Browse Source

dtc: Assorted improvements to test harness

This patch makes several small improvements to the test harness.

* An altered way of invoking shell script testcases from run_tests.sh
  means scripts no longer need to me marked executable in the
  repository to work properly.

* dtc.sh never did anything that was really dtc specific - with the
  exception of messages, it would work equally well for any binary
  that returns 0 in the successful case.  Therefore, generalise dtc.sh
  and fold it into run_tests.sh so we don't need a separate script any
  more.

* Tweak various things so that the valgrind options are properly
  propagated down to invoke dtc under valgrind when called via wrapper
  scripts.

* Tweak the valgrind suppressions to work properly on a wider range of
  systems (this was necessary on my machine running Ubuntu Hardy).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
David Gibson 17 years ago committed by Jon Loeliger
parent
commit
68fe10ba4e
  1. 5
      tests/dtc-checkfails.sh
  2. 10
      tests/dtc.sh
  3. 2
      tests/mangle-layout.supp
  4. 2
      tests/open_pack.supp
  5. 112
      tests/run_tests.sh

5
tests/dtc-checkfails.sh

@ -14,11 +14,12 @@ LOG="tmp.log.$$" @@ -14,11 +14,12 @@ LOG="tmp.log.$$"

rm -f $TMPFILE $LOG

verbose_run_log "$LOG" "$DTC" -o /dev/null "$@"
verbose_run_log "$LOG" $VALGRIND "$DTC" -o /dev/null "$@"
ret="$?"

if [ "$ret" -gt 127 ]; then
FAIL "dtc killed by signal (ret=$ret)"
signame=$(kill -l $[ret - 128])
FAIL "Killed by SIG$signame"
fi

for c in $CHECKS; do

10
tests/dtc.sh

@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
#! /bin/sh

. tests.sh

if verbose_run "$DTC" "$@"; then
PASS
else
ret="$?"
FAIL "dtc returned error code $ret"
fi

2
tests/mangle-layout.supp

@ -2,6 +2,6 @@ @@ -2,6 +2,6 @@
uninitialized alignment gaps can be dumped to output
Memcheck:Param
write(buf)
obj:/lib/ld-2.6.1.so
obj:/lib/ld-*.so
fun:main
}

2
tests/open_pack.supp

@ -2,6 +2,6 @@ @@ -2,6 +2,6 @@
opened blob dumps uninitialized data
Memcheck:Param
write(buf)
obj:/lib/ld-2.6.1.so
obj:/lib/ld-*.so
fun:main
}

112
tests/run_tests.sh

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
#! /bin/bash

. tests.sh

export QUIET_TEST=1

export VALGRIND=
@ -12,16 +14,9 @@ tot_config=0 @@ -12,16 +14,9 @@ tot_config=0
tot_vg=0
tot_strange=0

run_test () {
base_run_test() {
tot_tests=$[tot_tests + 1]
echo -n "$@: "
VGLOCAL="$VALGRIND"
if [ -n "$VALGRIND" ]; then
if [ -f $1.supp ]; then
VGLOCAL="$VGLOCAL --suppressions=$1.supp"
fi
fi
if $VGLOCAL "./$@"; then
if VALGRIND="$VALGRIND" "$@"; then
tot_pass=$[tot_pass + 1]
else
ret="$?"
@ -37,6 +32,45 @@ run_test () { @@ -37,6 +32,45 @@ run_test () {
fi
}

run_test () {
echo -n "$@: "
if [ -n "$VALGRIND" -a -f $1.supp ]; then
VGSUPP="--suppressions=$1.supp"
fi
base_run_test $VALGRIND $VGSUPP "./$@"
}

run_sh_test () {
echo -n "$@: "
base_run_test sh "$@"
}

wrap_test () {
(
if verbose_run "$@"; then
PASS
else
ret="$?"
if [ "$ret" -gt 127 ]; then
signame=$(kill -l $[ret - 128])
FAIL "Killed by SIG$signame"
else
FAIL "Returned error code $ret"
fi
fi
)
}

run_wrap_test () {
echo -n "$@: "
base_run_test wrap_test "$@"
}

run_dtc_test () {
echo -n "dtc $@: "
base_run_test wrap_test $VALGRIND $DTC "$@"
}

tree1_tests () {
TREE=$1

@ -140,35 +174,35 @@ libfdt_tests () { @@ -140,35 +174,35 @@ libfdt_tests () {
}

dtc_tests () {
run_test dtc.sh -I dts -O dtb -o dtc_tree1.test.dtb test_tree1.dts
run_dtc_test -I dts -O dtb -o dtc_tree1.test.dtb test_tree1.dts
tree1_tests dtc_tree1.test.dtb
tree1_tests_rw dtc_tree1.test.dtb
run_test dtbs_equal_ordered dtc_tree1.test.dtb test_tree1.dtb

run_test dtc.sh -I dts -O dtb -o dtc_tree1_dts0.test.dtb test_tree1_dts0.dts
run_dtc_test -I dts -O dtb -o dtc_tree1_dts0.test.dtb test_tree1_dts0.dts
tree1_tests dtc_tree1_dts0.test.dtb
tree1_tests_rw dtc_tree1_dts0.test.dtb

run_test dtc.sh -I dts -O dtb -o dtc_escapes.test.dtb escapes.dts
run_dtc_test -I dts -O dtb -o dtc_escapes.test.dtb escapes.dts
run_test string_escapes dtc_escapes.test.dtb

run_test dtc.sh -I dts -O dtb -o dtc_references.test.dtb references.dts
run_dtc_test -I dts -O dtb -o dtc_references.test.dtb references.dts
run_test references dtc_references.test.dtb

run_test dtc.sh -I dts -O dtb -o dtc_references_dts0.test.dtb references_dts0.dts
run_dtc_test -I dts -O dtb -o dtc_references_dts0.test.dtb references_dts0.dts
run_test references dtc_references_dts0.test.dtb

run_test dtc.sh -I dts -O dtb -o dtc_path-references.test.dtb path-references.dts
run_dtc_test -I dts -O dtb -o dtc_path-references.test.dtb path-references.dts
run_test path-references dtc_path-references.test.dtb

run_test dtc.sh -I dts -O dtb -o dtc_comments.test.dtb comments.dts
run_test dtc.sh -I dts -O dtb -o dtc_comments-cmp.test.dtb comments-cmp.dts
run_dtc_test -I dts -O dtb -o dtc_comments.test.dtb comments.dts
run_dtc_test -I dts -O dtb -o dtc_comments-cmp.test.dtb comments-cmp.dts
run_test dtbs_equal_ordered dtc_comments.test.dtb dtc_comments-cmp.test.dtb

# Check -Odts mode preserve all dtb information
for tree in test_tree1.dtb dtc_tree1.test.dtb dtc_escapes.test.dtb ; do
run_test dtc.sh -I dtb -O dts -o odts_$tree.test.dts $tree
run_test dtc.sh -I dts -O dtb -o odts_$tree.test.dtb odts_$tree.test.dts
run_dtc_test -I dtb -O dts -o odts_$tree.test.dts $tree
run_dtc_test -I dts -O dtb -o odts_$tree.test.dtb odts_$tree.test.dts
run_test dtbs_equal_ordered $tree odts_$tree.test.dtb
done

@ -176,34 +210,34 @@ dtc_tests () { @@ -176,34 +210,34 @@ dtc_tests () {
for tree in test_tree1.dtb ; do
for aver in 1 2 3 16 17; do
atree="ov${aver}_$tree.test.dtb"
run_test dtc.sh -I dtb -O dtb -V$aver -o $atree $tree
run_dtc_test -I dtb -O dtb -V$aver -o $atree $tree
for bver in 16 17; do
btree="ov${bver}_$atree"
run_test dtc.sh -I dtb -O dtb -V$bver -o $btree $atree
run_dtc_test -I dtb -O dtb -V$bver -o $btree $atree
run_test dtbs_equal_ordered $btree $tree
done
done
done

# Check some checks
run_test dtc-checkfails.sh duplicate_node_names -- -I dts -O dtb dup-nodename.dts
run_test dtc-checkfails.sh duplicate_property_names -- -I dts -O dtb dup-propname.dts
run_test dtc-checkfails.sh explicit_phandles -- -I dts -O dtb dup-phandle.dts
run_test dtc-checkfails.sh explicit_phandles -- -I dts -O dtb zero-phandle.dts
run_test dtc-checkfails.sh explicit_phandles -- -I dts -O dtb minusone-phandle.dts
run_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-node-ref.dts
run_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-label-ref.dts
run_test dtc-checkfails.sh name_properties -- -I dts -O dtb bad-name-property.dts

run_test dtc-checkfails.sh address_cells_is_cell size_cells_is_cell interrupt_cells_is_cell -- -I dts -O dtb bad-ncells.dts
run_test dtc-checkfails.sh device_type_is_string model_is_string status_is_string -- -I dts -O dtb bad-string-props.dts
run_test dtc-checkfails.sh reg_format ranges_format -- -I dts -O dtb bad-reg-ranges.dts
run_test dtc-checkfails.sh ranges_format -- -I dts -O dtb bad-empty-ranges.dts
run_test dtc-checkfails.sh avoid_default_addr_size -- -I dts -O dtb default-addr-size.dts
run_test dtc-checkfails.sh obsolete_chosen_interrupt_controller -- -I dts -O dtb obsolete-chosen-interrupt-controller.dts
run_test dtc-checkfails.sh node_name_chars -- -I dtb -O dtb bad_node_char.dtb
run_test dtc-checkfails.sh node_name_format -- -I dtb -O dtb bad_node_format.dtb
run_test dtc-checkfails.sh prop_name_chars -- -I dtb -O dtb bad_prop_char.dtb
run_sh_test dtc-checkfails.sh duplicate_node_names -- -I dts -O dtb dup-nodename.dts
run_sh_test dtc-checkfails.sh duplicate_property_names -- -I dts -O dtb dup-propname.dts
run_sh_test dtc-checkfails.sh explicit_phandles -- -I dts -O dtb dup-phandle.dts
run_sh_test dtc-checkfails.sh explicit_phandles -- -I dts -O dtb zero-phandle.dts
run_sh_test dtc-checkfails.sh explicit_phandles -- -I dts -O dtb minusone-phandle.dts
run_sh_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-node-ref.dts
run_sh_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-label-ref.dts
run_sh_test dtc-checkfails.sh name_properties -- -I dts -O dtb bad-name-property.dts

run_sh_test dtc-checkfails.sh address_cells_is_cell size_cells_is_cell interrupt_cells_is_cell -- -I dts -O dtb bad-ncells.dts
run_sh_test dtc-checkfails.sh device_type_is_string model_is_string status_is_string -- -I dts -O dtb bad-string-props.dts
run_sh_test dtc-checkfails.sh reg_format ranges_format -- -I dts -O dtb bad-reg-ranges.dts
run_sh_test dtc-checkfails.sh ranges_format -- -I dts -O dtb bad-empty-ranges.dts
run_sh_test dtc-checkfails.sh avoid_default_addr_size -- -I dts -O dtb default-addr-size.dts
run_sh_test dtc-checkfails.sh obsolete_chosen_interrupt_controller -- -I dts -O dtb obsolete-chosen-interrupt-controller.dts
run_sh_test dtc-checkfails.sh node_name_chars -- -I dtb -O dtb bad_node_char.dtb
run_sh_test dtc-checkfails.sh node_name_format -- -I dtb -O dtb bad_node_format.dtb
run_sh_test dtc-checkfails.sh prop_name_chars -- -I dtb -O dtb bad_prop_char.dtb
}

while getopts "vt:m" ARG ; do

Loading…
Cancel
Save