]> git.llucax.com Git - software/mutest.git/blobdiff - mkmutest
Implement test suite initialization and termination
[software/mutest.git] / mkmutest
index 1bfec88a20850dae61d1bc18528e93838100b84e..c6b941b6e1ac1b5f5879d52f4edb6e62e739642a 100755 (executable)
--- a/mkmutest
+++ b/mkmutest
 # cases must have unique names, even across test suites.
 
 # the first argument should be mutest.h
+if [ -z "$1" ]
+then
+       echo "Too few arguments" >&2
+       echo "Usage: $0 mutest_h_location [object files...]" >&2
+       exit 1
+fi
 mutest_h="$1"
 shift
 echo "#include \"$mutest_h\""
@@ -24,18 +30,31 @@ echo "void mu_run_suites() {"
 echo
 for file in "$@"
 do
-       suite="`basename "$file" .o | sed 's/\"/\\\\\"/g'`"
-       echo -e '\tmutest_suite_name = "'"$suite"'";'
-       echo -e '\tmu_print(MU_SUITE, "\\nRunning suite \"'"$suite"'\"\\n");'
-       for symbol in `nm -p "$file" \
-                       | egrep '^[[:xdigit:]]{8} T mu_test\w*$' \
-                       | cut -c12-`
+       pr_file=`echo "$file" | sed 's/\"/\\\\\"/g'`
+       suite=`basename "$file" .o | sed 's/\"/\\\\\"/g'`
+       symbols=`nm -p "$file" | egrep '^[[:xdigit:]]{8} T mu_\w+$' | cut -c12-`
+       tests=`echo "$symbols" | egrep '^mu_test'`
+       inits=`echo "$symbols" | egrep '^mu_init'`
+       terms=`echo "$symbols" | egrep '^mu_term'`
+       echo -e '\tdo {'
+       echo -e '\t\tmutest_suite_name = "'"$suite"'";'
+       echo -e '\t\tmu_print(MU_SUITE, "\\nRunning suite '"'$suite'"'\\n");'
+       for init in $inits
        do
-               echo -e "\tmu_run_case($symbol);"
+               echo -e "\\t\\tmu_run_init($init);"
        done
-       echo -e "\tif (mutest_suite_failed) ++mutest_failed_suites;"
-       echo -e "\telse                     ++mutest_passed_suites;"
-       echo -e "\tmutest_suite_failed = 0;"
+       for testcase in $tests
+       do
+               echo -e "\t\tmu_run_case($testcase);"
+       done
+       for term in $terms
+       do
+               echo -e "\t\tmu_run_term($term);"
+       done
+       echo -e "\t\tif (mutest_suite_failed) ++mutest_failed_suites;"
+       echo -e "\t\telse                     ++mutest_passed_suites;"
+       echo -e "\t\tmutest_suite_failed = 0;"
+       echo -e '\t} while (0);'
        echo
 done
 echo "}"