1#!/usr/bin/python 2# 3# Copyright 2018 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17from importlib import import_module 18import sys 19import unittest 20 21test_modules = [ 22 'anycast_test', 23 'bpf_test', 24 'csocket_test', 25 'cstruct_test', 26 'forwarding_test', 27 'leak_test', 28 'multinetwork_test', 29 'neighbour_test', 30 'nf_test', 31 'pf_key_test', 32 'ping6_test', 33 'policy_crash_test', 34 'qtaguid_test', 35 'removed_feature_test', 36 'resilient_rs_test', 37 'sock_diag_test', 38 'srcaddr_selection_test', 39 'tcp_fastopen_test', 40 'tcp_nuke_addr_test', 41 'tcp_repair_test', 42 'tcp_test', 43 'xfrm_algorithm_test', 44 'xfrm_test', 45 'xfrm_tunnel_test', 46] 47 48if __name__ == '__main__': 49 # First, run InjectTests on all modules, to ensure that any parameterized 50 # tests in those modules are injected. 51 for name in test_modules: 52 import_module(name) 53 if hasattr(sys.modules[name], "InjectTests"): 54 sys.modules[name].InjectTests() 55 56 loader = unittest.defaultTestLoader 57 test_suite = loader.loadTestsFromNames(test_modules) 58 runner = unittest.TextTestRunner(verbosity=2) 59 result = runner.run(test_suite) 60 sys.exit(not result.wasSuccessful()) 61