1#!/bin/bash 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. 15 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 || 46 ! command_exists fdt_apply_overlay || 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 \ 64 "local_fixup" \ 65 "Run test about fdt_overlay_do_local_fixups" 66 run_test_case \ 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" 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" 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" 85 run_test_case \ 86 "suffix_compress" \ 87 "Run test about string suffix compression" 88 ) 89 90 if [ $? -ne 0 ]; then 91 die "Some test cases failed, please check error message..." 92 fi 93} 94 95main "$@" 96