aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorOliver O'Halloran <oohall@gmail.com>2017-11-30 16:31:29 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-12-01 00:54:47 -0600
commitdaf9ff43cd0a2845a06b4f6cb209eab0111e13a3 (patch)
tree52106fc2dc539e5b0138800e546a10ab05d524d5 /external
parentaa82932e71906cbec11b708eba3979688f1d0ad9 (diff)
downloadskiboot-daf9ff43cd0a2845a06b4f6cb209eab0111e13a3.zip
skiboot-daf9ff43cd0a2845a06b4f6cb209eab0111e13a3.tar.gz
skiboot-daf9ff43cd0a2845a06b4f6cb209eab0111e13a3.tar.bz2
gard: Add tests
I hear Stewart likes these for some reason. Dunno why. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rwxr-xr-xexternal/gard/test/add_test.sh67
-rw-r--r--external/gard/test/files/blank.binbin0 -> 20480 bytes
-rw-r--r--external/gard/test/results/04-create-bad-instance.err2
-rw-r--r--external/gard/test/results/04-create-bad-instance.out0
-rw-r--r--external/gard/test/results/05-create-bad-unit.err2
-rw-r--r--external/gard/test/results/05-create-bad-unit.out0
-rw-r--r--external/gard/test/results/06-create-long-path.err2
-rw-r--r--external/gard/test/results/06-create-long-path.out0
-rw-r--r--external/gard/test/results/07-create-slash.err2
-rw-r--r--external/gard/test/results/07-create-slash.out0
-rw-r--r--external/gard/test/results/08-create-duplicate.err1
-rw-r--r--external/gard/test/results/08-create-duplicate.out0
-rw-r--r--external/gard/test/results/09-create-last-unit.err0
-rw-r--r--external/gard/test/results/09-create-last-unit.out4
-rw-r--r--external/gard/test/tests/00-list2
-rw-r--r--external/gard/test/tests/01-show_12
-rw-r--r--external/gard/test/tests/04-create-bad-instance10
-rw-r--r--external/gard/test/tests/05-create-bad-unit10
-rw-r--r--external/gard/test/tests/06-create-long-path10
-rw-r--r--external/gard/test/tests/07-create-slash10
-rw-r--r--external/gard/test/tests/08-create-duplicate10
-rw-r--r--external/gard/test/tests/09-create-last-unit16
22 files changed, 148 insertions, 2 deletions
diff --git a/external/gard/test/add_test.sh b/external/gard/test/add_test.sh
new file mode 100755
index 0000000..8e77360
--- /dev/null
+++ b/external/gard/test/add_test.sh
@@ -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
diff --git a/external/gard/test/files/blank.bin b/external/gard/test/files/blank.bin
new file mode 100644
index 0000000..c6cc6b8
--- /dev/null
+++ b/external/gard/test/files/blank.bin
Binary files differ
diff --git a/external/gard/test/results/04-create-bad-instance.err b/external/gard/test/results/04-create-bad-instance.err
new file mode 100644
index 0000000..2a8da50
--- /dev/null
+++ b/external/gard/test/results/04-create-bad-instance.err
@@ -0,0 +1,2 @@
+Instance 256 is invalid. Must be 0 to 255
+Unable to parse path
diff --git a/external/gard/test/results/04-create-bad-instance.out b/external/gard/test/results/04-create-bad-instance.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/external/gard/test/results/04-create-bad-instance.out
diff --git a/external/gard/test/results/05-create-bad-unit.err b/external/gard/test/results/05-create-bad-unit.err
new file mode 100644
index 0000000..aa1af82
--- /dev/null
+++ b/external/gard/test/results/05-create-bad-unit.err
@@ -0,0 +1,2 @@
+Unknown unit at: 'doesnt_exist0'
+Unable to parse path
diff --git a/external/gard/test/results/05-create-bad-unit.out b/external/gard/test/results/05-create-bad-unit.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/external/gard/test/results/05-create-bad-unit.out
diff --git a/external/gard/test/results/06-create-long-path.err b/external/gard/test/results/06-create-long-path.err
new file mode 100644
index 0000000..f79a3bd
--- /dev/null
+++ b/external/gard/test/results/06-create-long-path.err
@@ -0,0 +1,2 @@
+Path has more than 10 components!
+Unable to parse path
diff --git a/external/gard/test/results/06-create-long-path.out b/external/gard/test/results/06-create-long-path.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/external/gard/test/results/06-create-long-path.out
diff --git a/external/gard/test/results/07-create-slash.err b/external/gard/test/results/07-create-slash.err
new file mode 100644
index 0000000..6fd6876
--- /dev/null
+++ b/external/gard/test/results/07-create-slash.err
@@ -0,0 +1,2 @@
+Unknown unit at: ''
+Unable to parse path
diff --git a/external/gard/test/results/07-create-slash.out b/external/gard/test/results/07-create-slash.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/external/gard/test/results/07-create-slash.out
diff --git a/external/gard/test/results/08-create-duplicate.err b/external/gard/test/results/08-create-duplicate.err
new file mode 100644
index 0000000..4c40739
--- /dev/null
+++ b/external/gard/test/results/08-create-duplicate.err
@@ -0,0 +1 @@
+Unit /Sys0/Node0/Membuf0 is already GARDed by record 0x000002
diff --git a/external/gard/test/results/08-create-duplicate.out b/external/gard/test/results/08-create-duplicate.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/external/gard/test/results/08-create-duplicate.out
diff --git a/external/gard/test/results/09-create-last-unit.err b/external/gard/test/results/09-create-last-unit.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/external/gard/test/results/09-create-last-unit.err
diff --git a/external/gard/test/results/09-create-last-unit.out b/external/gard/test/results/09-create-last-unit.out
new file mode 100644
index 0000000..62cfcbb
--- /dev/null
+++ b/external/gard/test/results/09-create-last-unit.out
@@ -0,0 +1,4 @@
+ ID | Error | Type | Path
+----------------------------------------------------------------------------------------------------------------------------------------------------------------
+ 00000001 | 00000000 | Manual | /MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255/MFREFCLK255
+================================================================================================================================================================
diff --git a/external/gard/test/tests/00-list b/external/gard/test/tests/00-list
index 8e285c4..aa38fc3 100644
--- a/external/gard/test/tests/00-list
+++ b/external/gard/test/tests/00-list
@@ -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
diff --git a/external/gard/test/tests/01-show_1 b/external/gard/test/tests/01-show_1
index 66ee732..dc67b93 100644
--- a/external/gard/test/tests/01-show_1
+++ b/external/gard/test/tests/01-show_1
@@ -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
diff --git a/external/gard/test/tests/04-create-bad-instance b/external/gard/test/tests/04-create-bad-instance
new file mode 100644
index 0000000..29e08bd
--- /dev/null
+++ b/external/gard/test/tests/04-create-bad-instance
@@ -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
diff --git a/external/gard/test/tests/05-create-bad-unit b/external/gard/test/tests/05-create-bad-unit
new file mode 100644
index 0000000..cfe4b71
--- /dev/null
+++ b/external/gard/test/tests/05-create-bad-unit
@@ -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
diff --git a/external/gard/test/tests/06-create-long-path b/external/gard/test/tests/06-create-long-path
new file mode 100644
index 0000000..7eb197b
--- /dev/null
+++ b/external/gard/test/tests/06-create-long-path
@@ -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
diff --git a/external/gard/test/tests/07-create-slash b/external/gard/test/tests/07-create-slash
new file mode 100644
index 0000000..3897a7b
--- /dev/null
+++ b/external/gard/test/tests/07-create-slash
@@ -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
diff --git a/external/gard/test/tests/08-create-duplicate b/external/gard/test/tests/08-create-duplicate
new file mode 100644
index 0000000..7179a14
--- /dev/null
+++ b/external/gard/test/tests/08-create-duplicate
@@ -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
diff --git a/external/gard/test/tests/09-create-last-unit b/external/gard/test/tests/09-create-last-unit
new file mode 100644
index 0000000..d293057
--- /dev/null
+++ b/external/gard/test/tests/09-create-last-unit
@@ -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