]> git.ozlabs.org Git - petitboot/blobdiff - test/urls/run-url-test.in
test: Add URL parser test infrastructure
[petitboot] / test / urls / run-url-test.in
diff --git a/test/urls/run-url-test.in b/test/urls/run-url-test.in
new file mode 100755 (executable)
index 0000000..834166f
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+parser="@abs_builddir@/parse-url"
+testfile=$1
+
+url=$(head -n1 $testfile)
+
+tmp=$(mktemp)
+trap "rm $tmp" EXIT
+
+$parser $url > $tmp
+if test $? -ne 0
+then
+       echo "Error running $parser on $testfile"
+       exit 2
+fi
+
+cmp --silent $testfile $tmp
+result=$?
+
+if test $result -ne 0
+then
+       echo "FAIL: URL parse results differ:"
+       diff -u $testfile $tmp
+fi
+
+exit $result