summaryrefslogtreecommitdiff
path: root/tests/gen_test.sh
diff options
context:
space:
mode:
authorSzuWei Lin <szuweilin@google.com>2017-01-10 11:54:22 +0800
committerSzuWei Lin <szuweilin@google.com>2017-01-16 17:19:39 +0800
commitb63f3b74cc6f87a1106e2afd49e82cac3538ef53 (patch)
tree07c043517d2e001d48cbc80dea554bb416a52fb4 /tests/gen_test.sh
parentda8237d9cceccc3e650ad433689ee4c6ba93b80b (diff)
downloadlibufdt-b63f3b74cc6f87a1106e2afd49e82cac3538ef53.tar.gz
Add shell scripts to verify DTO
Add two shell scripts to verify DTO (device tree overlay). verify_dto_inc.sh uses syntax /include/ to simulate DTO. verify_dto_ovl.sh uses dtc to compile dts to dtb, and uses ufdt_overlay_test_app which implemented with libufdt to apply DTO. Also modified test code and test cases to use these shell scripts. Bug: 33954716 Test: run test scripts (see libufdt/tests/README) Change-Id: Iaa16d6d2b9a6cb767ed0cf25180b0e6ee290415d
Diffstat (limited to 'tests/gen_test.sh')
-rwxr-xr-xtests/gen_test.sh91
1 files changed, 21 insertions, 70 deletions
diff --git a/tests/gen_test.sh b/tests/gen_test.sh
index 74f7177..dcb6d2d 100755
--- a/tests/gen_test.sh
+++ b/tests/gen_test.sh
@@ -4,88 +4,39 @@
# the "base" and "add" device tree source (.dts) files in two
# different ways.
#
-# 1) /include/ the "add" at the end of the "base" file and
-# compile with dtc to make the "gold standard" .dtb
+# 1) Use /include/ and compile via dtc to make the "gold standard"
#
-# 2) Compile them separately (modifying the "add" file to
-# be an overlay file) with dtc, then join them with the
-# ov_test program
+# 2) Compile them separately dtc, and join them with the
+# ufdt_apply_overlay program
#
-# To do this, we need to generate a lot of files from the .base_dts
-# and .add_dts files:
-# .base_inc_dts - Has the /include/ "${FILENAME}.add_dts" at the end.
-# .base_inc_dtb - The dtc-generated "gold standard"
-# .add_ov_dts - Has the /plugin/ at the start
-# .base_dtb - Compiled version of just the base
-# .add_ov_dtbo - Compiled version of the overlay
-# .base_ov_dtb - overlay-test-joined version of the dtb
-#
-# Then, compare .base_inc_dtb and .base_ov_dtb with dtdiff
-# (or maybe diff?) and return 0 iff they are identical.
+# Then, compare 1) and 2) with dts_diff (diff merged nodes) and return 0
+# iff they are identical.
-# Include some functions from common.sh.
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
source ${SCRIPT_DIR}/common.sh
-# Constants
-IN_DATA_DIR="testdata"
-OUT_DATA_DIR="test-out"
-
-# Global variables
-FILENAME=$1
-
on_exit() {
- rm -rf "${OUT_DATA_DIR}"
-}
-
-# Generate test cases to OUT_DATA_DIR
-prepare_tests() {
- cp "${IN_DATA_DIR}/${FILENAME}.base_dts" "${OUT_DATA_DIR}/${FILENAME}.base_dts"
- cp "${IN_DATA_DIR}/${FILENAME}.add_dts" "${OUT_DATA_DIR}/${FILENAME}.add_dts"
-
- # Add the "include" to make .base_inc_dts
- cp "${IN_DATA_DIR}/${FILENAME}.base_dts" "${OUT_DATA_DIR}/${FILENAME}.base_inc_dts"
- echo "/include/ \"${FILENAME}.add_dts\"" >> "${OUT_DATA_DIR}/${FILENAME}.base_inc_dts"
-
- # Generate .base_inc_dtb
- dtc -@ -O dtb -s -b 0 -o "${OUT_DATA_DIR}/${FILENAME}.base_inc.dtb" \
- "${OUT_DATA_DIR}/${FILENAME}.base_inc_dts"
-
- # Add /dts-v1/ /plugin/; in front of .add_dts file. In order to trigger dtc's
- # fragment generation mechanism.
- if [ -a "${IN_DATA_DIR}/${FILENAME}.add_ov_dts" ]; then
- cp "${IN_DATA_DIR}/${FILENAME}.add_ov_dts" "${OUT_DATA_DIR}/${FILENAME}.add_ov_dts"
- else
- sed "1i/dts-v1/ /plugin/;" "${IN_DATA_DIR}/${FILENAME}.add_dts" > \
- "${OUT_DATA_DIR}/${FILENAME}.add_ov_dts"
- fi
+ rm -rf "$TEMP_DIR"
}
-# Compile test cases into dtb, and do the diff things.
-compile_and_diff() {
- # Compile the base to make .base_dtb
- dtc -O dtb -b 0 -qq -@ -o "${OUT_DATA_DIR}/${FILENAME}.base_dtb" \
- "${OUT_DATA_DIR}/${FILENAME}.base_dts"
-
- # Compile the overlay to make .add_ov_dtbo
- dtc -O dtb -b 0 -qq -@ -o "${OUT_DATA_DIR}/${FILENAME}.add_ov_dtbo" \
- "${OUT_DATA_DIR}/${FILENAME}.add_ov_dts"
-
- # Run ov_test to combine .base_dtb and .add_ov_dtbo
- # into .base_ov_dtb
- ufdt_apply_overlay "${OUT_DATA_DIR}/${FILENAME}.base_dtb" \
- "${OUT_DATA_DIR}/${FILENAME}.add_ov_dtbo" \
- "${OUT_DATA_DIR}/${FILENAME}.base_ov.dtb"
-
- # Run the diff
- dt_diff ${OUT_DATA_DIR}/${FILENAME}.base_inc.dtb ${OUT_DATA_DIR}/${FILENAME}.base_ov.dtb
-}
+# Constants
+IN_DATA_DIR="testdata"
+TEMP_DIR=`mktemp -d`
# The script will exit directly if any command fails.
set -e
trap on_exit EXIT
-mkdir -p "${OUT_DATA_DIR}" >& /dev/null
+# Global variables
+TESTCASE_NAME=$1
+BASE_DTS="$IN_DATA_DIR/${TESTCASE_NAME}-base.dts"
+OVERLAY_DTS="$IN_DATA_DIR/${TESTCASE_NAME}-overlay.dts"
+INC_MERGED_DTS="$TEMP_DIR/${TESTCASE_NAME}-inc-merged.dts"
+OVL_MERGED_DTS="$TEMP_DIR/${TESTCASE_NAME}-ovl-merged.dts"
-prepare_tests
-compile_and_diff
+#
+# Complie and diff
+#
+$SCRIPT_DIR/verify_dto_inc.sh "$BASE_DTS" "$OVERLAY_DTS" "$INC_MERGED_DTS"
+$SCRIPT_DIR/verify_dto_ovl.sh "$BASE_DTS" "$OVERLAY_DTS" "$OVL_MERGED_DTS"
+dts_diff "$INC_MERGED_DTS" "$OVL_MERGED_DTS"