Home | History | Annotate | Download | only in tests
      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.
     17 SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
     18 source ${SCRIPT_DIR}/common.sh
     19 
     20 OUT_DATA_DIR="test_out"
     21 
     22 DEBUG=false
     23 
     24 
     25 apply_overlay() {
     26   local overaly="$1"
     27   local base_dts="$2"
     28   local overlay_dts="$3"
     29   local merged_dts="$4"
     30 
     31   ./apply_overlay.sh "--$overaly" "$base_dts" "$overlay_dts" "$merged_dts"
     32 }
     33 
     34 run_stress_test() {
     35   # see ufdt_gen_test_dts.c for detail
     36   local node_depth="$1"
     37   local node_unused="$2"
     38   local node_count="$3"
     39   local append_count="$4"
     40   local override_count="$5"
     41 
     42   mkdir -p "$OUT_DATA_DIR" >& /dev/null
     43 
     44   #
     45   # Prepare dtb and dtbo files
     46   #
     47   local base_dts="${OUT_DATA_DIR}/base.dts"
     48   echo "  Base DT: depth=$node_depth unused=$node_unused nodes=$node_count"
     49   ufdt_gen_test_dts -n $node_count -d $node_depth -u $node_unused \
     50     -o "$base_dts"
     51   if $DEBUG; then
     52     cat "$base_dts"
     53   fi
     54 
     55   local overlay_dts="${OUT_DATA_DIR}/overlay.dts"
     56   echo "  Overlay DT: append=$append_count override=$override_count"
     57   ufdt_gen_test_dts -p -a $append_count -w $override_count \
     58     -o "$overlay_dts"
     59   if $DEBUG; then
     60     cat "$overlay_dts"
     61   fi
     62 
     63   local merged_dts="${OUT_DATA_DIR}/overlay_merged.dts"
     64   apply_overlay ufdt $base_dts $overlay_dts $merged_dts
     65 
     66   rm -rf "$OUT_DATA_DIR"
     67 }
     68 
     69 main() {
     70   alert "========== Running Stress Tests =========="
     71 
     72   if [ -z "$ANDROID_BUILD_TOP" ]; then
     73     die "Run envsetup.sh / lunch yet?"
     74   fi
     75 
     76   if ! command_exists ufdt_gen_test_dts ||
     77      ! command_exists dtc; then
     78     die "Run mmma $(dirname $SCRIPT_DIR) yet?"
     79   fi
     80 
     81   (
     82 
     83   # cd to ${SCRIPT_DIR} in a subshell because gen_test.sh uses relative
     84   # paths for dependent files.
     85   cd "${SCRIPT_DIR}"
     86 
     87   # node_depth      = 2
     88   # node_unused     = 0
     89   # node_count      = 5000
     90   # append_count    = 2500
     91   # override_count  = 2500
     92   run_stress_test 2 0 5000 2500 2500
     93 
     94   )
     95 
     96   if [ $? -ne 0 ]; then
     97     die "Some test cases failed, please check error message..."
     98   fi
     99 }
    100 
    101 main "$@"
    102