[companion] Adjust GVAR not possible in global functions (fix #5425)
[opentx.git] / tools / commit-tests.sh
blob251a59f5630ecba3d4a60375969dcdc55a510f2c
1 #!/bin/bash
3 # Stops on first error, echo on
4 set -e
5 set -x
7 # Allow variable core usage, default uses two cores, to set 8 cores for example : commit-tests.sh -j8
8 : ${CORES:=2}
9 # Default build treats warnings as errors, set -Wno-error to override, e.g.: commit-tests.sh -Wno-error
10 : ${WERROR:=1}
11 # A board name to build for, or ALL
12 : ${FLAVOR:=ALL}
14 for i in "$@"
16 case $i in
17 --jobs=*)
18 CORES="${i#*=}"
19 shift
21 -j*)
22 CORES="${i#*j}"
23 shift
25 -Wno-error)
26 WERROR=0
27 shift
29 -b*)
30 FLAVOR="${i#*b}"
31 shift
33 esac
34 done
36 if [ "$(uname)" = "Darwin" ]; then
37 SCRIPT=$(python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' "$0")
38 else
39 SCRIPT=$(readlink -f "$0")
42 if [[ ! -z ${GCC_ARM} ]] ; then
43 export PATH=${GCC_ARM}:$PATH
46 : ${SRCDIR:=$(dirname "$SCRIPT")/..}
48 : ${COMMON_OPTIONS:="-DCMAKE_BUILD_TYPE=Debug -DTRACE_SIMPGMSPACE=NO -DVERBOSE_CMAKELISTS=YES -DCMAKE_RULE_MESSAGES=OFF -Wno-dev"}
49 if (( $WERROR )); then COMMON_OPTIONS+=" -DWARNINGS_AS_ERRORS=YES"; fi
51 : ${EXTRA_OPTIONS:="$EXTRA_OPTIONS"}
53 COMMON_OPTIONS+=${EXTRA_OPTIONS}
55 : ${TEST_OPTIONS:="--gtest_shuffle --gtest_repeat=5 --gtest_break_on_failure"}
57 : ${FIRMARE_TARGET:="firmware-size"}
59 mkdir build || true
60 cd build
62 if [[ " 9X AVR9X ALL " =~ " ${FLAVOR} " ]] ; then
63 # OpenTX on 9X stock with FrSky telemetry
64 rm -rf *
65 cmake ${COMMON_OPTIONS} -DPCB=9X -DHELI=YES -DTEMPLATES=YES -DGVARS=YES -DTELEMETRY=FRSKY ${SRCDIR}
66 make -j${CORES} ${FIRMARE_TARGET}
67 make -j${CORES} libsimulator
68 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
70 # OpenTX on 9X stock with Ardupilot telemetry
71 rm -rf *
72 cmake ${COMMON_OPTIONS} -DPCB=9X -DHELI=YES -DTEMPLATES=YES -DGVARS=YES -DTELEMETRY=ARDUPILOT ${SRCDIR}
73 make -j${CORES} ${FIRMARE_TARGET}
75 # OpenTX on 9X stock with JETI telemetry
76 rm -rf *
77 cmake ${COMMON_OPTIONS} -DPCB=9X -DHELI=YES -DTEMPLATES=YES -DGVARS=YES -DTELEMETRY=JETI ${SRCDIR}
78 make -j${CORES} ${FIRMARE_TARGET}
81 if [[ " MEGA2560 AVR9X ALL " =~ " ${FLAVOR} " ]] ; then
82 # OpenTX on Mega2560
83 rm -rf *
84 cmake ${COMMON_OPTIONS} -DPCB=MEGA2560 -DTEMPLATES=YES -DGVARS=YES -DHELI=YES ${SRCDIR}
85 make -j${CORES} ${FIRMARE_TARGET}
86 make -j${CORES} libsimulator
87 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
89 # OpenTX on Mega2560 with Mavlink telemetry
90 rm -rf *
91 cmake ${COMMON_OPTIONS} -DPCB=MEGA2560 -DTELEMETRY=MAVLINK -DHELI=YES -DTEMPLATES=YES -DAUDIO=YES -DVOICE=YES -DGVARS=YES ${SRCDIR}
92 make -j${CORES} ${FIRMARE_TARGET}
93 make -j${CORES} libsimulator
94 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
97 if [[ " GRUVIN9X AVR9X ALL " =~ " ${FLAVOR} " ]] ; then
98 # OpenTX on gruvin9x board
99 rm -rf *
100 cmake ${COMMON_OPTIONS} -DPCB=GRUVIN9X -DHELI=YES -DTEMPLATES=YES -DAUDIO=YES -DVOICE=YES -DGVARS=YES ${SRCDIR}
101 make -j${CORES} ${FIRMARE_TARGET}
102 make -j${CORES} libsimulator
103 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
106 if [[ " SKY9X ARM9X ALL " =~ " ${FLAVOR} " ]] ; then
107 # OpenTX on Sky9x
108 rm -rf *
109 cmake ${COMMON_OPTIONS} -DPCB=SKY9X -DHELI=YES DLUA=YES -DMULTIMODULE=YES -DTELEMETRY=FRSKY -DPPM_LIMITS_SYMETRICAL=YES -DVARIO=YES -DGAUGES=YES -DAUTOSWITCH=YES -DAUTOSOURCE=YES -DAUDIO=YES -DGPS=YES -DPPM_CENTER_ADJUSTABLE=YES -DFLIGHT_MODES=YES -DOVERRIDE_CHANNEL_FUNCTION=YES -DFRSKY_STICKS=YES -DGVARS=YES ${SRCDIR}
110 make -j${CORES} ${FIRMARE_TARGET}
111 make -j${CORES} libsimulator
112 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
115 if [[ " AR9X ARM9X ALL " =~ " ${FLAVOR} " ]] ; then
116 # OpenTX on AR9X
117 rm -rf *
118 cmake ${COMMON_OPTIONS} -DPCB=AR9X -DHELI=YES -DGVARS=YES ${SRCDIR}
119 make -j${CORES} ${FIRMARE_TARGET}
120 make -j${CORES} libsimulator
121 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
124 if [[ " 9XRPRO ARM9X ALL " =~ " ${FLAVOR} " ]] ; then
125 # OpenTX on Sky9x
126 rm -rf *
127 cmake ${COMMON_OPTIONS} -DPCB=9XRPRO -DHELI=YES -DGVARS=YES ${SRCDIR}
128 make -j${CORES} ${FIRMARE_TARGET}
129 make -j${CORES} libsimulator
130 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
133 if [[ " X7 ALL " =~ " ${FLAVOR} " ]] ; then
134 # OpenTX on X7
135 rm -rf *
136 cmake ${COMMON_OPTIONS} -DPCB=X7 -DHELI=YES -DGVARS=YES ${SRCDIR}
137 make -j${CORES} ${FIRMARE_TARGET}
138 make -j${CORES} libsimulator
139 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
142 if [[ " X9D X9 ALL " =~ " ${FLAVOR} " ]] ; then
143 # OpenTX on X9D
144 rm -rf *
145 cmake ${COMMON_OPTIONS} -DPCB=X9D -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
146 make -j${CORES} ${FIRMARE_TARGET}
147 make -j${CORES} libsimulator
148 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
151 if [[ " X9D+ X9 ALL " =~ " ${FLAVOR} " ]] ; then
152 # OpenTX on X9D+
153 rm -rf *
154 cmake ${COMMON_OPTIONS} -DPCB=X9D+ -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
155 make -j${CORES} ${FIRMARE_TARGET}
156 make -j${CORES} libsimulator
157 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
160 if [[ " X9E X9 ALL " =~ " ${FLAVOR} " ]] ; then
161 # OpenTX on Taranis X9E
162 rm -rf *
163 cmake ${COMMON_OPTIONS} -DPCB=X9E -DHELI=YES -DLUA=YES -DGVARS=YES -DPPM_UNIT=PERCENT_PREC1 ${SRCDIR}
164 make -j${CORES} ${FIRMARE_TARGET}
165 make -j${CORES} libsimulator
166 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
169 if [[ " X10 HORUS ALL " =~ " ${FLAVOR} " ]] ; then
170 # OpenTX on X10 boards
171 rm -rf *
172 cmake ${COMMON_OPTIONS} -DPCB=X10 -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
173 make -j${CORES} ${FIRMARE_TARGET}
174 make -j${CORES} libsimulator
175 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
178 if [[ " X12Sr10 HORUS ALL " =~ " ${FLAVOR} " ]] ; then
179 # OpenTX on Horus beta boards
180 rm -rf *
181 cmake ${COMMON_OPTIONS} -DPCB=X12S -DPCBREV=10 -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
182 make -j${CORES} ${FIRMARE_TARGET}
183 make -j${CORES} libsimulator
184 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
187 if [[ " X12S HORUS ALL " =~ " ${FLAVOR} " ]] ; then
188 # OpenTX on Horus
189 rm -rf *
190 cmake ${COMMON_OPTIONS} -DPCB=X12S -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
191 make -j${CORES} ${FIRMARE_TARGET}
192 make -j${CORES} libsimulator
193 make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
196 if [[ " DEFAULT ALL " =~ " ${FLAVOR} " ]] ; then
197 # Companion
198 rm -rf *
199 cmake ${COMMON_OPTIONS} ${SRCDIR}
200 make -j${CORES}