#!/usr/bin/env python # # Copyright (C) 2025 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import os import subprocess import sys """ This script runs all of Torq's unit tests specified in the Android.bp file. All tests can be run with: ./torq_test You can filter to only run specific tests with: ./torq_test torq_unit_test device_unit_test """ if __name__ == "__main__": # Find the Android.bp file script_dir = os.path.dirname(os.path.abspath(__file__)) android_bp_path = os.path.join(script_dir, '..', 'Android.bp') # Get all test names tests = [] has_pending_test = False try: with open(android_bp_path, 'r') as f: for line in f: text = line.strip() if 'python_test_host' in text: has_pending_test = True elif has_pending_test and 'name' in text: # parse the test host name tests.append(text.split(':')[-1].strip()[1:-2]) has_pending_test = False except FileNotFoundError: print(f"Error: Android.bp file not found at: {android_bp_path}") sys.exit(1) except Exception as e: print(f"Error reading Android.bp: {e}") sys.exit(1) # Filter out unwanted tests filter_tests = sys.argv[1:] if len(filter_tests) > 0: tests = list(filter(lambda e: e in filter_tests, tests)) cmd = ['atest'] + tests # Run atest for all the tests subprocess.run(cmd)