|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +root=$(git rev-parse --show-toplevel) |
| 4 | +source "$root/tests/env.sh" |
| 5 | + |
| 6 | +unset -f step_summary |
| 7 | +function step_summary() |
| 8 | +{ |
| 9 | + echo "" |
| 10 | +} |
| 11 | + |
| 12 | +export ARDUINO_BUILD_CACHE_PATH="$cache_dir" |
| 13 | + |
| 14 | +sketches="${cache_dir}/sketches/" |
| 15 | +cores="${cache_dir}/cores/" |
| 16 | + |
| 17 | +esp8266_dir="${ESP8266_ARDUINO_BUILD_DIR}" |
| 18 | +commonfileh="${esp8266_dir}/cores/esp8266/CommonHFile.h" |
| 19 | + |
| 20 | +tests_dir="$root/tests/test_mkbuildoptglobals" |
| 21 | +tests=$(ls -1 "$tests_dir" | sed 's/.sh$//g') |
| 22 | + |
| 23 | +function name_size_mtime() |
| 24 | +{ |
| 25 | + stat --printf '%n:%s:%Y' "$1" |
| 26 | +} |
| 27 | + |
| 28 | +function most_recent_file() |
| 29 | +{ |
| 30 | + local name="$1" |
| 31 | + local location="$2" |
| 32 | + echo $(readlink -f "${location}/"$(ls -t1 "${location}" | grep "$name" | head -1)) |
| 33 | +} |
| 34 | + |
| 35 | +function most_recent_dir() |
| 36 | +{ |
| 37 | + local location="$1" |
| 38 | + echo $(readlink -f "${location}/"$(ls -t1 "$location" | head -1)) |
| 39 | +} |
| 40 | + |
| 41 | +function assert_build() |
| 42 | +{ |
| 43 | + local name="$1" |
| 44 | + local build_dir="$2" |
| 45 | + local size_check="${3:-0}" |
| 46 | + |
| 47 | + local build_opt="$build_dir"/sketch/build.opt |
| 48 | + test -e "$build_opt" |
| 49 | + |
| 50 | + local globals_h="$build_dir"/${name}.ino.globals.h |
| 51 | + test -e "$globals_h" |
| 52 | + |
| 53 | + if [ "$size_check" = "1" ] ; then |
| 54 | + test -s "$build_opt" |
| 55 | + test -s "$globals_h" |
| 56 | + fi |
| 57 | +} |
| 58 | + |
| 59 | +function assert_core() |
| 60 | +{ |
| 61 | + local size_check="$1" |
| 62 | + |
| 63 | + if [ "$size_check" = "1" ] ; then |
| 64 | + test -s "$commonfileh" |
| 65 | + else |
| 66 | + test ! -s "$commonfileh" |
| 67 | + fi |
| 68 | + |
| 69 | +} |
| 70 | + |
| 71 | +function build_esp8266_example() |
| 72 | +{ |
| 73 | + local name="$1" |
| 74 | + |
| 75 | + ESP8266_ARDUINO_SKETCHES="$root/libraries/esp8266/examples/${name}/${name}.ino" |
| 76 | + build_sketches_with_arduino "$ESP8266_ARDUINO_LWIP" "$mod" "$rem" "$cnt" |
| 77 | +} |
| 78 | + |
| 79 | +function make_commonh_stat() |
| 80 | +{ |
| 81 | + local stat=$(name_size_mtime "$commonfileh") |
| 82 | + test -n "$stat" |
| 83 | + |
| 84 | + echo "$stat" |
| 85 | +} |
| 86 | + |
| 87 | +function make_core_stat() |
| 88 | +{ |
| 89 | + local recent_core=$(most_recent_dir "$cores") |
| 90 | + local recent_file=$(most_recent_file "core.a" "$recent_core") |
| 91 | + |
| 92 | + local stat=$(name_size_mtime "$recent_file") |
| 93 | + test -n "$stat" |
| 94 | + |
| 95 | + echo "$stat" |
| 96 | +} |
| 97 | + |
| 98 | +case "${1:-}" in |
| 99 | +"list") |
| 100 | + printf "%s\n" $tests |
| 101 | + ;; |
| 102 | + |
| 103 | +"run") |
| 104 | + for test in $tests ; do |
| 105 | + printf "Checking \"%s\"\n" "$test" |
| 106 | + /usr/bin/env bash $root/tests/test_mkbuildoptglobals.sh $test |
| 107 | + done |
| 108 | + ;; |
| 109 | +*) |
| 110 | + source "$tests_dir/${1}.sh" |
| 111 | + ;; |
| 112 | +esac |
0 commit comments