blob: 78a78a10ec24d966c111b2c041b483dae7957aeb [file] [log] [blame]
Anindita Ghosh1582b412020-07-31 10:24:27 +00001#!/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
21ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
22
23
24def main():
Primiano Tucci44a15be2021-11-06 21:40:18 +000025 try:
26 import numpy
27 import pandas
28 except ModuleNotFoundError:
29 print('Cannot proceed. Please `pip3 install pandas numpy`', file=sys.stderr)
30 return 1
31
Anindita Ghosh1582b412020-07-31 10:24:27 +000032 # Append test and src paths so that all imports are loaded in correctly
33 sys.path.append(os.path.join(ROOT_DIR, 'test', 'trace_processor', 'python'))
Anindita Ghosh456261f2020-09-07 11:31:24 +010034 sys.path.append(
35 os.path.join(ROOT_DIR, 'src', 'trace_processor', 'python', 'perfetto'))
Anindita Ghosh1582b412020-07-31 10:24:27 +000036 import api_unittest
37 import api_integrationtest
38
39 # Set paths to trace_processor_shell and root directory as environment
40 # variables
41 parser = argparse.ArgumentParser()
42 parser.add_argument("shell", type=str)
43 os.environ["SHELL_PATH"] = parser.parse_args().shell
44 os.environ["ROOT_DIR"] = ROOT_DIR
45
46 # Initialise test suite
47 loader = unittest.TestLoader()
48 suite = unittest.TestSuite()
49
50 # Add all relevant tests to test suite
51 suite.addTests(loader.loadTestsFromModule(api_unittest))
52 suite.addTests(loader.loadTestsFromModule(api_integrationtest))
53
54 # Initialise runner to run all tests in suite
55 runner = unittest.TextTestRunner(verbosity=3)
56 result = runner.run(suite)
57
Lalit Maganti0fdfdcf2020-08-25 15:55:10 +010058 return 0 if result.wasSuccessful() else 1
59
Anindita Ghosh1582b412020-07-31 10:24:27 +000060
61if __name__ == '__main__':
62 sys.exit(main())