diff mbox

[v2,19/19] external/pflash: tests: Move the test-miscprint to pflash tests

Message ID 20170728064637.11081-20-cyril.bur@au1.ibm.com
State Accepted
Headers show

Commit Message

Cyril Bur July 28, 2017, 6:46 a.m. UTC
New code that is very much pflash functionality was added in commit
f2c87a3d2f6 "pflash option to retrieve PNOR partition flags".
Unfortunately at the time there wasn't an easy way to test pflash.

The previous patch adds pflash infrastructure and plumbs it into
`make check` nicely. This commit converts the tests originally added to
libflash tests.

Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 external/pflash/test/files/06-miscprint.ffs   |   4 +++
 external/pflash/test/results/06-miscprint.err |   0
 external/pflash/test/results/06-miscprint.out |  36 +++++++++++++++++++++++++
 external/pflash/test/tests/06-miscprint       |  37 ++++++++++++++++++++++++++
 libflash/test/Makefile.check                  |   7 ++---
 libflash/test/test-miscprint.pnor             | Bin 3072 -> 0 bytes
 libflash/test/test-miscprint.sh               |  27 -------------------
 7 files changed, 79 insertions(+), 32 deletions(-)
 create mode 100644 external/pflash/test/files/06-miscprint.ffs
 create mode 100644 external/pflash/test/results/06-miscprint.err
 create mode 100644 external/pflash/test/results/06-miscprint.out
 create mode 100644 external/pflash/test/tests/06-miscprint
 delete mode 100644 libflash/test/test-miscprint.pnor
 delete mode 100755 libflash/test/test-miscprint.sh
diff mbox

Patch

diff --git a/external/pflash/test/files/06-miscprint.ffs b/external/pflash/test/files/06-miscprint.ffs
new file mode 100644
index 00000000..8f916f39
--- /dev/null
+++ b/external/pflash/test/files/06-miscprint.ffs
@@ -0,0 +1,4 @@ 
+PRESERVED,0x00300,0x100,P,/dev/zero
+READONLY,0x000400,0x100,R,/dev/zero
+REPROVISION,0x500,0x100,F,/dev/zero
+BACKUP,0x00000600,0x100,B,/dev/zero
diff --git a/external/pflash/test/results/06-miscprint.err b/external/pflash/test/results/06-miscprint.err
new file mode 100644
index 00000000..e69de29b
diff --git a/external/pflash/test/results/06-miscprint.out b/external/pflash/test/results/06-miscprint.out
new file mode 100644
index 00000000..e90976d6
--- /dev/null
+++ b/external/pflash/test/results/06-miscprint.out
@@ -0,0 +1,36 @@ 
+Detailed partition information
+Name:
+PRESERVED (ID=01)
+
+Start       End         Actual    
+0x00000300  0x00000400  0x00000100
+
+Flags:
+PRESERVED [P]
+Detailed partition information
+Name:
+READONLY (ID=02)
+
+Start       End         Actual    
+0x00000400  0x00000500  0x00000100
+
+Flags:
+READONLY [R]
+Detailed partition information
+Name:
+REPROVISION (ID=03)
+
+Start       End         Actual    
+0x00000500  0x00000600  0x00000100
+
+Flags:
+REPROVISION [F]
+Detailed partition information
+Name:
+BACKUP (ID=04)
+
+Start       End         Actual    
+0x00000600  0x00000700  0x00000100
+
+Flags:
+BACKUP [B]
diff --git a/external/pflash/test/tests/06-miscprint b/external/pflash/test/tests/06-miscprint
new file mode 100644
index 00000000..e4957a94
--- /dev/null
+++ b/external/pflash/test/tests/06-miscprint
@@ -0,0 +1,37 @@ 
+#! /bin/sh
+
+touch "$DATA_DIR/$CUR_TEST.pnor"
+
+# Don't record the output of ffspart
+../ffspart/ffspart -s 0x100 -c 10 -i "$DATA_DIR/$CUR_TEST.ffs" \
+	-p "$DATA_DIR/$CUR_TEST.pnor" 2>&1 >/dev/null
+if [ "$?" -ne 0 ] ; then
+	fail_test
+fi
+
+run_binary "./pflash" "--detail=1 -F $DATA_DIR/$CUR_TEST.pnor"
+if [ "$?" -ne 0 ] ; then
+	fail_test;
+fi
+run_binary "./pflash" "--detail=2 -F $DATA_DIR/$CUR_TEST.pnor"
+if [ "$?" -ne 0 ] ; then
+	fail_test;
+fi
+run_binary "./pflash" "--detail=3 -F $DATA_DIR/$CUR_TEST.pnor"
+if [ "$?" -ne 0 ] ; then
+	fail_test;
+fi
+run_binary "./pflash" "--detail=4 -F $DATA_DIR/$CUR_TEST.pnor"
+if [ "$?" -ne 0 ] ; then
+	fail_test;
+fi
+
+# The test infrastructure will clean up but lets no chew unnecessarily
+# though disk space
+rm "$DATA_DIR/$CUR_TEST.pnor"
+
+strip_version_from_result "pflash"
+
+diff_with_result
+
+pass_test
diff --git a/libflash/test/Makefile.check b/libflash/test/Makefile.check
index 344cad0a..1f92b9d2 100644
--- a/libflash/test/Makefile.check
+++ b/libflash/test/Makefile.check
@@ -4,8 +4,8 @@  LIBFLASH_TEST := libflash/test/test-flash libflash/test/test-ecc libflash/test/t
 LCOV_EXCLUDE += $(LIBFLASH_TEST:%=%.c)
 
 .PHONY : libflash-check libc-coverage
-libflash-check: $(LIBFLASH_TEST:%=%-check) libflash/test/test-miscprint $(CORE_TEST:%=%-gcov-run)
-libflash-coverage: $(LIBFLASH_TEST:%=%-gcov-run) libflash/test/test-miscprint
+libflash-check: $(LIBFLASH_TEST:%=%-check) $(CORE_TEST:%=%-gcov-run)
+libflash-coverage: $(LIBFLASH_TEST:%=%-gcov-run)
 
 check: libflash-check libc-coverage
 coverage: libflash-coverage
@@ -16,9 +16,6 @@  $(LIBFLASH_TEST:%=%-gcov-run) : %-run: %
 $(LIBFLASH_TEST:%=%-check) : %-check: %
 	$(call QTEST, RUN-TEST ,$(VALGRIND) $<, $<)
 
-libflash/test/test-miscprint: pflash
-	$(call Q, RUN-TEST , ./libflash/test/test-miscprint.sh,  $@)
-
 libflash/test/stubs.o: libflash/test/stubs.c
 	$(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) -g -c -o $@ $<, $<)
 
diff --git a/libflash/test/test-miscprint.pnor b/libflash/test/test-miscprint.pnor
deleted file mode 100644
index 8a84ebaf079cb0af235ecd8568c3c990456d7764..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 3072
zcmWG=3<_ajU|@ve1|ZGKz`zWo7+63AG6--CyjqZ0RDvu9Wi$Q<0w5b?4oEYQ2Actu
zrViCVudg#8$TiqCD9qIbVI;^-2B`f^Kqi<Erx5BOtOj%e;`!_9-@XoVb#(Ff^NB>#
zg=|06?;u&IGmsR5nGWaz#Pc6*`TQ`*H6X}8%rn^2-w&n{*?v%*;rG7)OdIL+>dh;E
zIXOCehX$bN1%){*{DEnQfc**})#QN}=k{&_#q%f_4S~@R7!85Z5Eu=C(GVC7fzc2k
GKLh~mR(fav

diff --git a/libflash/test/test-miscprint.sh b/libflash/test/test-miscprint.sh
deleted file mode 100755
index b84a6cf4..00000000
--- a/libflash/test/test-miscprint.sh
+++ /dev/null
@@ -1,27 +0,0 @@ 
-#!/bin/bash
-
-# test-miscprint.pnor is constructed as follows:
-# PRESERVED,0x00000300,0x00000100,P,/dev/zero
-# READONLY,0x00000400,0x00000100,R,/dev/zero
-# REPROVISION,0x00000500,0x00000100,F,/dev/zero
-# BACKUP,0x00000600,0x00000100,B,/dev/zero
-
-wd="libflash/test"
-pflash="./external/pflash/pflash"
-
-pnor="$wd/test-miscprint.pnor"
-
-output1=$(${pflash} --detail=1 -F "$pnor" | grep "\[P\]")
-output2=$(${pflash} --detail=2 -F "$pnor" | grep "\[R\]")
-output3=$(${pflash} --detail=3 -F "$pnor" | grep "\[F\]")
-output4=$(${pflash} --detail=4 -F "$pnor" | grep "\[B\]")
-
-if [[ $output1 == "PRESERVED [P]" && $output2 == "READONLY [R]" &&
-      $output3 == "REPROVISION [F]" && $output4 == "BACKUP [B]" ]]; then
-    echo "Test passed!"
-    exit 0;
-else
-    echo "Test failed!"
-    exit 1; 
-fi
-