mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 11:59:17 +08:00
Don't run each functional test in a different process
This commit is contained in:
@@ -1,54 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
from sys import argv, stderr
|
|
||||||
from subprocess import call, check_output
|
|
||||||
|
|
||||||
|
|
||||||
def list_all_tests(bin_path):
|
|
||||||
out = check_output(['./' + bin_path,"--gtest_list_tests"])
|
|
||||||
out = out.split("\n")
|
|
||||||
if len(out) > 1:
|
|
||||||
prefix = ''
|
|
||||||
tests_list = []
|
|
||||||
for token in out:
|
|
||||||
if len(token) == 0:
|
|
||||||
continue
|
|
||||||
if token[-1] == '.':
|
|
||||||
prefix = token
|
|
||||||
continue
|
|
||||||
if token[0] == ' ' and token[1] == ' ' and len(token) > 0:
|
|
||||||
tests_list.append(''.join([prefix, token[2:]]))
|
|
||||||
continue
|
|
||||||
|
|
||||||
return tests_list
|
|
||||||
|
|
||||||
else:
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run_tests(bin_path, tests_list, args):
|
|
||||||
for test in tests_list:
|
|
||||||
call_args = ['./' + bin_path, ' '.join(args), '--gtest_filter=*{}'.format(test)]
|
|
||||||
print(' '.join(call_args))
|
|
||||||
result = call(call_args)
|
|
||||||
if result != 0:
|
|
||||||
return result
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
if len(argv) >= 2:
|
|
||||||
try:
|
|
||||||
exit(run_tests(argv[1], list_all_tests(argv[1]), argv[2:]))
|
|
||||||
except:
|
|
||||||
print('Error with arguments "' + ' '.join(argv[1:]) + '"')
|
|
||||||
raise
|
|
||||||
print('Runs each gtest test in a difference process')
|
|
||||||
print('Usage: ' + argv[0] + ' path/to/gtest.bin [GTEST_OPTIONS]')
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
@@ -111,8 +111,7 @@ function(px4_add_functional_gtest)
|
|||||||
add_test(NAME ${TESTNAME}
|
add_test(NAME ${TESTNAME}
|
||||||
# functional tests need to run in a new process for each test,
|
# functional tests need to run in a new process for each test,
|
||||||
# since they set up and tear down system components
|
# since they set up and tear down system components
|
||||||
COMMAND ${PX4_SOURCE_DIR}/Tools/run-gtest-isolated.py ${TESTNAME}
|
COMMAND ${PX4_BINARY_DIR}/${TESTNAME})
|
||||||
WORKING_DIRECTORY ${PX4_BINARY_DIR})
|
|
||||||
|
|
||||||
# attach it to the unit test target
|
# attach it to the unit test target
|
||||||
add_dependencies(test_results ${TESTNAME})
|
add_dependencies(test_results ${TESTNAME})
|
||||||
|
|||||||
Reference in New Issue
Block a user