From a34bb721caca10964cb7d22b9d9322b0424c9042 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 22 Sep 2016 14:42:42 +1000 Subject: [PATCH] dtc: Fix assorted problems in the testcases for the -a option We just added the -a option to allow padding of the output dtb's size to a specified alignment. Unfortunately the test cases for this had several bugs: * Didn't actually test anything since "alignbase" instead of $alignbase was passed to the checker function * Introduced an unnecessary run_local_test wrapper * Didn't provide very helpful output on failure * Only attempted to check one alignment value This patch fixes up these problems. Signed-off-by: David Gibson --- tests/run_tests.sh | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index a71909c..f4b32e4 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -62,11 +62,6 @@ run_test () { base_run_test $VALGRIND $VGSUPP "./$@" } -run_local_test () { - printf "$*: " - base_run_test "$@" -} - run_sh_test () { printf "$*: " base_run_test sh "$@" @@ -117,14 +112,15 @@ run_wrap_error_test () { # $1: dtb file # $2: align base -align_test () { - local size=`stat -c %s $1` - local mod=$(($size%$2)) +check_align () { + shorten_echo "check_align $@: " + local size=$(stat -c %s "$1") + local align="$2" ( - if [ $mod -eq 0 ] ;then + if [ $(($size % $align)) -eq 0 ] ;then PASS else - FAIL + FAIL "Output size $size is not $align-byte aligned" fi ) } @@ -524,13 +520,14 @@ dtc_tests () { search_dir_b/search_paths_subdir.dts # Check -a option - local alignbase=64 - # -p -a - run_dtc_test -O dtb -p 1000 -a $alignbase -o align0.dtb subnode_iterate.dts - run_local_test align_test align0.dtb alignbase - # -S -a - run_dtc_test -O dtb -S 1999 -a $alignbase -o align1.dtb subnode_iterate.dts - run_local_test align_test align1.dtb alignbase + for align in 2 4 8 16 32 64; do + # -p -a + run_dtc_test -O dtb -p 1000 -a $align -o align0.dtb subnode_iterate.dts + check_align align0.dtb $align + # -S -a + run_dtc_test -O dtb -S 1999 -a $align -o align1.dtb subnode_iterate.dts + check_align align1.dtb $align + done } cmp_tests () {