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 | |
Lalit Maganti | 4c76b4d | 2022-01-11 15:37:41 +0000 | [diff] [blame] | 21 | from test import api_unittest |
| 22 | from test import api_integrationtest |
Lalit Maganti | 9fe07de | 2022-01-15 00:18:44 +0000 | [diff] [blame] | 23 | from test import resolver_unittest |
Anna Mayzner | b215390 | 2023-01-06 16:32:49 +0000 | [diff] [blame] | 24 | from test import stdlib_unittest |
Lalit Maganti | 4c76b4d | 2022-01-11 15:37:41 +0000 | [diff] [blame] | 25 | |
Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 26 | ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
Lalit Maganti | 6b2ac69 | 2023-05-23 01:24:29 +0100 | [diff] [blame] | 27 | sys.path.append(os.path.join(ROOT_DIR)) |
Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 28 | |
| 29 | |
| 30 | def main(): |
Primiano Tucci | 44a15be | 2021-11-06 21:40:18 +0000 | [diff] [blame] | 31 | try: |
| 32 | import numpy |
| 33 | import pandas |
| 34 | except ModuleNotFoundError: |
| 35 | print('Cannot proceed. Please `pip3 install pandas numpy`', file=sys.stderr) |
| 36 | return 1 |
| 37 | |
Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 38 | # Set paths to trace_processor_shell and root directory as environment |
| 39 | # variables |
| 40 | parser = argparse.ArgumentParser() |
| 41 | parser.add_argument("shell", type=str) |
| 42 | os.environ["SHELL_PATH"] = parser.parse_args().shell |
| 43 | os.environ["ROOT_DIR"] = ROOT_DIR |
| 44 | |
Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 45 | loader = unittest.TestLoader() |
| 46 | suite = unittest.TestSuite() |
| 47 | |
| 48 | # Add all relevant tests to test suite |
| 49 | suite.addTests(loader.loadTestsFromModule(api_unittest)) |
Lalit Maganti | 9fe07de | 2022-01-15 00:18:44 +0000 | [diff] [blame] | 50 | suite.addTests(loader.loadTestsFromModule(resolver_unittest)) |
Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 51 | suite.addTests(loader.loadTestsFromModule(api_integrationtest)) |
Anna Mayzner | b215390 | 2023-01-06 16:32:49 +0000 | [diff] [blame] | 52 | suite.addTests(loader.loadTestsFromModule(stdlib_unittest)) |
Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 53 | |
| 54 | # Initialise runner to run all tests in suite |
| 55 | runner = unittest.TextTestRunner(verbosity=3) |
| 56 | result = runner.run(suite) |
| 57 | |
Lalit Maganti | 0fdfdcf | 2020-08-25 15:55:10 +0100 | [diff] [blame] | 58 | return 0 if result.wasSuccessful() else 1 |
| 59 | |
Anindita Ghosh | 1582b41 | 2020-07-31 10:24:27 +0000 | [diff] [blame] | 60 | |
| 61 | if __name__ == '__main__': |
| 62 | sys.exit(main()) |