Patchwork partial write test script

login
register
about
Submitter David Hendricks
Date 2010-10-29 20:51:54
Message ID <AANLkTin1ep0fPBT9ObLSYfstLFsyCryoWkhRM_mvGDpP@mail.gmail.com>
Download mbox | patch
Permalink /patch/2211/
State Accepted
Commit r1219
Headers show

Comments

David Hendricks - 2010-10-29 20:51:54
On Fri, Oct 29, 2010 at 1:19 PM, Carl-Daniel Hailfinger <
c-d.hailfinger.devel.2006@gmx.net> wrote:

> On 29.10.2010 21:53, David Hendricks wrote:
> > Before you commit, add the last range to the unaligned layout and maybe
> add
> > a note to the comments above. Maybe something like:
> > [...]
> >
>
> Done. Thanks for the torture test script.
>
> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
> and committed in r1218.
>

Naturally, I already hit a snag.

When running the script, it seems that the added "$FLASHROM_PARAM" can get
expanded incorrectly by the shell thus causing flashrom to barf when
$FLASHROM_PARAM is empty. I suspect it quietly passes in "".

The attached patch is a simple s/\"$FLASHROM_PARAM\"/${FLASHROM_PARAM}/g.
This seems to work.

My shell-fu is only moderate, perhaps someone with more expertise can verify
that this is the -correct- way to do it.
Carl-Daniel Hailfinger - 2010-10-29 21:27:04
On 29.10.2010 22:51, David Hendricks wrote:
> When running the script, it seems that the added "$FLASHROM_PARAM" can get
> expanded incorrectly by the shell thus causing flashrom to barf when
> $FLASHROM_PARAM is empty. I suspect it quietly passes in "".
>
> The attached patch is a simple s/\"$FLASHROM_PARAM\"/${FLASHROM_PARAM}/g.
> This seems to work.
>
> My shell-fu is only moderate, perhaps someone with more expertise can verify
> that this is the -correct- way to do it.
>   

If you reply to this with a Signed-off-by line, this is
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>

Regards,
Carl-Daniel
David Hendricks - 2010-10-29 21:29:28
On Fri, Oct 29, 2010 at 2:27 PM, Carl-Daniel Hailfinger <
c-d.hailfinger.devel.2006@gmx.net> wrote:

> On 29.10.2010 22:51, David Hendricks wrote:
> > When running the script, it seems that the added "$FLASHROM_PARAM" can
> get
> > expanded incorrectly by the shell thus causing flashrom to barf when
> > $FLASHROM_PARAM is empty. I suspect it quietly passes in "".
> >
> > The attached patch is a simple s/\"$FLASHROM_PARAM\"/${FLASHROM_PARAM}/g.
> > This seems to work.
> >
> > My shell-fu is only moderate, perhaps someone with more expertise can
> verify
> > that this is the -correct- way to do it.
> >
>
> If you reply to this with a Signed-off-by line, this is
> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
>

D'oh! Thanks again for catching my silly mistakes.
The fix-parameter-passing-shell-stupidity.patch is:
Signed-off-by: David Hendricks <dhendrix@google.com>


>
> Regards,
> Carl-Daniel
>
> --
> http://www.hailfinger.org/
>
>
Carl-Daniel Hailfinger - 2010-10-29 21:55:16
On 29.10.2010 23:29, David Hendricks wrote:
> On Fri, Oct 29, 2010 at 2:27 PM, Carl-Daniel Hailfinger wrote:
>   
>> On 29.10.2010 22:51, David Hendricks wrote:
>>     
>>> When running the script, it seems that the added "$FLASHROM_PARAM" can
>>> get expanded incorrectly by the shell thus causing flashrom to barf
>>> when $FLASHROM_PARAM is empty. I suspect it quietly passes in "".
>>>
>>> The attached patch is a simple s/\"$FLASHROM_PARAM\"/${FLASHROM_PARAM}/g.
>>> This seems to work.
>>>
>>>       
>> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
>>     
>
> Signed-off-by: David Hendricks <dhendrix@google.com>
>   

Committed in r1219.

Regards,
Carl-Daniel

Patch

Index: util/flashrom_partial_write_test.sh
===================================================================
--- util/flashrom_partial_write_test.sh	(revision 1218)
+++ util/flashrom_partial_write_test.sh	(working copy)
@@ -81,13 +81,13 @@ 
 
 echo "Reading BIOS image"
 BIOS="bios.bin"
-flashrom "$FLASHROM_PARAM" -r "$BIOS" > /dev/null
+flashrom ${FLASHROM_PARAM} -r "$BIOS" > /dev/null
 echo "Original image saved as ${BIOS}"
 
 # $1: exit code
 do_exit() {
 	echo "restoring original bios image using system's flashrom"
-	flashrom "$FLASHROM_PARAM" -w "$BIOS"
+	flashrom ${FLASHROM_PARAM} -w "$BIOS"
 	echo "test files remain in ${TMPDIR}"
 	cd "$OLDDIR"
 	exit "$1"
@@ -157,7 +157,7 @@ 
 	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
+	./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"
@@ -166,7 +166,7 @@ 
 
 	# download the entire ROM image and use diff to compare to ensure
 	# flashrom logic does not violate user-specified regions
-	flashrom "$FLASHROM_PARAM" -r difftest.bin > /dev/null
+	flashrom ${FLASHROM_PARAM} -r difftest.bin > /dev/null
 	diff -q difftest.bin "$TESTFILE"
 	if [ "$?" != "0" ] ; then
 		echo "diff test failed on iteration ${i}"
@@ -239,7 +239,7 @@ 
 " > layout_unaligned.txt
 
 # reset the test file and ROM to the original state
-flashrom "$FLASHROM_PARAM" -w "$BIOS"
+flashrom ${FLASHROM_PARAM} -w "$BIOS"
 cp "$BIOS" "$TESTFILE"
 
 i=0
@@ -256,7 +256,7 @@ 
 	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)) count=writelen 2> /dev/null
 
-	./flashrom "$FLASHROM_PARAM" -l layout_unaligned.txt -i 00_${i} -i ff_${i} -w "$TESTFILE" > /dev/null
+	./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"
@@ -265,7 +265,7 @@ 
 
 	# download the entire ROM image and use diff to compare to ensure
 	# flashrom logic does not violate user-specified regions
-	flashrom "$FLASHROM_PARAM" -r difftest.bin > /dev/null
+	flashrom ${FLASHROM_PARAM} -r difftest.bin > /dev/null
 	diff -q difftest.bin "$TESTFILE"
 	if [ "$?" != "0" ] ; then
 		echo "diff test failed on iteration ${i}"