Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # Copyright (C) 2020 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | import argparse |
| 17 | import os |
| 18 | import sys |
| 19 | import unittest |
| 20 | |
| 21 | ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 22 | |
| 23 | |
| 24 | def main(): |
| 25 | # Append test and src paths so that all imports are loaded in correctly |
| 26 | sys.path.append(os.path.join(ROOT_DIR, 'test', 'trace_processor', 'python')) |
Anindita Ghosh | 456261f | 2020-09-07 11:31:24 +0100 | [diff] [blame] | 27 | sys.path.append( |
| 28 | os.path.join(ROOT_DIR, 'src', 'trace_processor', 'python', 'perfetto')) |
Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 29 | import api_unittest |
| 30 | import api_integrationtest |
| 31 | |
| 32 | # Set paths to trace_processor_shell and root directory as environment |
| 33 | # variables |
| 34 | parser = argparse.ArgumentParser() |
| 35 | parser.add_argument("shell", type=str) |
| 36 | os.environ["SHELL_PATH"] = parser.parse_args().shell |
| 37 | os.environ["ROOT_DIR"] = ROOT_DIR |
| 38 | |
| 39 | # Initialise test suite |
| 40 | loader = unittest.TestLoader() |
| 41 | suite = unittest.TestSuite() |
| 42 | |
| 43 | # Add all relevant tests to test suite |
| 44 | suite.addTests(loader.loadTestsFromModule(api_unittest)) |
| 45 | suite.addTests(loader.loadTestsFromModule(api_integrationtest)) |
| 46 | |
| 47 | # Initialise runner to run all tests in suite |
| 48 | runner = unittest.TextTestRunner(verbosity=3) |
| 49 | result = runner.run(suite) |
| 50 | |
Lalit Maganti | 0fdfdcf | 2020-08-25 15:55:10 +0100 | [diff] [blame] | 51 | return 0 if result.wasSuccessful() else 1 |
| 52 | |
Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 53 | |
| 54 | if __name__ == '__main__': |
| 55 | sys.exit(main()) |