Patchwork print test status in partial write test script

login
register
about
Submitter David Hendricks
Date 2010-11-02 01:20:42
Message ID <AANLkTimvgzAT63Ckiaa2=PB8c4R5_UNF3T+Uddv5thH9@mail.gmail.com>
Download mbox | patch
Permalink /patch/2226/
State Accepted
Commit r1222
Headers show

Comments

David Hendricks - 2010-11-02 01:20:42
New version -- fixes the number of regions tested (i had reduced them to get
a patch prepped in a hurry. d'oh!)

On Mon, Nov 1, 2010 at 6:10 PM, David Hendricks <dhendrix@google.com> wrote:

> We were a bit too aggressive in trimming superfluous print messages earlier
> on. This patch adds a line of output for each iteration of the while loops
> in the test. The intention is to give the user something useful to indicate
> test progress without just printing a ton of debug spew. Maybe a future
> patch can redirect more verbose info to a log file.
>
> The output looks like this::
> localhost ~ # FLASHROM="./flashrom" sh flashrom_partial_write_test.sh
> testing flashrom binary: ./flashrom
> Running test in /tmp/tmp.4xPejwaADU
> ffh pattern written in ff_4k.bin
> 00h pattern written in 00_4k.bin
> Reading BIOS image
> Original image saved as bios.bin
> aligned region 0 test: passed
> ...
> aligned region 15 test: passed
> unaligned region 0 test: passed
> ...
> unaligned region 15 test: passed
> Result: PASSED
> restoring original bios image using system's flashrom
> test files remain in /tmp/tmp.4xPejwaADU
>
> Signed-off-by: David Hendricks <dhendrix@google.com>
>
> --
> David Hendricks (dhendrix)
> Systems Software Engineer, Google Inc.
>
Carl-Daniel Hailfinger - 2010-11-02 03:04:21
On 02.11.2010 02:20, David Hendricks wrote:
> New version -- fixes the number of regions tested (i had reduced them to get
> a patch prepped in a hurry. d'oh!)
>
> On Mon, Nov 1, 2010 at 6:10 PM, David Hendricks <dhendrix@google.com> wrote:
>
>   
>> We were a bit too aggressive in trimming superfluous print messages earlier
>> on. This patch adds a line of output for each iteration of the while loops
>> in the test. The intention is to give the user something useful to indicate
>> test progress without just printing a ton of debug spew. Maybe a future
>> patch can redirect more verbose info to a log file.
>>
>> The output looks like this::
>> localhost ~ # FLASHROM="./flashrom" sh flashrom_partial_write_test.sh
>> testing flashrom binary: ./flashrom
>> Running test in /tmp/tmp.4xPejwaADU
>> ffh pattern written in ff_4k.bin
>> 00h pattern written in 00_4k.bin
>> Reading BIOS image
>> Original image saved as bios.bin
>> aligned region 0 test: passed
>> ...
>> aligned region 15 test: passed
>> unaligned region 0 test: passed
>> ...
>> unaligned region 15 test: passed
>> Result: PASSED
>> restoring original bios image using system's flashrom
>> test files remain in /tmp/tmp.4xPejwaADU
>>
>> Signed-off-by: David Hendricks <dhendrix@google.com>
>>     

Looks good and improves the output.
I removed the /dev/null redirect of the final flashrom run since we
really want to know if the fail flashrom run had any issues.

Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
and committed in r1222.

Regards,
Carl-Daniel
David Hendricks - 2010-11-02 03:07:07
On Mon, Nov 1, 2010 at 8:04 PM, Carl-Daniel Hailfinger <
c-d.hailfinger.devel.2006@gmx.net> wrote:

> On 02.11.2010 02:20, David Hendricks wrote:
> > New version -- fixes the number of regions tested (i had reduced them to
> get
> > a patch prepped in a hurry. d'oh!)
> >
> > On Mon, Nov 1, 2010 at 6:10 PM, David Hendricks <dhendrix@google.com>
> wrote:
> >
> >
> >> We were a bit too aggressive in trimming superfluous print messages
> earlier
> >> on. This patch adds a line of output for each iteration of the while
> loops
> >> in the test. The intention is to give the user something useful to
> indicate
> >> test progress without just printing a ton of debug spew. Maybe a future
> >> patch can redirect more verbose info to a log file.
> >>
> >> The output looks like this::
> >> localhost ~ # FLASHROM="./flashrom" sh flashrom_partial_write_test.sh
> >> testing flashrom binary: ./flashrom
> >> Running test in /tmp/tmp.4xPejwaADU
> >> ffh pattern written in ff_4k.bin
> >> 00h pattern written in 00_4k.bin
> >> Reading BIOS image
> >> Original image saved as bios.bin
> >> aligned region 0 test: passed
> >> ...
> >> aligned region 15 test: passed
> >> unaligned region 0 test: passed
> >> ...
> >> unaligned region 15 test: passed
> >> Result: PASSED
> >> restoring original bios image using system's flashrom
> >> test files remain in /tmp/tmp.4xPejwaADU
> >>
> >> Signed-off-by: David Hendricks <dhendrix@google.com>
> >>
>
> Looks good and improves the output.
> I removed the /dev/null redirect of the final flashrom run since we
> really want to know if the fail flashrom run had any issues.
>

Sounds good. Thanks!


>
> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
> and committed in r1222.
>
> Regards,
> Carl-Daniel
>
> --
> http://www.hailfinger.org/
>
>

Patch

Index: util/flashrom_partial_write_test.sh
===================================================================
--- util/flashrom_partial_write_test.sh	(revision 1220)
+++ util/flashrom_partial_write_test.sh	(working copy)
@@ -86,8 +86,14 @@ 
 
 # $1: exit code
 do_exit() {
+	if [ ${1} -eq ${EXIT_FAILURE} ] ; then
+		echo "Result: FAILED"
+	else
+		echo "Result: PASSED"
+	fi
+
 	echo "restoring original bios image using system's flashrom"
-	flashrom ${FLASHROM_PARAM} -w "$BIOS"
+	flashrom ${FLASHROM_PARAM} -w "$BIOS" > /dev/null
 	echo "test files remain in ${TMPDIR}"
 	cd "$OLDDIR"
 	exit "$1"
@@ -153,14 +159,14 @@ 
 cp "$BIOS" "$TESTFILE"
 i=0
 while [ $i -lt $NUM_REGIONS ] ; do
+	echo -n "aligned region ${i} test: "
 	offset=$((${i} * 8192))
 	dd if=${ZERO_4K} of=${TESTFILE} bs=1 conv=notrunc seek=${offset} 2> /dev/null
 	dd if=${FF_4K} of=${TESTFILE} bs=1 conv=notrunc seek=$((${offset} + 4096)) 2> /dev/null
 
 	./flashrom ${FLASHROM_PARAM} -l layout_4k_aligned.txt -i 00_${i} -i ff_${i} -w "$TESTFILE" > /dev/null
 	if [ "$?" != "0" ] ; then
-		echo "partial flash failed on iteration ${i}"
-		echo "Result: FAIL"
+		echo "failed to flash region"
 		do_exit "$EXIT_FAILURE"
 	fi
 
@@ -169,13 +175,13 @@ 
 	flashrom ${FLASHROM_PARAM} -r difftest.bin > /dev/null
 	diff -q difftest.bin "$TESTFILE"
 	if [ "$?" != "0" ] ; then
-		echo "diff test failed on iteration ${i}"
-		echo "Result: FAIL"
+		echo "failed diff test"
 		do_exit "$EXIT_FAILURE"
 	fi
 	rm -f difftest.bin
 
 	i=$((${i} + 1))
+	echo "passed"
 done
 
 # Make a layout - 4K regions on 4.5K boundaries. This will help find problems
@@ -239,11 +245,13 @@ 
 " > layout_unaligned.txt
 
 # reset the test file and ROM to the original state
-flashrom ${FLASHROM_PARAM} -w "$BIOS"
+flashrom ${FLASHROM_PARAM} -w "$BIOS" > /dev/null
 cp "$BIOS" "$TESTFILE"
 
 i=0
 while [ $i -lt $NUM_REGIONS ] ; do
+	echo -n "unaligned region ${i} test: "
+
 	offset=$(($((${i} * 8192)) + 2048))
 	# Protect against too long write
 	writelen=4096
@@ -258,8 +266,7 @@ 
 
 	./flashrom ${FLASHROM_PARAM} -l layout_unaligned.txt -i 00_${i} -i ff_${i} -w "$TESTFILE" > /dev/null
 	if [ "$?" != "0" ] ; then
-		echo "partial flash failed on iteration ${i}"
-		echo "Result: FAIL"
+		echo "failed to flash region"
 		do_exit "$EXIT_FAILURE"
 	fi
 
@@ -268,14 +275,13 @@ 
 	flashrom ${FLASHROM_PARAM} -r difftest.bin > /dev/null
 	diff -q difftest.bin "$TESTFILE"
 	if [ "$?" != "0" ] ; then
-		echo "diff test failed on iteration ${i}"
-		echo "Result: FAIL"
+		echo "failed diff test"
 		do_exit "$EXIT_FAILURE"
 	fi
 	rm -f difftest.bin
 
 	i=$((${i} + 1))
+	echo "passed"
 done
 
-echo "Result: PASS"
 do_exit "$EXIT_SUCCESS"