Files
bizhang_-obav/Tools/run-gtest-isolated.py
Julian Kent d70b024ec7 GTest functional tests that include parameters and uORB messaging (#12521)
* Add kdevelop to gitignore

* Add test stubs

* Rename px4_add_gtest to px4_add_unit_gtest

* Add infrastructure to run functional tests

* Add example tests with parameters and uorb messages

* Fix memory issues in destructors in uORB manager and CDev

* Add a more real-world test of the collision prevention
2019-08-09 15:10:09 +02:00

55 lines
1.3 KiB
Python
Executable File

#!/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()