Skip to content

Commit

Permalink
external/ffspart: Add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
cyrilbur-ibm authored and stewartsmith committed Mar 24, 2017
1 parent e53cf9e commit 5f7e491
Show file tree
Hide file tree
Showing 66 changed files with 440 additions and 0 deletions.
6 changes: 6 additions & 0 deletions external/ffspart/Makefile
Expand Up @@ -5,6 +5,12 @@ include ../../external/common/rules.mk

all: links arch_links $(EXE)

#Rebuild version.o so that the the version always matches
#what the test suite will get from ./make_version.sh
check: version.o all
@ln -sf ../../test/test.sh test/test.sh
@test/test-ffspart

$(OBJS): | links arch_links

.PHONY: VERSION-always
Expand Down
20 changes: 20 additions & 0 deletions external/ffspart/test/Makefile.check
@@ -0,0 +1,20 @@
# -*-Makefile-*-

check: check-ffspart

#Makefile knows to build it before checking, should also
#make clean before checking. If not, .o files for different
#architectures might be lying around and clean once done to
#avoid the opposite
check-ffspart: ffspart-test-clean
@make CROSS_COMPILE='' -C external/ffspart/ check
@make CROSS_COMPILE='' -C external/ffspart/ clean

.PHONY: check-ffspart

clean: ffspart-test-clean

ffspart-test-clean:
@make -C external/ffspart clean

.PHONY: ffspart-test-clean
4 changes: 4 additions & 0 deletions external/ffspart/test/files/03-tiny-pnor.in
@@ -0,0 +1,4 @@
ONE,0x00000300,0x00000100,EV,/dev/zero
TWO,0x00000400,0x00000100,EF,/dev/zero
THREE,0x00000500,0x00000100,EF,/dev/zero
FOUR,0x00000600,0x00000100,EF,/dev/zero
Binary file added external/ffspart/test/files/03-tiny-pnor.out
Binary file not shown.
4 changes: 4 additions & 0 deletions external/ffspart/test/files/03.1-tiny-pnor-backup.in
@@ -0,0 +1,4 @@
ONE,0x00000300,0x00000100,EV,/dev/zero
TWO,0x00000400,0x00000100,EF,/dev/zero
THREE,0x00000500,0x00000100,EF,/dev/zero
FOUR,0x00000600,0x00000100,EF,/dev/zero
Binary file not shown.
4 changes: 4 additions & 0 deletions external/ffspart/test/files/04-tiny-pnor2.in
@@ -0,0 +1,4 @@
ONE,0x00000300,0x00000100,EV,SEDCATCH_1
TWO,0x00000400,0x00000100,EF,SEDCATCH_2
THREE,0x00000500,0x00000100,EF,SEDCATCH_3
FOUR,0x00000600,0x00000100,EF,SEDCATCH_4
Binary file added external/ffspart/test/files/04-tiny-pnor2.out
Binary file not shown.
4 changes: 4 additions & 0 deletions external/ffspart/test/files/05-hdr-overlap.in
@@ -0,0 +1,4 @@
ONE,0x00000200,0x00000100,EV,/dev/zero
TWO,0x00000300,0x00000100,EF,/dev/zero
THREE,0x00000400,0x00000100,EF,/dev/zero
FOUR,0x00000500,0x00000100,EF,/dev/zero
3 changes: 3 additions & 0 deletions external/ffspart/test/files/05.1-hdr-overlap-backup.in
@@ -0,0 +1,3 @@
ONE,0x00000200,0x00000100,EV,/dev/zero
TWO,0x00000300,0x00000100,EF,/dev/zero
THREE,0x00000400,0x00000100,EF,/dev/zero
5 changes: 5 additions & 0 deletions external/ffspart/test/files/06-small-flash.in
@@ -0,0 +1,5 @@
ONE,0x00000300,0x00000100,EV,/dev/zero
TWO,0x00000400,0x00000100,EF,/dev/zero
THREE,0x00000500,0x00000100,EF,/dev/zero
FOUR,0x00000600,0x00000100,EF,/dev/zero
FIVE,0x00000700,0x00000100,EF,/dev/zero
4 changes: 4 additions & 0 deletions external/ffspart/test/files/07-big-files.in
@@ -0,0 +1,4 @@
ONE,0x00000300,0x00000100,EV,SEDCATCH_1
TWO,0x00000400,0x00000100,EF,SEDCATCH_2
THREE,0x00000500,0x00000100,EF,SEDCATCH_3
FOUR,0x00000600,0x00000100,EF,SEDCATCH_4
4 changes: 4 additions & 0 deletions external/ffspart/test/files/08-small-files.in
@@ -0,0 +1,4 @@
ONE,0x00000300,0x00000100,EV,SEDCATCH_1
TWO,0x00000400,0x00000100,EF,SEDCATCH_2
THREE,0x00000500,0x00000100,EF,SEDCATCH_3
FOUR,0x00000600,0x00000100,EF,SEDCATCH_4
4 changes: 4 additions & 0 deletions external/ffspart/test/files/10-bad-input.in
@@ -0,0 +1,4 @@
ONE0x00000300,0x00000100,EV,/dev/zero
TWO,0x00000400,0x00000100,EF,/dev/zero
THREE,0x00000500,0x00000100,EF,/dev/zero
FOUR,0x00000600,0x00000100,EF,/dev/zero
4 changes: 4 additions & 0 deletions external/ffspart/test/files/11-long-name.in
@@ -0,0 +1,4 @@
This_is_more_than_15_characters,0x00000300,0x00000100,EV,/dev/zero
This_is_exactly,0x00000400,0x00000100,EF,/dev/zero
This_is_one_le,0x00000500,0x00000100,EF,/dev/zero
This_is_one_more,0x00000600,0x00000100,EF,/dev/zero
4 changes: 4 additions & 0 deletions external/ffspart/test/files/12-bad-numbers-base.in
@@ -0,0 +1,4 @@
ONE,0xg0000300,0x00000100,EV,/dev/zero
TWO,0x00000400,0x00000100,EF,/dev/zero
THREE,0x00000500,0x00000100,EF,/dev/zero
FOUR,0x00000600,0x00000100,EF,/dev/zero
4 changes: 4 additions & 0 deletions external/ffspart/test/files/13-bad-numbers-size.in
@@ -0,0 +1,4 @@
ONE,0x00000300,0x00001g00,EV,/dev/zero
TWO,0x00000400,0x00000100,EF,/dev/zero
THREE,0x00000500,0x00000100,EF,/dev/zero
FOUR,0x00000600,0x00000100,EF,/dev/zero
4 changes: 4 additions & 0 deletions external/ffspart/test/files/14-bad-input-flags.in
@@ -0,0 +1,4 @@
ONE,0x00000300,0x00000100,EVZ,/dev/zero
TWO,0x00000400,0x00000100,EF,/dev/zero
THREE,0x00000500,0x00000100,EF,/dev/zero
FOUR,0x00000600,0x00000100,EF,/dev/zero
4 changes: 4 additions & 0 deletions external/ffspart/test/files/15-overlapping-partitions.in
@@ -0,0 +1,4 @@
ONE,0x00000300,0x00000100,EV,/dev/zero
TWO,0x00000350,0x00000100,EF,/dev/zero
THREE,0x00000500,0x00000100,EF,/dev/zero
FOUR,0x00000600,0x00000100,EF,/dev/zero
1 change: 1 addition & 0 deletions external/ffspart/test/make-check-test
@@ -0,0 +1 @@
make -C external/ffspart/ check
Empty file.
21 changes: 21 additions & 0 deletions external/ffspart/test/results/00-usage.out
@@ -0,0 +1,21 @@
Open-Power FFS format tool VERSION
Usage: ./ffspart [options] -s size -c num -i layout_file -p pnor_file ...

Options:
-s, --block_size=size
Size (in hex with leading 0x) of the blocks on the flash in bytes

-c, --block_count=num
Number of blocks on the flash

-i, --input=file
File containing the required partition data

-o, --order=( ADB | ABD )
Ordering of the TOC, Data and Backup TOC. Currently only ADB (default)
is supported
-p, --pnor=file
Output file to write data

-t, --sides=( 1 | 2 )
Number of sides to the flash (Default: 1)
1 change: 1 addition & 0 deletions external/ffspart/test/results/01-param-sanity.err
@@ -0,0 +1 @@
Greater than two sides is not supported
21 changes: 21 additions & 0 deletions external/ffspart/test/results/01-param-sanity.out
@@ -0,0 +1,21 @@
Open-Power FFS format tool VERSION
Usage: ./ffspart [options] -s size -c num -i layout_file -p pnor_file ...

Options:
-s, --block_size=size
Size (in hex with leading 0x) of the blocks on the flash in bytes

-c, --block_count=num
Number of blocks on the flash

-i, --input=file
File containing the required partition data

-o, --order=( ADB | ABD )
Ordering of the TOC, Data and Backup TOC. Currently only ADB (default)
is supported
-p, --pnor=file
Output file to write data

-t, --sides=( 1 | 2 )
Number of sides to the flash (Default: 1)
1 change: 1 addition & 0 deletions external/ffspart/test/results/02-param-sides.err
@@ -0,0 +1 @@
Invalid block_count 1 for sides 2
21 changes: 21 additions & 0 deletions external/ffspart/test/results/02-param-sides.out
@@ -0,0 +1,21 @@
Open-Power FFS format tool VERSION
Usage: ./ffspart [options] -s size -c num -i layout_file -p pnor_file ...

Options:
-s, --block_size=size
Size (in hex with leading 0x) of the blocks on the flash in bytes

-c, --block_count=num
Number of blocks on the flash

-i, --input=file
File containing the required partition data

-o, --order=( ADB | ABD )
Ordering of the TOC, Data and Backup TOC. Currently only ADB (default)
is supported
-p, --pnor=file
Output file to write data

-t, --sides=( 1 | 2 )
Number of sides to the flash (Default: 1)
2 changes: 2 additions & 0 deletions external/ffspart/test/results/05-hdr-overlap.err
@@ -0,0 +1,2 @@
Adding partition 'FOUR' would cause partition 'ONE' at 0x00000200 to overlap with the header
Couldn't add entry 'FOUR' 0x00000500 for 0x00000100
5 changes: 5 additions & 0 deletions external/ffspart/test/results/05-hdr-overlap.out
@@ -0,0 +1,5 @@
Adding 'ONE' 0x00000200, 0x00000100
Adding 'TWO' 0x00000300, 0x00000100
Adding 'THREE' 0x00000400, 0x00000100
Adding 'FOUR' 0x00000500, 0x00000100
Freeing hdr
2 changes: 2 additions & 0 deletions external/ffspart/test/results/05.1-hdr-overlap-backup.err
@@ -0,0 +1,2 @@
Adding partition 'BACKUP_PART' would cause partition 'ONE' at 0x00000200 to overlap with the header
Failed to create backup part
4 changes: 4 additions & 0 deletions external/ffspart/test/results/05.1-hdr-overlap-backup.out
@@ -0,0 +1,4 @@
Adding 'ONE' 0x00000200, 0x00000100
Adding 'TWO' 0x00000300, 0x00000100
Adding 'THREE' 0x00000400, 0x00000100
Freeing hdr
1 change: 1 addition & 0 deletions external/ffspart/test/results/06-small-flash.err
@@ -0,0 +1 @@
Couldn't add entry 'TWO' 0x00000400 for 0x00000100
3 changes: 3 additions & 0 deletions external/ffspart/test/results/06-small-flash.out
@@ -0,0 +1,3 @@
Adding 'ONE' 0x00000300, 0x00000100
Adding 'TWO' 0x00000400, 0x00000100
Freeing hdr
1 change: 1 addition & 0 deletions external/ffspart/test/results/07-big-files.err
@@ -0,0 +1 @@
Data file for partition 'ONE' is too large
2 changes: 2 additions & 0 deletions external/ffspart/test/results/07-big-files.out
@@ -0,0 +1,2 @@
Adding 'ONE' 0x00000300, 0x00000100
Freeing hdr
Empty file.
5 changes: 5 additions & 0 deletions external/ffspart/test/results/08-small-files.out
@@ -0,0 +1,5 @@
Adding 'ONE' 0x00000300, 0x00000100
Adding 'TWO' 0x00000400, 0x00000100
Adding 'THREE' 0x00000500, 0x00000100
Adding 'FOUR' 0x00000600, 0x00000100
Freeing hdr
1 change: 1 addition & 0 deletions external/ffspart/test/results/10-bad-input.err
@@ -0,0 +1 @@
Invalid input file format: Couldn't parse 'ONE0x00000300' partition length
1 change: 1 addition & 0 deletions external/ffspart/test/results/10-bad-input.out
@@ -0,0 +1 @@
Freeing hdr
2 changes: 2 additions & 0 deletions external/ffspart/test/results/11-long-name.err
@@ -0,0 +1,2 @@
WARNING: Long partition 'This_is_more_than_15_characters' name will get truncated
WARNING: Long partition 'This_is_one_more' name will get truncated
5 changes: 5 additions & 0 deletions external/ffspart/test/results/11-long-name.out
@@ -0,0 +1,5 @@
Adding 'This_is_more_than_15_characters' 0x00000300, 0x00000100
Adding 'This_is_exactly' 0x00000400, 0x00000100
Adding 'This_is_one_le' 0x00000500, 0x00000100
Adding 'This_is_one_more' 0x00000600, 0x00000100
Freeing hdr
1 change: 1 addition & 0 deletions external/ffspart/test/results/12-bad-numbers-base.err
@@ -0,0 +1 @@
Invalid input file format: Couldn't parse 'ONE' partition base address
1 change: 1 addition & 0 deletions external/ffspart/test/results/12-bad-numbers-base.out
@@ -0,0 +1 @@
Freeing hdr
1 change: 1 addition & 0 deletions external/ffspart/test/results/13-bad-numbers-size.err
@@ -0,0 +1 @@
Invalid input file format: Couldn't parse 'ONE' partition length
1 change: 1 addition & 0 deletions external/ffspart/test/results/13-bad-numbers-size.out
@@ -0,0 +1 @@
Freeing hdr
1 change: 1 addition & 0 deletions external/ffspart/test/results/14-bad-input-flags.err
@@ -0,0 +1 @@
Unknown flag 'Z'
1 change: 1 addition & 0 deletions external/ffspart/test/results/14-bad-input-flags.out
@@ -0,0 +1 @@
Freeing hdr
@@ -0,0 +1 @@
Couldn't add entry 'TWO' 0x00000350 for 0x00000100
3 changes: 3 additions & 0 deletions external/ffspart/test/results/15-overlapping-partitions.out
@@ -0,0 +1,3 @@
Adding 'ONE' 0x00000300, 0x00000100
Adding 'TWO' 0x00000350, 0x00000100
Freeing hdr
5 changes: 5 additions & 0 deletions external/ffspart/test/test-ffspart
@@ -0,0 +1,5 @@
#! /bin/sh

. test/test.sh

run_tests "test/tests/*" "test/results" "test/files"
12 changes: 12 additions & 0 deletions external/ffspart/test/tests/00-usage
@@ -0,0 +1,12 @@
#! /bin/sh

run_binary "./ffspart"
if [ "$?" -ne 1 ] ; then
fail_test
fi

strip_version_from_result "ffspart"

diff_with_result

pass_test
12 changes: 12 additions & 0 deletions external/ffspart/test/tests/01-param-sanity
@@ -0,0 +1,12 @@
#! /bin/sh

run_binary "./ffspart" "-t 3 -s 1 -c 3 -i /dev/null -p /dev/null"
if [ "$?" -ne 1 ] ; then
fail_test
fi

strip_version_from_result "ffspart"

diff_with_result

pass_test
12 changes: 12 additions & 0 deletions external/ffspart/test/tests/02-param-sides
@@ -0,0 +1,12 @@
#! /bin/sh

run_binary "./ffspart" "-t 2 -s 1 -c 1 -i /dev/null -p /dev/null"
if [ "$?" -ne 1 ] ; then
fail_test
fi

strip_version_from_result "ffspart"

diff_with_result

pass_test
15 changes: 15 additions & 0 deletions external/ffspart/test/tests/03-tiny-pnor
@@ -0,0 +1,15 @@
#! /bin/sh

touch $DATA_DIR/$CUR_TEST.gen

run_binary "./ffspart" "-s 0x100 -c 10 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen"
if [ "$?" -ne 0 ] ; then
fail_test
fi

if ! cmp -n $((0x100)) $DATA_DIR/$CUR_TEST.out $DATA_DIR/$CUR_TEST.gen ; then
echo "Output differs"
fail_test
fi

pass_test
15 changes: 15 additions & 0 deletions external/ffspart/test/tests/03.1-tiny-pnor-backup
@@ -0,0 +1,15 @@
#! /bin/sh

touch $DATA_DIR/$CUR_TEST.gen

run_binary "./ffspart" "-b -s 0x100 -c 10 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen"
if [ "$?" -ne 0 ] ; then
fail_test
fi

if ! cmp -n $((0x100)) $DATA_DIR/$CUR_TEST.out $DATA_DIR/$CUR_TEST.gen ; then
echo "Output differs"
fail_test
fi

pass_test
25 changes: 25 additions & 0 deletions external/ffspart/test/tests/04-tiny-pnor2
@@ -0,0 +1,25 @@
#! /bin/sh
touch $DATA_DIR/$CUR_TEST.gen

i=1;
while [ $i -lt 5 ] ; do
j=0;
while [ $j -lt $((0x100)) ] ; do
echo -n "$i" >> $DATA_DIR/$CUR_TEST.$i;
j=$(expr $j + 1);
done
sed -i "s|SEDCATCH_$i|$DATA_DIR\/$CUR_TEST.$i|" $DATA_DIR/$CUR_TEST.in
i=$(expr $i + 1);
done

run_binary "./ffspart" "-s 0x100 -c 10 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen"
if [ "$?" -ne 0 ] ; then
fail_test
fi

if ! cmp -n $((0x500)) $DATA_DIR/$CUR_TEST.out $DATA_DIR/$CUR_TEST.gen ; then
echo "Output differs"
fail_test
fi

pass_test
15 changes: 15 additions & 0 deletions external/ffspart/test/tests/05-hdr-overlap
@@ -0,0 +1,15 @@
#! /bin/sh

touch $DATA_DIR/$CUR_TEST.gen

run_binary "./ffspart" "-s 0x100 -c 10 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen"
#expect this error code, which is FFS_ERR_BAD_PART_BASE becase we're
#going to have too many partitions for header to fit before the first
#partition
if [ "$?" -ne 107 ] ; then
fail_test
fi

diff_with_result

pass_test
15 changes: 15 additions & 0 deletions external/ffspart/test/tests/05.1-hdr-overlap-backup
@@ -0,0 +1,15 @@
#! /bin/sh

touch $DATA_DIR/$CUR_TEST.gen

run_binary "./ffspart" "-b -s 0x100 -c 10 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen"
#expect this error code, which is FFS_ERR_BAD_PART_BASE becase we're
#going to have too many partitions for header to fit before the first
#partition
if [ "$?" -ne 107 ] ; then
fail_test
fi

diff_with_result

pass_test
12 changes: 12 additions & 0 deletions external/ffspart/test/tests/06-small-flash
@@ -0,0 +1,12 @@
#! /bin/sh
touch $DATA_DIR/$CUR_TEST.gen

run_binary "./ffspart" "-s 0x100 -c 4 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen"
#Expect FFS_ERR_BAD_PART_SIZE because the flash is too small
if [ "$?" -ne 108 ] ; then
fail_test
fi

diff_with_result

pass_test

0 comments on commit 5f7e491

Please sign in to comment.