Skip to content

Commit 48cc4b7

Browse files
committed
Merge branch 'master' into ci/qemu
2 parents e4d3c58 + e883a2c commit 48cc4b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+9084
-247
lines changed

.flake8

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python/.flake8
22
# See: https://flake8.pycqa.org/en/latest/user/configuration.html
3-
# The code style defined in this file is the official standardized style to be used in all Arduino tooling projects and
4-
# should not be modified.
53

64
[flake8]
75
doctests = True
86
# W503 and W504 are mutually exclusive. PEP 8 recommends line break before.
97
ignore = W503,E203
10-
max-complexity = 10
8+
max-complexity = 20
119
max-line-length = 120
1210
select = E,W,F,C,N

.github/scripts/sketch_utils.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
121121
fi
122122

123123
if [ -z "$fqbn" ]; then
124-
echo "No FQBN passed or unvalid chip: $target"
124+
echo "No FQBN passed or invalid chip: $target"
125125
exit 1
126126
fi
127127

@@ -365,6 +365,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
365365
start_index=$(( $chunk_index * $chunk_size ))
366366
if [ "$sketchcount" -le "$start_index" ]; then
367367
echo "Skipping job"
368+
touch ~/.build_skipped
368369
return 0
369370
fi
370371

.github/scripts/tests_build.sh

+25-7
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
USAGE="
44
USAGE:
5-
${0} -c <chunk_build_opts>
6-
Example: ${0} -c -t esp32 -i 0 -m 15
5+
${0} -c -type <test_type> <chunk_build_opts>
6+
Example: ${0} -c -type validation -t esp32 -i 0 -m 15
77
${0} -s sketch_name <build_opts>
88
Example: ${0} -s hello_world -t esp32
99
${0} -clean
1010
Remove build and test generated files
1111
"
1212

1313
function clean(){
14-
rm -rf tests/*/build*/
1514
rm -rf tests/.pytest_cache
16-
rm -rf tests/*/__pycache__/
17-
rm -rf tests/*/*.xml
15+
find tests/ -type d -name 'build*' -exec rm -rf "{}" \+
16+
find tests/ -type d -name '__pycache__' -exec rm -rf "{}" \+
17+
find tests/ -name '*.xml' -exec rm -rf "{}" \+
18+
find tests/ -name 'result_*.json' -exec rm -rf "{}" \+
1819
}
1920

2021
SCRIPTS_DIR="./.github/scripts"
@@ -35,6 +36,10 @@ while [ ! -z "$1" ]; do
3536
echo "$USAGE"
3637
exit 0
3738
;;
39+
-type )
40+
shift
41+
test_type=$1
42+
;;
3843
-clean )
3944
clean
4045
exit 0
@@ -52,12 +57,25 @@ source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
5257

5358
args="-ai $ARDUINO_IDE_PATH -au $ARDUINO_USR_PATH"
5459

60+
if [[ $test_type == "all" ]] || [[ -z $test_type ]]; then
61+
if [ -n "$sketch" ]; then
62+
tmp_sketch_path=$(find tests -name $sketch.ino)
63+
test_type=$(basename $(dirname $(dirname "$tmp_sketch_path")))
64+
echo "Sketch $sketch test type: $test_type"
65+
test_folder="$PWD/tests/$test_type"
66+
else
67+
test_folder="$PWD/tests"
68+
fi
69+
else
70+
test_folder="$PWD/tests/$test_type"
71+
fi
72+
5573
if [ $chunk_build -eq 1 ]; then
5674
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh chunk_build"
57-
args+=" -p $PWD/tests"
75+
args+=" -p $test_folder"
5876
else
5977
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build"
60-
args+=" -s $PWD/tests/$sketch"
78+
args+=" -s $test_folder/$sketch"
6179
fi
6280

6381
${BUILD_CMD} ${args} $*

.github/scripts/tests_run.sh

+44-10
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ function run_test() {
2020
fi
2121

2222
if [ $len -eq 1 ]; then
23-
# build_dir="tests/$sketchname/build"
23+
# build_dir="$sketchdir/build"
2424
build_dir="$HOME/.arduino/tests/$sketchname/build.tmp"
25-
report_file="tests/$sketchname/$sketchname.xml"
25+
report_file="$sketchdir/$sketchname.xml"
2626
fi
2727

2828
for i in `seq 0 $(($len - 1))`
@@ -33,12 +33,17 @@ function run_test() {
3333
fi
3434

3535
if [ $len -ne 1 ]; then
36-
# build_dir="tests/$sketchname/build$i"
36+
# build_dir="$sketchdir/build$i"
3737
build_dir="$HOME/.arduino/tests/$sketchname/build$i.tmp"
38-
report_file="tests/$sketchname/$sketchname$i.xml"
38+
report_file="$sketchdir/$sketchname$i.xml"
3939
fi
4040

41-
if [ $platform == "qemu" ]; then
41+
if [ $platform == "wokwi" ]; then
42+
extra_args="--target $target --embedded-services arduino,wokwi --wokwi-timeout=$wokwi_timeout"
43+
if [[ -f "$sketchdir/scenario.yaml" ]]; then
44+
extra_args+=" --wokwi-scenario $sketchdir/scenario.yaml"
45+
fi
46+
elif [ $platform == "qemu" ]; then
4247
PATH=$HOME/qemu/bin:$PATH
4348
extra_args="--embedded-services qemu --qemu-image-path $build_dir/$sketchname.ino.merged.bin"
4449

@@ -67,6 +72,7 @@ SCRIPTS_DIR="./.github/scripts"
6772
COUNT_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh count"
6873

6974
platform="hardware"
75+
wokwi_timeout=60000
7076
chunk_run=0
7177
options=0
7278
erase=0
@@ -83,6 +89,11 @@ while [ ! -z "$1" ]; do
8389
fi
8490
platform="qemu"
8591
;;
92+
-w )
93+
shift
94+
wokwi_timeout=$1
95+
platform="wokwi"
96+
;;
8697
-o )
8798
options=1
8899
;;
@@ -109,6 +120,10 @@ while [ ! -z "$1" ]; do
109120
echo "$USAGE"
110121
exit 0
111122
;;
123+
-type )
124+
shift
125+
test_type=$1
126+
;;
112127
* )
113128
break
114129
;;
@@ -120,21 +135,39 @@ if [ ! $platform == "qemu" ]; then
120135
source ${SCRIPTS_DIR}/install-arduino-ide.sh
121136
fi
122137

138+
# If sketch is provided and test type is not, test type is inferred from the sketch path
139+
if [[ $test_type == "all" ]] || [[ -z $test_type ]]; then
140+
if [ -n "$sketch" ]; then
141+
tmp_sketch_path=$(find tests -name $sketch.ino)
142+
test_type=$(basename $(dirname $(dirname "$tmp_sketch_path")))
143+
echo "Sketch $sketch test type: $test_type"
144+
test_folder="$PWD/tests/$test_type"
145+
else
146+
test_folder="$PWD/tests"
147+
fi
148+
else
149+
test_folder="$PWD/tests/$test_type"
150+
fi
151+
123152
if [ $chunk_run -eq 0 ]; then
124-
run_test $target $PWD/tests/$sketch/$sketch.ino $options $erase
153+
if [ -z $sketch ]; then
154+
echo "ERROR: Sketch name is required for single test run"
155+
exit 1
156+
fi
157+
run_test $target $test_folder/$sketch/$sketch.ino $options $erase
125158
else
126159
if [ "$chunk_max" -le 0 ]; then
127160
echo "ERROR: Chunks count must be positive number"
128-
return 1
161+
exit 1
129162
fi
130163

131164
if [ "$chunk_index" -ge "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then
132165
echo "ERROR: Chunk index must be less than chunks count"
133-
return 1
166+
exit 1
134167
fi
135168

136169
set +e
137-
${COUNT_SKETCHES} $PWD/tests $target
170+
${COUNT_SKETCHES} $test_folder $target
138171
sketchcount=$?
139172
set -e
140173
sketches=$(cat sketches.txt)
@@ -155,7 +188,8 @@ else
155188
start_index=$(( $chunk_index * $chunk_size ))
156189
if [ "$sketchcount" -le "$start_index" ]; then
157190
echo "Skipping job"
158-
return 0
191+
touch ~/.test_skipped
192+
exit 0
159193
fi
160194

161195
end_index=$(( $(( $chunk_index + 1 )) * $chunk_size ))

0 commit comments

Comments
 (0)