4 echo "Usage note: tcheadgen.sh <header_filename.h>"
10 HEADER_NAME=$(echo $1 | tr '[:lower:]' '[:upper:]' | sed -e 's/-/_/g' -e 's/\./_/')
11 SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)"
13 $SCRIPT_DIR/retriever.sh > $TFILE
14 if [ $? -ne 0 ]; then cat $TFILE; exit 1; fi
15 awk -F',' -v HEADER_NAME="$HEADER_NAME" '
26 testcase_list[0] = "";
29 tc_array_list[0] = "";
31 print "#ifndef __" HEADER_NAME "__"
32 print "#define __" HEADER_NAME "__"
34 print "#include \"testcase.h\""
38 testcase_list[testcase_counter++] = $1;
40 if (startup_counter == 0 || startup_list[startup_counter-1] != $2)
41 startup_list[startup_counter++] = $2;
43 if (startup_counter == 0 || cleanup_list[cleanup_counter-1] != $3)
44 cleanup_list[cleanup_counter++] = $3;
46 tc_array_list[tc_array_counter++] = "\"" $1 "\", " $1 ", " $2 ", " $3;
49 sc_count = (startup_counter > cleanup_counter) ? startup_counter : cleanup_counter;
50 for (i = 0; i < sc_count; i++) {
51 if (i < startup_counter && startup_list[i] != "NULL")
52 print "extern void " startup_list[i] "(void);"
53 if (i < cleanup_counter && cleanup_list[i] != "NULL")
54 print "extern void " cleanup_list[i] "(void);"
58 for (i = 0; i < testcase_counter; i++)
59 print "extern int " testcase_list[i] "(void);"
62 print "testcase tc_array[] = {"
64 for (i = 0; i < tc_array_counter; i++)
65 print " {" tc_array_list[i] "},"
70 print "#endif // __" HEADER_NAME "__"