Skip to content

Commit

Permalink
tests: add basic tests of fdtget/fdtput with &label syntax
Browse files Browse the repository at this point in the history
We obviously need to build some dtbs with -@ to do these tests. In
order to still test all the old functionality on blobs built without
-@, simply run all fdtget/fdtput tests twice, with/without -@, and for
the few new test cases that rely on -@, check that they fail when the
blob is not built with -@.

Signed-off-by: Rasmus Villemoes <[email protected]>
  • Loading branch information
Rasmus Villemoes committed Apr 27, 2023
1 parent 7b52d7e commit f0ec5b1
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,10 @@ dtbs_equal_tests () {
}

fdtget_tests () {
at="$1"
dts=label01.dts
dtb=$dts.fdtget.test.dtb
run_dtc_test -O dtb -o $dtb "$SRCDIR/$dts"
run_dtc_test $at -O dtb -o $dtb "$SRCDIR/$dts"

# run_fdtget_test <expected-result> [<flags>] <file> <node> <property>
run_fdtget_test "MyBoardName" $dtb / model
Expand All @@ -878,6 +879,11 @@ fdtget_tests () {
# Here the property size is not a multiple of 4 bytes, so it should fail
run_wrap_error_test $DTGET -tlx $dtb /randomnode mixed
run_fdtget_test "6162 6300 1234 0 a 0 b 0 c" -thx $dtb /randomnode mixed
if [ -n "$at" ]; then
run_fdtget_test "6162 6300 1234 0 a 0 b 0 c" -thx $dtb "&node" mixed
else
run_wrap_error_test $DTGET -thx $dtb "&node" mixed
fi
run_fdtget_test "61 62 63 0 12 34 0 0 0 a 0 0 0 b 0 0 0 c" \
-thhx $dtb /randomnode mixed
run_wrap_error_test $DTGET -ts $dtb /randomnode doctor-who
Expand All @@ -893,12 +899,13 @@ fdtget_tests () {
}

fdtput_tests () {
at="$1"
dts=label01.dts
dtb=$dts.fdtput.test.dtb
text="$SRCDIR/lorem.txt"

# Allow just enough space for $text
run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb "$SRCDIR/$dts"
run_dtc_test $at -O dtb -p $($STATSZ $text) -o $dtb "$SRCDIR/$dts"

# run_fdtput_test <expected-result> <file> <node> <property> <flags> <value>
run_fdtput_test "a_model" $dtb / model -ts "a_model"
Expand All @@ -912,12 +919,19 @@ fdtput_tests () {
run_fdtput_test "a0b0c0d deeaae ef000000" $dtb /randomnode blob \
-tx "a0b0c0d deeaae ef000000"
run_fdtput_test "$(cat $text)" $dtb /randomnode blob -ts "$(cat $text)"
if [ -n "$at" ]; then
run_fdtput_test "y" $dtb '&node' x -ts "y"
run_fdtput_test "z" $dtb '&node/child' x -ts "z"
else
run_wrap_error_test $DTPUT $dtb '&node' x -ts "y"
run_wrap_error_test $DTPUT $dtb '&node/child' x -ts "z"
fi

# Test expansion of the blob when insufficient room for property
run_fdtput_test "$(cat $text $text)" $dtb /randomnode blob -ts "$(cat $text $text)"

# Start again with a fresh dtb
run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb "$SRCDIR/$dts"
run_dtc_test $at -O dtb -p $($STATSZ $text) -o $dtb "$SRCDIR/$dts"

# Node creation
run_wrap_error_test $DTPUT $dtb -c /baldrick sod
Expand Down Expand Up @@ -945,7 +959,7 @@ fdtput_tests () {
run_wrap_test $DTPUT $dtb -cp /chosen/son

# Start again with a fresh dtb
run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb "$SRCDIR/$dts"
run_dtc_test $at -O dtb -p $($STATSZ $text) -o $dtb "$SRCDIR/$dts"

# Node delete
run_wrap_test $DTPUT $dtb -c /chosen/node1 /chosen/node2 /chosen/node3
Expand Down Expand Up @@ -1095,10 +1109,12 @@ for set in $TESTSETS; do
dtbs_equal_tests
;;
"fdtget")
fdtget_tests
fdtget_tests ""
fdtget_tests "-@"
;;
"fdtput")
fdtput_tests
fdtput_tests ""
fdtput_tests "-@"
;;
"fdtdump")
fdtdump_tests
Expand Down

0 comments on commit f0ec5b1

Please sign in to comment.