4 echo "Usage note: tcheadgen.sh <header_filename.h> <test-sources>"
11 TFILE="/tmp/retr.csv$$"
12 HEADER_NAME=$(echo $1 | tr '[:lower:]' '[:upper:]' | sed -e 's/-/_/g' -e 's/\./_/')
13 SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)"
15 $SCRIPT_DIR/retriever.sh $TC_FILES > $TFILE
16 if [ $? -ne 0 ]; then cat $TFILE; exit 1; fi
17 awk -F',' -v HEADER_NAME="$HEADER_NAME" '
28 testcase_list[0] = "";
31 tc_array_list[0] = "";
33 print "#ifndef " HEADER_NAME
34 print "#define " HEADER_NAME
36 print "#include \"testcase.h\""
40 testcase_list[testcase_counter++] = $1;
42 if (startup_counter == 0 || startup_list[startup_counter-1] != $2)
43 startup_list[startup_counter++] = $2;
45 if (startup_counter == 0 || cleanup_list[cleanup_counter-1] != $3)
46 cleanup_list[cleanup_counter++] = $3;
48 tc_array_list[tc_array_counter++] = "\"" $1 "\", " $1 ", " $2 ", " $3;
51 sc_count = (startup_counter > cleanup_counter) ? startup_counter : cleanup_counter;
52 for (i = 0; i < sc_count; i++) {
53 if (i < startup_counter && startup_list[i] != "NULL")
54 print "extern void " startup_list[i] "(void);"
55 if (i < cleanup_counter && cleanup_list[i] != "NULL")
56 print "extern void " cleanup_list[i] "(void);"
60 for (i = 0; i < testcase_counter; i++)
61 print "extern int " testcase_list[i] "(void);"
64 print "testcase tc_array[] = {"
66 for (i = 0; i < tc_array_counter; i++)
67 print " {" tc_array_list[i] "},"
72 print "#endif // " HEADER_NAME