3 # This is a simple glue script to run the tests and collect the results
7 # We expect simple structure i.e. the tests_dir contains directories with
8 # tests, each directory that contains tests has test_list.txt with a list of
9 # tests to run. The structure is then mirrored in the results_dir filled with
17 # Relative path to root directory containing tests
22 # Results directory prefix
27 # Relative path to the directory with GP libraries to run tests against
32 # By default the glibc __libc_message() writes to /dev/tty before calling
33 # the abort(). Exporting this macro makes it to use stderr instead.
35 # The main usage of the function are malloc assertions, so this makes us catch
36 # the malloc error message by catching stderr output.
38 runline_prep
='export LIBC_FATAL_STDERR_=1;'
41 # Relative path, from the current directory, to the framework preload library.
43 framework_lib
='framework/libtst_preload.so'
48 return os
.getcwd() + '/' + path
51 # Reads test_list.txt test file and executes tests one after another
53 def run_test(resdir
, tstdir
, runtest
):
54 f
= open(runtest
, 'r')
69 # This is a little hairy but what it does is to constructs correct
70 # paths to preload and dynamic libraries and runs the test.
72 runline
= runline_prep
+ ' '
73 runline
+= 'export LD_PRELOAD="' + globpath(framework_lib
) + '"; '
74 runline
+= 'export LD_LIBRARY_PATH="' + globpath(build_dir
) + '"; '
75 runline
+= 'cd ' + tstdir
+ ' && ./' + line
+ ' -o "' + globpath(resdir
) + '"'
78 print(" LINE: %s" % runline
)
83 # Discovers tests in directories.
85 def run_tests(resdir
, testsdir
):
88 print('Looking for tests in "%s"' % testsdir
)
90 for root
, dirs
, _
in os
.walk(testsdir
):
93 path
= root
+ '/' + name
96 print('Looking into dir "%s"' % path
)
98 runtest
= path
+ '/test_list.txt'
100 if (os
.access(runtest
, os
.R_OK
)):
101 # Create result directory
102 curresdir
= resdir
+ '/' + name
105 print("\n========= Running " + name
+ " testsuites =========\n")
106 run_test(curresdir
, path
, runtest
)
109 now
= datetime
.datetime
.now()
110 resdir
= '%s_%i-%02i-%02i_%02i-%02i-%02i' % (results_dir
, now
.year
, now
.month
,
111 now
.day
, now
.hour
, now
.minute
, now
.second
)
112 print('Creating result directory "%s"' % resdir
)
115 run_tests(resdir
, tests_dir
)
117 if __name__
== '__main__':