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 16import argparse 17import os 18import sys 19import unittest 20 21from test import api_unittest 22from test import api_integrationtest 23from test import resolver_unittest 24 25ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 26 27 28def main(): 29 try: 30 import numpy 31 import pandas 32 except ModuleNotFoundError: 33 print('Cannot proceed. Please `pip3 install pandas numpy`', file=sys.stderr) 34 return 1 35 36 # Set paths to trace_processor_shell and root directory as environment 37 # variables 38 parser = argparse.ArgumentParser() 39 parser.add_argument("shell", type=str) 40 os.environ["SHELL_PATH"] = parser.parse_args().shell 41 os.environ["ROOT_DIR"] = ROOT_DIR 42 43 loader = unittest.TestLoader() 44 suite = unittest.TestSuite() 45 46 # Add all relevant tests to test suite 47 suite.addTests(loader.loadTestsFromModule(api_unittest)) 48 suite.addTests(loader.loadTestsFromModule(resolver_unittest)) 49 suite.addTests(loader.loadTestsFromModule(api_integrationtest)) 50 51 # Initialise runner to run all tests in suite 52 runner = unittest.TextTestRunner(verbosity=3) 53 result = runner.run(suite) 54 55 return 0 if result.wasSuccessful() else 1 56 57 58if __name__ == '__main__': 59 sys.exit(main()) 60