4 This file runs all of the yaffs unit tests and aggrates the outputs.
6 To run this file you can use:
8 $ python3 test_runner.py
14 To add a new test to this test runner, add the test dir path to the
15 test_list below. Inside that folder there need to be a makefile with
16 a "test" target that compiles and runs the test script. I.e. "make test"
17 is called in every test directory.
21 import subprocess, sys
23 test_list = ["is_yaffs_working_tests",
25 "64_and_32_bit_time/64_bit",
26 "64_and_32_bit_time/32_bit",
33 def run(makefile_paths):
35 for path in makefile_paths:
36 print("\nrunning test {}".format(path))
37 is_successful, test_output = run_makefile_test(path)
38 if is_successful != TEST_PASSED:
39 print('\033[41m' +'test {} failed'.format(path)+'\033[0m')
41 failed_tests.append( (path, is_successful) )
43 print('\033[42m' +"test passed"+'\033[0m')
46 def run_makefile_test(path):
48 subprocess.check_output("make -j -C {} test".format(path), shell=True)
49 except subprocess.CalledProcessError as e:
50 return (TEST_FAILED, e.output.decode('UTF-8'))
52 return (TEST_PASSED, "test passed")
54 if __name__ == "__main__":
56 failed_tests = run(test_list)
58 print("\ntest summary #############")
59 if len(failed_tests) == 0:
60 print('\033[42m' +"all tests passed"+'\033[0m')
62 for path, output in failed_tests:
63 print('\033[41m' +"test {} failed".format(path)+'\033[0m')
64 print('\033[41m' + "ran {} tests, {} failed".format(len(test_list), len(failed_tests))+'\033[0m')