aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite.awk
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite.awk')
-rwxr-xr-xtestsuite.awk32
1 files changed, 32 insertions, 0 deletions
diff --git a/testsuite.awk b/testsuite.awk
new file mode 100755
index 0000000..2c9fd14
--- /dev/null
+++ b/testsuite.awk
@@ -0,0 +1,32 @@
+#!/usr/bin/awk -f
+
+BEGIN {
+ RS = "--\n"
+ FS = ":\n"
+}
+
+function runtest(id, code, output,
+ failed)
+{
+ print code > "script.sh"
+ print output > "output"
+
+ failed = 0
+
+ if (output == "ERR\n") {
+ if (system("sh script.sh > /dev/null 2>&1") == 0)
+ failed = 1
+ } else if (system("[ \"$(sh script.sh)\" = \"$(cat output)\" ]") != 0) {
+ failed = 1
+ }
+
+ if (failed)
+ printf("test %s failed (for cppawk = %s)\n", id, ENVIRON["cppawk"])
+
+ close("script.sh")
+ close("output")
+}
+
+$1 {
+ runtest($1, $2, $3)
+}