Li Chen | f6c209b | 2016-11-28 12:15:33 +0800 | [diff] [blame] | 1 | #!/bin/bash |
SzuWei Lin | 4f00eda | 2017-04-06 17:12:27 +0800 | [diff] [blame] | 2 | # 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 Chen | f6c209b | 2016-11-28 12:15:33 +0800 | [diff] [blame] | 15 | |
| 16 | # Include some functions from common.sh. |
| 17 | SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" |
| 18 | source ${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 |
| 29 | run_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 | |
| 38 | main() { |
| 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 Lin | f7403df | 2017-02-18 15:18:30 +0800 | [diff] [blame] | 46 | ! command_exists fdt_apply_overlay || |
Li Chen | f6c209b | 2016-11-28 12:15:33 +0800 | [diff] [blame] | 47 | ! 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 Lin | b63f3b7 | 2017-01-10 11:54:22 +0800 | [diff] [blame] | 64 | "local_fixup" \ |
Li Chen | f6c209b | 2016-11-28 12:15:33 +0800 | [diff] [blame] | 65 | "Run test about fdt_overlay_do_local_fixups" |
| 66 | run_test_case \ |
Li Chen | f6c209b | 2016-11-28 12:15:33 +0800 | [diff] [blame] | 67 | "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 Lin | 08dd727 | 2017-02-20 10:38:20 +0800 | [diff] [blame] | 72 | # 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 Lin | fba5805 | 2017-03-20 16:11:17 +0800 | [diff] [blame] | 76 | 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 Lin | 32ad7f0 | 2017-03-28 17:14:56 +0800 | [diff] [blame] | 85 | run_test_case \ |
| 86 | "suffix_compress" \ |
| 87 | "Run test about string suffix compression" |
Li Chen | f6c209b | 2016-11-28 12:15:33 +0800 | [diff] [blame] | 88 | ) |
| 89 | |
| 90 | if [ $? -ne 0 ]; then |
| 91 | die "Some test cases failed, please check error message..." |
| 92 | fi |
| 93 | } |
| 94 | |
| 95 | main "$@" |