new file mode 100755
@@ -0,0 +1,67 @@
+#!/bin/bash -uex
+#
+# this is a really dumb script for auto-generating test cases from known good-data
+#
+# usage: ./add_test <pass|fail> <inputfile> <testname> [gard subcommand]
+#
+# e.g.
+# ./add_test.sh fail blank.bin create-bad-instance create /sys256
+# ./add_test.sh pass blank.bin create-normal create /sys0/node0/proc0
+#
+# this will generate a test script file and writes the stdout/stderr of the command
+# to the respective files.
+#
+
+cd $(dirname $(realpath $0))/../
+echo $PWD
+
+if [ "$1" = "pass" ]; then
+ check='if [ "$?" -ne 0 ]; then'
+ test_type="pass"
+else
+ check='if [ "$?" -eq 0 ]; then'
+ test_type="fails"
+fi
+shift
+
+file="test/files/$1"
+if [ ! -f "$file" ]; then
+ echo "test file not found!"
+ exit 1;
+fi
+shift
+
+name="$1"
+shift
+
+max="$(ls test/tests/ -1|sort -n | sed 's@\(..\).*@\1@' | tail -1 | sed s@^0*@@)"
+num="$(printf %02d $((max + 1)))"
+
+echo "Adding: $num-$name"
+
+# where we will write the script file
+script_file="test/tests/$num-$name"
+
+echo "making $num-$name: f=$script_file, normally $test_type, cmd='$*'"
+
+cat > $script_file <<EOF
+#! /bin/sh
+
+run_binary "./gard" "-9 -p -e -f $file $*"
+$check
+ fail_test
+fi
+
+diff_with_result
+
+pass_test
+EOF
+
+# generate the .out and .err files
+stdout_file="test/results/$num-$name.out"
+stderr_file="test/results/$num-$name.err"
+
+test_input="$name-$num-input"
+cp $file $test_input
+./gard -f $test_input -p -e $* 2>$stderr_file >$stdout_file
+rm -f $test_input
new file mode 100644
GIT binary patch
literal 20480
zcmeIxu?YYG2m?X)Upfjpg5}x7`r(qjx{YT_h#&$N6i`3`1r$&~0R<FLKmi35P(T3%
z6i`3`1r$&~0R<FLKmi35P(T3%6i`3`1r$&~0R<FLKmi35P(T3%6i`3`1r$&~0R<FL
cKmi35P(T3%6i`3`1r$&~0R<FLK*6tq28;XI{r~^~
literal 0
HcmV?d00001
new file mode 100644
@@ -0,0 +1,2 @@
+Instance 256 is invalid. Must be 0 to 255
+Unable to parse path
new file mode 100644
new file mode 100644
@@ -0,0 +1,2 @@
+Unknown unit at: 'doesnt_exist0'
+Unable to parse path
new file mode 100644
new file mode 100644
@@ -0,0 +1,2 @@
+Path has more than 10 components!
+Unable to parse path
new file mode 100644
new file mode 100644
@@ -0,0 +1,2 @@
+Unknown unit at: ''
+Unable to parse path
new file mode 100644
new file mode 100644
@@ -0,0 +1 @@
+Unit /Sys0/Node0/Membuf0 is already GARDed by record 0x000002
new file mode 100644
new file mode 100644
new file mode 100644
@@ -0,0 +1,4 @@
+ ID | Error | Type | Path
+----------------------------------------------------------------------------------------------------------------------------------------------------------------
+ 00000001 | 00000000 | Manual | /MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255
+================================================================================================================================================================
@@ -1,6 +1,6 @@
#! /bin/sh
-run_binary "./gard" "-p -e -f test/files/data1.bin list"
+run_binary "./gard" "-p -e -8 -f test/files/data1.bin list"
if [ "$?" -ne 0 ] ; then
fail_test
fi
@@ -1,6 +1,6 @@
#! /bin/sh
-run_binary "./gard" "-p -e -f test/files/data1.bin show 1"
+run_binary "./gard" "-p -e -8 -f test/files/data1.bin show 1"
if [ "$?" -ne 0 ] ; then
fail_test
fi
new file mode 100644
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+run_binary "./gard" "-p -e -8 -f test/files/blank.bin create /sys256"
+if [ "$?" -eq 0 ]; then
+ fail_test
+fi
+
+diff_with_result
+
+pass_test
new file mode 100644
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+run_binary "./gard" "-p -e -f test/files/blank.bin create /doesnt_exist0"
+if [ "$?" -eq 0 ]; then
+ fail_test
+fi
+
+diff_with_result
+
+pass_test
new file mode 100644
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+run_binary "./gard" "-p -e -8 -f test/files/blank.bin create /sys0/sys0/sys0/sys0/sys0/sys0/sys0/sys0/sys0/sys0/sys0/sys0/"
+if [ "$?" -eq 0 ]; then
+ fail_test
+fi
+
+diff_with_result
+
+pass_test
new file mode 100644
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+run_binary "./gard" "-p -e -f test/files/blank.bin create /"
+if [ "$?" -eq 0 ]; then
+ fail_test
+fi
+
+diff_with_result
+
+pass_test
new file mode 100644
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+run_binary "./gard" "-p -e -8 -f test/files/data1.bin create /Sys0/Node0/Membuf0"
+if [ "$?" -eq 0 ]; then
+ fail_test
+fi
+
+diff_with_result
+
+pass_test
new file mode 100644
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+cp test/files/blank.bin $DATA_DIR/input
+run_binary "./gard" "-9 -p -e -f $DATA_DIR/input create /MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255"
+if [ "$?" -ne 0 ]; then
+ fail_test
+fi
+
+run_binary "./gard" "-9 -p -e -f $DATA_DIR/input list"
+if [ "$?" -ne 0 ]; then
+ fail_test
+fi
+
+diff_with_result
+
+pass_test
I hear Stewart likes these for some reason. Dunno why. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- external/gard/test/add_test.sh | 67 +++++++++++++++++++++ external/gard/test/files/blank.bin | Bin 0 -> 20480 bytes .../gard/test/results/04-create-bad-instance.err | 2 + .../gard/test/results/04-create-bad-instance.out | 0 external/gard/test/results/05-create-bad-unit.err | 2 + external/gard/test/results/05-create-bad-unit.out | 0 external/gard/test/results/06-create-long-path.err | 2 + external/gard/test/results/06-create-long-path.out | 0 external/gard/test/results/07-create-slash.err | 2 + external/gard/test/results/07-create-slash.out | 0 external/gard/test/results/08-create-duplicate.err | 1 + external/gard/test/results/08-create-duplicate.out | 0 external/gard/test/results/09-create-last-unit.err | 0 external/gard/test/results/09-create-last-unit.out | 4 ++ external/gard/test/tests/00-list | 2 +- external/gard/test/tests/01-show_1 | 2 +- external/gard/test/tests/04-create-bad-instance | 10 +++ external/gard/test/tests/05-create-bad-unit | 10 +++ external/gard/test/tests/06-create-long-path | 10 +++ external/gard/test/tests/07-create-slash | 10 +++ external/gard/test/tests/08-create-duplicate | 10 +++ external/gard/test/tests/09-create-last-unit | 16 +++++ 22 files changed, 148 insertions(+), 2 deletions(-) create mode 100755 external/gard/test/add_test.sh create mode 100644 external/gard/test/files/blank.bin create mode 100644 external/gard/test/results/04-create-bad-instance.err create mode 100644 external/gard/test/results/04-create-bad-instance.out create mode 100644 external/gard/test/results/05-create-bad-unit.err create mode 100644 external/gard/test/results/05-create-bad-unit.out create mode 100644 external/gard/test/results/06-create-long-path.err create mode 100644 external/gard/test/results/06-create-long-path.out create mode 100644 external/gard/test/results/07-create-slash.err create mode 100644 external/gard/test/results/07-create-slash.out create mode 100644 external/gard/test/results/08-create-duplicate.err create mode 100644 external/gard/test/results/08-create-duplicate.out create mode 100644 external/gard/test/results/09-create-last-unit.err create mode 100644 external/gard/test/results/09-create-last-unit.out create mode 100644 external/gard/test/tests/04-create-bad-instance create mode 100644 external/gard/test/tests/05-create-bad-unit create mode 100644 external/gard/test/tests/06-create-long-path create mode 100644 external/gard/test/tests/07-create-slash create mode 100644 external/gard/test/tests/08-create-duplicate create mode 100644 external/gard/test/tests/09-create-last-unit