xref: /aosp_15_r20/system/libufdt/tests/run_tests.sh (revision 13e8728f0cffde9369df671f7b293a048a99c7ed)
1*13e8728fSAndroid Build Coastguard Worker#!/bin/bash
2*13e8728fSAndroid Build Coastguard Worker# Copyright (C) 2016 The Android Open Source Project
3*13e8728fSAndroid Build Coastguard Worker#
4*13e8728fSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
5*13e8728fSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
6*13e8728fSAndroid Build Coastguard Worker# You may obtain a copy of the License at
7*13e8728fSAndroid Build Coastguard Worker#
8*13e8728fSAndroid Build Coastguard Worker#      http://www.apache.org/licenses/LICENSE-2.0
9*13e8728fSAndroid Build Coastguard Worker#
10*13e8728fSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
11*13e8728fSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
12*13e8728fSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*13e8728fSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
14*13e8728fSAndroid Build Coastguard Worker# limitations under the License.
15*13e8728fSAndroid Build Coastguard Worker
16*13e8728fSAndroid Build Coastguard Worker# Include some functions from common.sh.
17*13e8728fSAndroid Build Coastguard WorkerSCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
18*13e8728fSAndroid Build Coastguard Workersource ${SCRIPT_DIR}/common.sh
19*13e8728fSAndroid Build Coastguard Worker
20*13e8728fSAndroid Build Coastguard Worker# Usage: run_test_case <filename> <description>
21*13e8728fSAndroid Build Coastguard Worker# Args:
22*13e8728fSAndroid Build Coastguard Worker#   filename: The file name for ./gen_test.sh to generate and run the
23*13e8728fSAndroid Build Coastguard Worker#     test case. Several files under ./testdata subfolder are required:
24*13e8728fSAndroid Build Coastguard Worker#       - ./testdata/${filename}.base_dts
25*13e8728fSAndroid Build Coastguard Worker#       - ./testdata/${filename}.add_dts
26*13e8728fSAndroid Build Coastguard Worker#       - ./testdata/${filename}.add_ov_dts (optional)
27*13e8728fSAndroid Build Coastguard Worker#     For more details, check ./gen_test.sh.
28*13e8728fSAndroid Build Coastguard Worker#   description: a description message to be displayed in the terminal
29*13e8728fSAndroid Build Coastguard Workerrun_test_case() {
30*13e8728fSAndroid Build Coastguard Worker  local filename="$1"
31*13e8728fSAndroid Build Coastguard Worker  local description="$2"
32*13e8728fSAndroid Build Coastguard Worker
33*13e8728fSAndroid Build Coastguard Worker  alert "${description}"
34*13e8728fSAndroid Build Coastguard Worker  ./gen_test.sh "${filename}" >&2 ||
35*13e8728fSAndroid Build Coastguard Worker    die "Test case: ${filename} failed!!"
36*13e8728fSAndroid Build Coastguard Worker}
37*13e8728fSAndroid Build Coastguard Worker
38*13e8728fSAndroid Build Coastguard Workermain() {
39*13e8728fSAndroid Build Coastguard Worker  alert "========== Running Tests of libufdt =========="
40*13e8728fSAndroid Build Coastguard Worker
41*13e8728fSAndroid Build Coastguard Worker  if [ -z "${ANDROID_BUILD_TOP}" ]; then
42*13e8728fSAndroid Build Coastguard Worker    die "Run envsetup.sh / lunch yet?"
43*13e8728fSAndroid Build Coastguard Worker  fi
44*13e8728fSAndroid Build Coastguard Worker
45*13e8728fSAndroid Build Coastguard Worker  if ! command_exists dtc ||
46*13e8728fSAndroid Build Coastguard Worker     ! command_exists fdt_apply_overlay ||
47*13e8728fSAndroid Build Coastguard Worker     ! command_exists ufdt_apply_overlay; then
48*13e8728fSAndroid Build Coastguard Worker    die "Run mmma $(dirname ${SCRIPT_DIR}) yet?"
49*13e8728fSAndroid Build Coastguard Worker  fi
50*13e8728fSAndroid Build Coastguard Worker
51*13e8728fSAndroid Build Coastguard Worker  (
52*13e8728fSAndroid Build Coastguard Worker
53*13e8728fSAndroid Build Coastguard Worker  # cd to ${SCRIPT_DIR} in a subshell because gen_test.sh uses relative
54*13e8728fSAndroid Build Coastguard Worker  # paths for dependent files.
55*13e8728fSAndroid Build Coastguard Worker  cd "${SCRIPT_DIR}"
56*13e8728fSAndroid Build Coastguard Worker
57*13e8728fSAndroid Build Coastguard Worker  run_test_case \
58*13e8728fSAndroid Build Coastguard Worker    "no_local_fixup" \
59*13e8728fSAndroid Build Coastguard Worker    "Run test about fdt_apply_fragment with no local fixup"
60*13e8728fSAndroid Build Coastguard Worker  run_test_case \
61*13e8728fSAndroid Build Coastguard Worker    "apply_fragment" \
62*13e8728fSAndroid Build Coastguard Worker    "Run test about fdt_apply_fragment with phandle update"
63*13e8728fSAndroid Build Coastguard Worker  run_test_case \
64*13e8728fSAndroid Build Coastguard Worker    "local_fixup" \
65*13e8728fSAndroid Build Coastguard Worker    "Run test about fdt_overlay_do_local_fixups"
66*13e8728fSAndroid Build Coastguard Worker  run_test_case \
67*13e8728fSAndroid Build Coastguard Worker    "local_fixup_with_offset" \
68*13e8728fSAndroid Build Coastguard Worker    "Run test about dealing with local fixup with offset > 0"
69*13e8728fSAndroid Build Coastguard Worker  run_test_case \
70*13e8728fSAndroid Build Coastguard Worker    "overlay_2_layers" \
71*13e8728fSAndroid Build Coastguard Worker    "Run test about dealing with overlay deep tree"
72*13e8728fSAndroid Build Coastguard Worker  # looks that libfdt doesn't promise the order, the order isn't matched.
73*13e8728fSAndroid Build Coastguard Worker  run_test_case \
74*13e8728fSAndroid Build Coastguard Worker    "node_ordering" \
75*13e8728fSAndroid Build Coastguard Worker    "Run test about node ordering"
76*13e8728fSAndroid Build Coastguard Worker  run_test_case \
77*13e8728fSAndroid Build Coastguard Worker    "base_no_symbols" \
78*13e8728fSAndroid Build Coastguard Worker    "Run test about base dtb without __symbols__"
79*13e8728fSAndroid Build Coastguard Worker  run_test_case \
80*13e8728fSAndroid Build Coastguard Worker    "overlay_no_symbols" \
81*13e8728fSAndroid Build Coastguard Worker    "Run test about overlay dtb without __symbols__"
82*13e8728fSAndroid Build Coastguard Worker  run_test_case \
83*13e8728fSAndroid Build Coastguard Worker    "empty_overlay" \
84*13e8728fSAndroid Build Coastguard Worker    "Run test about overlaying with empty base and overlay dt"
85*13e8728fSAndroid Build Coastguard Worker  run_test_case \
86*13e8728fSAndroid Build Coastguard Worker    "suffix_compress" \
87*13e8728fSAndroid Build Coastguard Worker    "Run test about string suffix compression"
88*13e8728fSAndroid Build Coastguard Worker  )
89*13e8728fSAndroid Build Coastguard Worker
90*13e8728fSAndroid Build Coastguard Worker  if [ $? -ne 0 ]; then
91*13e8728fSAndroid Build Coastguard Worker    die "Some test cases failed, please check error message..."
92*13e8728fSAndroid Build Coastguard Worker  fi
93*13e8728fSAndroid Build Coastguard Worker}
94*13e8728fSAndroid Build Coastguard Worker
95*13e8728fSAndroid Build Coastguard Workermain "$@"
96