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