diff options
Diffstat (limited to 'roms/skiboot/external/pflash/test/tests')
-rw-r--r-- | roms/skiboot/external/pflash/test/tests/00-usage | 13 | ||||
-rw-r--r-- | roms/skiboot/external/pflash/test/tests/01-info | 23 | ||||
-rw-r--r-- | roms/skiboot/external/pflash/test/tests/02-erase | 27 | ||||
-rw-r--r-- | roms/skiboot/external/pflash/test/tests/03-erase-parts | 56 | ||||
-rw-r--r-- | roms/skiboot/external/pflash/test/tests/04-program-rand | 55 | ||||
-rw-r--r-- | roms/skiboot/external/pflash/test/tests/05-bad-numbers | 66 | ||||
-rw-r--r-- | roms/skiboot/external/pflash/test/tests/06-miscprint | 46 |
7 files changed, 286 insertions, 0 deletions
diff --git a/roms/skiboot/external/pflash/test/tests/00-usage b/roms/skiboot/external/pflash/test/tests/00-usage new file mode 100644 index 000000000..4c4ba2aa5 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/00-usage @@ -0,0 +1,13 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +run_binary "./pflash" "-h" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +strip_version_from_result "pflash" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/01-info b/roms/skiboot/external/pflash/test/tests/01-info new file mode 100644 index 000000000..583d275c4 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/01-info @@ -0,0 +1,23 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +touch "$DATA_DIR/$CUR_TEST.pnor" + +# Don't record the output of ffspart +../ffspart/ffspart -s 0x1000 -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" "-F $DATA_DIR/$CUR_TEST.pnor --info" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +#--info will print the name of the file which will change between runs +sed -i "s|$DATA_DIR/$CUR_TEST.pnor|FILE|" "$STDOUT_OUT" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/02-erase b/roms/skiboot/external/pflash/test/tests/02-erase new file mode 100644 index 000000000..f1db99266 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/02-erase @@ -0,0 +1,27 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +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 + +yes yes | run_binary "./pflash" "-F $DATA_DIR/$CUR_TEST.pnor -E" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp_with_ff "$DATA_DIR/$CUR_TEST.pnor" 0 \ + "$(stat --printf="%s" "$DATA_DIR/$CUR_TEST.pnor")" + +# The test infrastructure will clean up but lets not chew unnecessarily +# though disk space +rm "$DATA_DIR/$CUR_TEST.pnor" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/03-erase-parts b/roms/skiboot/external/pflash/test/tests/03-erase-parts new file mode 100644 index 000000000..91b0a145e --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/03-erase-parts @@ -0,0 +1,56 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +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 + +cp "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +#Let us all take a second to appreciate the fragility of this. +#The reason we need is that pflash -e will set the actual size of the +#partition to zero, which we'll do here. Examination determined that +#it will be at byte 216 in the file +dd if=/dev/zero of="$DATA_DIR/$CUR_TEST.bk" \ + bs=1 seek=216 count=4 conv=notrunc status=none + +#176 Should be where the FFS header for partition ONE starts +update_checksum "$DATA_DIR/$CUR_TEST.bk" "176"; + +yes yes | run_binary "./pflash" "-F $DATA_DIR/$CUR_TEST.pnor -e -P ONE" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +one_start=$(get_part_start "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_len=$(get_part_len "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_end=$(get_part_end "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +cmp_with_ff "$DATA_DIR/$CUR_TEST.pnor" "$one_start" "$one_len" + +cmp --bytes="$one_start" "$DATA_DIR/$CUR_TEST.pnor" \ + "$DATA_DIR/$CUR_TEST.bk"; +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_end" \ + --bytes="$(expr $(stat --printf="%s" "$DATA_DIR/$CUR_TEST.pnor") - "$one_end")" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +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" "$DATA_DIR/$CUR_TEST.bk" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/04-program-rand b/roms/skiboot/external/pflash/test/tests/04-program-rand new file mode 100644 index 000000000..fc8abb648 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/04-program-rand @@ -0,0 +1,55 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +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 + +cp "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +one_len=$(get_part_len "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_start=$(get_part_start "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_end=$(get_part_end "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +dd if=/dev/urandom bs="$one_len" count=1 of="$DATA_DIR/random" status=none + +yes yes | run_binary "./pflash" \ + "-F $DATA_DIR/$CUR_TEST.pnor -e -P ONE -p $DATA_DIR/random" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_start:0" --bytes="$one_len" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/random" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --bytes="$one_start" "$DATA_DIR/$CUR_TEST.pnor" \ + "$DATA_DIR/$CUR_TEST.bk"; +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_end" \ + --bytes="$(expr $(stat --printf="%s" "$DATA_DIR/$CUR_TEST.pnor") - "$one_end")" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +sed -i "s|$DATA_DIR/random|FILE|" "$STDOUT_OUT" + +# The test infrastructure will clean up but lets no chew unnecessarily +# though disk space +rm "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" "$DATA_DIR/random" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/05-bad-numbers b/roms/skiboot/external/pflash/test/tests/05-bad-numbers new file mode 100644 index 000000000..03cc39ebf --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/05-bad-numbers @@ -0,0 +1,66 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +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 + +cp "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +one_len=$(get_part_len "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_start=$(get_part_start "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_end=$(get_part_end "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +dd if=/dev/urandom bs="$one_len" count=1 of="$DATA_DIR/random" status=none + +#This should error out +run_binary "./pflash" \ + "-F $DATA_DIR/$CUR_TEST.pnor -e -a NOT_A_NUMBER -s ALSO_NOT_A_NUMBER" +if [ "$?" -eq 0 ] ; then + fail_test; +fi + +one_start_decimal=$(printf "%d" $one_start); +one_len_decimal=$(printf "%d" $one_len); +yes yes | run_binary "./pflash" \ + "-F $DATA_DIR/$CUR_TEST.pnor -e -a $one_start_decimal \ + -s $one_len_decimal -p $DATA_DIR/random" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_start:0" --bytes="$one_len" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/random" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --bytes="$one_start" "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk"; +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_end" \ + --bytes="$(expr $(stat --printf="%s" "$DATA_DIR/$CUR_TEST.pnor") - "$one_end")" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +sed -i "s|$DATA_DIR/random|FILE|" "$STDOUT_OUT" + +# The test infrastructure will clean up but lets no chew unnecessarily +# though disk space +rm "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" "$DATA_DIR/random" + +strip_version_from_result "pflash" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/06-miscprint b/roms/skiboot/external/pflash/test/tests/06-miscprint new file mode 100644 index 000000000..bee84afc5 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/06-miscprint @@ -0,0 +1,46 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +touch "$DATA_DIR/$CUR_TEST.pnor" + +# Don't record the output of ffspart +../ffspart/ffspart -s 0x1000 -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 +run_binary "./pflash" "--detail=5 -F $DATA_DIR/$CUR_TEST.pnor" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +run_binary "./pflash" "--detail=6 -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 |