[Skiboot] [PATCH v2 2/2] external/gard/tests: Add tests for the gard tool

Cyril Bur cyril.bur at au1.ibm.com
Wed Sep 16 13:55:51 AEST 2015


Simple tests for the gard tool that can be expanded on over time

Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 external/gard/Makefile                   |   6 +++++-
 external/gard/test/Makefile.check        |  16 ++++++++++++++++
 external/gard/test/files/data1.bin       | Bin 0 -> 20480 bytes
 external/gard/test/make-check-test       |   1 +
 external/gard/test/results/00-list.err   |   0
 external/gard/test/results/00-list.out   |   5 +++++
 external/gard/test/results/01-show_1.err |   0
 external/gard/test/results/01-show_1.out |   9 +++++++++
 external/gard/test/results/02-usage.err  |  18 ++++++++++++++++++
 external/gard/test/results/02-usage.out  |   0
 external/gard/test/test-gard             |   5 +++++
 external/gard/test/test.sh               |   1 +
 external/gard/test/tests/00-list         |  10 ++++++++++
 external/gard/test/tests/01-show_1       |  10 ++++++++++
 external/gard/test/tests/02-usage        |  10 ++++++++++
 15 files changed, 90 insertions(+), 1 deletion(-)
 create mode 100644 external/gard/test/Makefile.check
 create mode 100644 external/gard/test/files/data1.bin
 create mode 100755 external/gard/test/make-check-test
 create mode 100644 external/gard/test/results/00-list.err
 create mode 100644 external/gard/test/results/00-list.out
 create mode 100644 external/gard/test/results/01-show_1.err
 create mode 100644 external/gard/test/results/01-show_1.out
 create mode 100644 external/gard/test/results/02-usage.err
 create mode 100644 external/gard/test/results/02-usage.out
 create mode 100755 external/gard/test/test-gard
 create mode 120000 external/gard/test/test.sh
 create mode 100644 external/gard/test/tests/00-list
 create mode 100644 external/gard/test/tests/01-show_1
 create mode 100644 external/gard/test/tests/02-usage

diff --git a/external/gard/Makefile b/external/gard/Makefile
index f43be43..2c00dcc 100644
--- a/external/gard/Makefile
+++ b/external/gard/Makefile
@@ -26,12 +26,16 @@ all: $(EXE)
 $(EXE): $(OBJS)
 	$(LINK.o) -o $@ $^
 
+check: all
+	@ln -sf ../../test/test.sh test/test.sh
+	@test/test-gard
+
 install: all
 	install -D gard $(DESTDIR)$(sbindir)/opal-gard
 	install -D -m 0644 opal-gard.1 $(DESTDIR)$(mandir)/man1/opal-gard.1
 
 clean:
-	rm -f $(OBJS) $(EXE) *.d
+	rm -f $(OBJS) $(EXE) *.d test/test.sh
 
 distclean: clean
 
diff --git a/external/gard/test/Makefile.check b/external/gard/test/Makefile.check
new file mode 100644
index 0000000..27f1aa0
--- /dev/null
+++ b/external/gard/test/Makefile.check
@@ -0,0 +1,16 @@
+# -*-Makefile-*-
+
+check: check-gard
+
+#Makefile knows to build it before checking
+check-gard:
+	@make CROSS_COMPILE='' -C external/gard/ check
+
+.PHONY: check-gard
+
+clean: gard-test-clean
+
+gard-test-clean:
+	@make -C external/gard clean
+
+.PHONY: gard-test-clean
diff --git a/external/gard/test/files/data1.bin b/external/gard/test/files/data1.bin
new file mode 100644
index 0000000000000000000000000000000000000000..aa5bf1437e3ce8c74b7ea8a2b2b1dc9cbf989892
GIT binary patch
literal 20480
zcmeIy!41MN3<c2N3PykhxG)A|un{-JPz=BntYMN`>Jq#h?8wdO%dbh6%aZkxW43ec
zHfvSAlGE*5J$sL~&d1LjdUEeJYd=1J_Qzweo%zK at 2vs&=Y=IDj&_4s4U=wTt1r$&~
z0R<FLKmi35P(T3%6i`3`1r$&~0R<FLKmi35P(T3%6i`3`1r$&~0R<FLKmi35P(T3%
q6i`3`1r$&~0R<FLKmi35P(T3%6i~1$=qOYPNI(J-kbngKA%P#wS$qxv

literal 0
HcmV?d00001

diff --git a/external/gard/test/make-check-test b/external/gard/test/make-check-test
new file mode 100755
index 0000000..6b9e5db
--- /dev/null
+++ b/external/gard/test/make-check-test
@@ -0,0 +1 @@
+make -C external/gard/ check
diff --git a/external/gard/test/results/00-list.err b/external/gard/test/results/00-list.err
new file mode 100644
index 0000000..e69de29
diff --git a/external/gard/test/results/00-list.out b/external/gard/test/results/00-list.out
new file mode 100644
index 0000000..3fd3344
--- /dev/null
+++ b/external/gard/test/results/00-list.out
@@ -0,0 +1,5 @@
+|    ID    |   Error  | Type            |
++---------------------------------------+
+| 00000001 | 90000015 | physical        |
+| 00000002 | 90000016 | physical        |
++=======================================+
diff --git a/external/gard/test/results/01-show_1.err b/external/gard/test/results/01-show_1.err
new file mode 100644
index 0000000..e69de29
diff --git a/external/gard/test/results/01-show_1.out b/external/gard/test/results/01-show_1.out
new file mode 100644
index 0000000..4e5726b
--- /dev/null
+++ b/external/gard/test/results/01-show_1.out
@@ -0,0 +1,9 @@
+Record ID:    0x00000001
+========================
+Error ID:     0x90000015
+Error Type:         0xe6
+Res Recovery:       0xff
+Path Type: physical
+>System, Instance #0
+ >Node, Instance #0
+  >Processor, Instance #0
diff --git a/external/gard/test/results/02-usage.err b/external/gard/test/results/02-usage.err
new file mode 100644
index 0000000..2aef39d
--- /dev/null
+++ b/external/gard/test/results/02-usage.err
@@ -0,0 +1,18 @@
+Usage: ./gard [-a -e -f <file> -p] <command> [<args>]
+
+-e --ecc
+	Force reading/writing with ECC bytes.
+
+-f --file <file>
+	Don't search for MTD device, read from <file>.
+
+-p --part
+	Used in conjunction with -f to specifythat just
+	the GUARD partition is in <file> and libffs
+	shouldn't be used.
+
+Where <command> is one of:
+
+	list   	List current GARD records
+	show   	Show details of a GARD record
+	clear  	Clear GARD records
diff --git a/external/gard/test/results/02-usage.out b/external/gard/test/results/02-usage.out
new file mode 100644
index 0000000..e69de29
diff --git a/external/gard/test/test-gard b/external/gard/test/test-gard
new file mode 100755
index 0000000..10da351
--- /dev/null
+++ b/external/gard/test/test-gard
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+. test/test.sh
+
+run_tests "test/tests/*" "test/results"
diff --git a/external/gard/test/test.sh b/external/gard/test/test.sh
new file mode 120000
index 0000000..386568f
--- /dev/null
+++ b/external/gard/test/test.sh
@@ -0,0 +1 @@
+../../test/test.sh
\ No newline at end of file
diff --git a/external/gard/test/tests/00-list b/external/gard/test/tests/00-list
new file mode 100644
index 0000000..8e285c4
--- /dev/null
+++ b/external/gard/test/tests/00-list
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+run_binary "./gard" "-p -e -f test/files/data1.bin list"
+if [ "$?" -ne 0 ] ; then
+	fail_test
+fi
+
+diff_with_result
+
+pass_test
diff --git a/external/gard/test/tests/01-show_1 b/external/gard/test/tests/01-show_1
new file mode 100644
index 0000000..66ee732
--- /dev/null
+++ b/external/gard/test/tests/01-show_1
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+run_binary "./gard" "-p -e -f test/files/data1.bin show 1"
+if [ "$?" -ne 0 ] ; then
+	fail_test
+fi
+
+diff_with_result
+
+pass_test
diff --git a/external/gard/test/tests/02-usage b/external/gard/test/tests/02-usage
new file mode 100644
index 0000000..768f5d0
--- /dev/null
+++ b/external/gard/test/tests/02-usage
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+run_binary "./gard"
+if [ "$?" -ne 1 ] ; then
+	fail_test
+fi
+
+diff_with_result
+
+pass_test
-- 
2.5.1



More information about the Skiboot mailing list