Comments
Patch
===================================================================
@@ -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"
@@ -96,7 +102,7 @@
#
# Actual tests are performed below.
#
-NUM_REGIONS=16
+NUM_REGIONS=1
# Make a layout - 4K regions on 4K boundaries. This will test basic
# functionality of erasing and writing specific blocks.
@@ -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"
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>