3 # This file is part of mutest, a micro testing framework for C.
5 # mutest is under the BOLA license, please see the LICENSE file or visit
6 # http://blitiri.com.ar/p/bola/
8 # This is a simple script to generate a C file that runs all the test cases
9 # present in .o files passed as arguments.
11 # Please, read the README file for more details.
14 # the trick here is getting all the test cases present in an object file using
15 # nm. All the tests must take and return void, start with "mutest_" and, of
16 # course, should not be static, which leads to a small limitation: all test
17 # cases must have unique names, even across test suites.
19 # the first argument should be mutest.h
22 echo "#include \"$mutest_h\""
23 echo "void mu_run_suites() {"
27 suite="`basename "$file" .o | sed 's/\"/\\\\\"/g'`"
28 echo -e '\tmutest_suite_name = "'"$suite"'";'
29 echo -e '\tmu_print(MU_SUITE, "\\nRunning suite \"'"$suite"'\"\\n");'
30 for symbol in `nm -p "$file" \
31 | egrep '^[[:xdigit:]]{8} T mu_test\w*$' \
34 echo -e "\tmu_run_case($symbol);"
36 echo -e "\tif (mutest_suite_failed) ++mutest_failed_suites;"
37 echo -e "\telse ++mutest_passed_suites;"
38 echo -e "\tmutest_suite_failed = 0;"