platform_external_dtc/tests/run_tests.sh
David Gibson 333542fabf libfdt: Add functions for handling the "compatible" property
This patch adds functions for dealing with the compatible property.
fdt_node_check_compatible() can be used to determine whether a node is
compatible with a given string and fdt_node_offset_by_compatible()
locates nodes with a given compatible string.

Testcases for these functions are also included.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-16 07:41:37 -05:00

145 lines
3 KiB
Bash
Executable file

#! /bin/bash
export QUIET_TEST=1
ENV=/usr/bin/env
tot_tests=0
tot_pass=0
tot_fail=0
tot_config=0
tot_strange=0
run_test () {
tot_tests=$[tot_tests + 1]
echo -n "$@: "
if PATH=".:$PATH" $ENV "$@"; then
tot_pass=$[tot_pass + 1]
else
ret="$?"
if [ "$ret" == "1" ]; then
tot_config=$[tot_config + 1]
elif [ "$ret" == "2" ]; then
tot_fail=$[tot_fail + 1]
else
tot_strange=$[tot_strange + 1]
fi
fi
}
tree1_tests () {
TREE=$1
# Read-only tests
run_test get_mem_rsv $TREE
run_test root_node $TREE
run_test find_property $TREE
run_test subnode_offset $TREE
run_test path_offset $TREE
run_test get_name $TREE
run_test getprop $TREE
run_test get_path $TREE
run_test supernode_atdepth_offset $TREE
run_test parent_offset $TREE
run_test node_offset_by_prop_value $TREE
run_test node_check_compatible $TREE
run_test node_offset_by_compatible $TREE
run_test notfound $TREE
# Write-in-place tests
run_test setprop_inplace $TREE
run_test nop_property $TREE
run_test nop_node $TREE
}
tree1_tests_rw () {
TREE=$1
# Read-write tests
run_test setprop $TREE
run_test del_property $TREE
run_test del_node $TREE
}
libfdt_tests () {
tree1_tests test_tree1.dtb
# Sequential write tests
run_test sw_tree1
tree1_tests sw_tree1.test.dtb
tree1_tests unfinished_tree1.test.dtb
# fdt_move tests
for tree in test_tree1.dtb sw_tree1.test.dtb unfinished_tree1.test.dtb; do
rm -f moved.$tree shunted.$tree deshunted.$tree
run_test move_and_save $tree
tree1_tests moved.$tree
tree1_tests shunted.$tree
tree1_tests deshunted.$tree
done
# Read-write tests
for tree in test_tree1.dtb sw_tree1.test.dtb; do
rm -f opened.$tree repacked.$tree
run_test open_pack $tree
tree1_tests opened.$tree
tree1_tests repacked.$tree
done
for tree in test_tree1.dtb sw_tree1.test.dtb; do
tree1_tests_rw $tree
tree1_tests_rw moved.$tree
tree1_tests_rw shunted.$tree
tree1_tests_rw deshunted.$tree
done
run_test rw_tree1
tree1_tests rw_tree1.test.dtb
tree1_tests_rw rw_tree1.test.dtb
# Tests for behaviour on various sorts of corrupted trees
run_test truncated_property
}
dtc_tests () {
run_test dtc.sh -f -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
}
while getopts "vdt:" ARG ; do
case $ARG in
"v")
unset QUIET_TEST
;;
"t")
TESTSETS=$OPTARG
;;
esac
done
if [ -z "$TESTSETS" ]; then
TESTSETS="libfdt dtc"
fi
# Make sure we don't have stale blobs lying around
rm -f *.test.dtb
for set in $TESTSETS; do
case $set in
"libfdt")
libfdt_tests
;;
"dtc")
dtc_tests
;;
esac
done
echo -e "********** TEST SUMMARY"
echo -e "* Total testcases: $tot_tests"
echo -e "* PASS: $tot_pass"
echo -e "* FAIL: $tot_fail"
echo -e "* Bad configuration: $tot_config"
echo -e "* Strange test result: $tot_strange"
echo -e "**********"