-
Notifications
You must be signed in to change notification settings - Fork 7.8k
ci(tests): Add support for multiple duts #12063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lucasssvaz
wants to merge
1
commit into
master
Choose a base branch
from
ci/multi_dut
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,533
−45
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,90 @@ function clean { | |
| find tests/ -name 'result_*.json' -exec rm -rf "{}" \+ | ||
| } | ||
|
|
||
| # Check if a test is a multi-device test | ||
| function is_multi_device_test { | ||
| local test_dir=$1 | ||
| local has_multi_device | ||
| if [ -f "$test_dir/ci.yml" ]; then | ||
| has_multi_device=$(yq eval '.multi_device' "$test_dir/ci.yml" 2>/dev/null) | ||
| if [[ "$has_multi_device" != "null" && "$has_multi_device" != "" ]]; then | ||
| echo "1" | ||
| return | ||
| fi | ||
| fi | ||
| echo "0" | ||
| } | ||
|
|
||
| # Build a single sketch for multi-device tests | ||
| function build_multi_device_sketch { | ||
| local test_name=$1 | ||
| local sketch_path=$2 | ||
| local target=$3 | ||
| shift 3 | ||
| local build_args=("$@") | ||
| local sketch_dir | ||
| local sketch_name | ||
| local test_dir | ||
| local build_dir | ||
|
|
||
| sketch_dir=$(dirname "$sketch_path") | ||
| sketch_name=$(basename "$sketch_dir") | ||
| test_dir=$(dirname "$sketch_dir") | ||
|
|
||
| # Override build directory to use <test_name>_<sketch_name> pattern | ||
| build_dir="$HOME/.arduino/tests/$target/${test_name}_${sketch_name}/build.tmp" | ||
|
|
||
| echo "Building multi-device sketch $sketch_name for test $test_name" | ||
|
|
||
| # Call sketch_utils.sh build function with custom build directory | ||
| ARDUINO_BUILD_DIR="$build_dir" ${SCRIPTS_DIR}/sketch_utils.sh build "${build_args[@]}" -s "$sketch_dir" | ||
| return $? | ||
| } | ||
|
|
||
| # Build all sketches for a multi-device test | ||
| function build_multi_device_test { | ||
| local test_dir=$1 | ||
| local target=$2 | ||
| shift 2 | ||
| local build_args=("$@") | ||
| local test_name | ||
| local devices | ||
|
|
||
| test_name=$(basename "$test_dir") | ||
|
|
||
| echo "Building multi-device test $test_name" | ||
|
|
||
| # Get the list of devices from ci.yml | ||
| devices=$(yq eval '.multi_device | keys | .[]' "$test_dir/ci.yml" 2>/dev/null) | ||
|
|
||
| if [[ -z "$devices" ]]; then | ||
| echo "ERROR: No devices found in multi_device configuration for $test_name" | ||
| return 1 | ||
| fi | ||
|
|
||
| local result=0 | ||
| local sketch_name | ||
| local sketch_path | ||
| for device in $devices; do | ||
| sketch_name=$(yq eval ".multi_device.$device" "$test_dir/ci.yml" 2>/dev/null) | ||
| sketch_path="$test_dir/$sketch_name/$sketch_name.ino" | ||
|
|
||
| if [ ! -f "$sketch_path" ]; then | ||
| echo "ERROR: Sketch not found: $sketch_path" | ||
| return 1 | ||
| fi | ||
|
|
||
| build_multi_device_sketch "$test_name" "$sketch_path" "$target" "${build_args[@]}" | ||
| result=$? | ||
| if [ $result -ne 0 ]; then | ||
| echo "ERROR: Failed to build sketch $sketch_name for test $test_name" | ||
| return $result | ||
| fi | ||
| done | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
| SCRIPTS_DIR="./.github/scripts" | ||
| BUILD_CMD="" | ||
|
|
||
|
|
@@ -58,10 +142,25 @@ args=("-ai" "$ARDUINO_IDE_PATH" "-au" "$ARDUINO_USR_PATH") | |
|
|
||
| if [[ $test_type == "all" ]] || [[ -z $test_type ]]; then | ||
| if [ -n "$sketch" ]; then | ||
| tmp_sketch_path=$(find tests -name "$sketch".ino) | ||
| test_type=$(basename "$(dirname "$(dirname "$tmp_sketch_path")")") | ||
| # For multi-device tests, we need to find the test directory, not the device sketch directory | ||
| # First, try to find a test directory with this name | ||
| if [ -d "tests/validation/$sketch" ] && [ -f "tests/validation/$sketch/ci.yml" ]; then | ||
| test_type="validation" | ||
| test_folder="$PWD/tests/$test_type" | ||
| elif [ -d "tests/performance/$sketch" ] && [ -f "tests/performance/$sketch/ci.yml" ]; then | ||
| test_type="performance" | ||
| test_folder="$PWD/tests/$test_type" | ||
| else | ||
| # Fall back to finding by .ino file (for regular tests) | ||
| tmp_sketch_path=$(find tests -name "$sketch".ino | head -1) | ||
| if [ -z "$tmp_sketch_path" ]; then | ||
| echo "ERROR: Sketch $sketch not found" | ||
| exit 1 | ||
| fi | ||
| test_type=$(basename "$(dirname "$(dirname "$tmp_sketch_path")")") | ||
| test_folder="$PWD/tests/$test_type" | ||
| fi | ||
| echo "Sketch $sketch test type: $test_type" | ||
| test_folder="$PWD/tests/$test_type" | ||
| else | ||
| test_folder="$PWD/tests" | ||
| fi | ||
|
|
@@ -70,11 +169,86 @@ else | |
| fi | ||
|
|
||
| if [ $chunk_build -eq 1 ]; then | ||
| # For chunk builds, we need to handle multi-device tests separately | ||
| # First, build all multi-device tests, then build regular tests | ||
|
|
||
| # Extract target from remaining arguments | ||
| target="" | ||
| remaining_args=() | ||
| while [ -n "$1" ]; do | ||
| case $1 in | ||
| -t ) | ||
| shift | ||
| target=$1 | ||
| remaining_args+=("-t" "$target") | ||
| ;; | ||
| * ) | ||
| remaining_args+=("$1") | ||
| ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| if [ -z "$target" ]; then | ||
| echo "ERROR: Target (-t) is required for chunk builds" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Find and build all multi-device tests in the test folder | ||
| multi_device_error=0 | ||
| if [ -d "$test_folder" ]; then | ||
| for test_dir in "$test_folder"/*; do | ||
| if [ -d "$test_dir" ] && [ "$(is_multi_device_test "$test_dir")" -eq 1 ]; then | ||
| build_multi_device_test "$test_dir" "$target" "${args[@]}" "${remaining_args[@]}" | ||
| result=$? | ||
| if [ $result -ne 0 ]; then | ||
| multi_device_error=$result | ||
| fi | ||
| fi | ||
| done | ||
| fi | ||
|
|
||
| # Now build regular (non-multi-device) tests using chunk_build | ||
| BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh chunk_build" | ||
| args+=("-p" "$test_folder" "-i" "0" "-m" "1") | ||
| args+=("-p" "$test_folder") | ||
| ${BUILD_CMD} "${args[@]}" "${remaining_args[@]}" | ||
| regular_error=$? | ||
|
|
||
| # Return error if either multi-device or regular builds failed | ||
| if [ $multi_device_error -ne 0 ]; then | ||
| exit $multi_device_error | ||
| fi | ||
| exit $regular_error | ||
| else | ||
| BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build" | ||
| args+=("-s" "$test_folder/$sketch") | ||
| fi | ||
| # Check if this is a multi-device test | ||
| test_dir="$test_folder/$sketch" | ||
| if [ -d "$test_dir" ] && [ "$(is_multi_device_test "$test_dir")" -eq 1 ]; then | ||
| # Extract target from remaining arguments | ||
| target="" | ||
| remaining_args=() | ||
| while [ -n "$1" ]; do | ||
| case $1 in | ||
| -t ) | ||
| shift | ||
| target=$1 | ||
| remaining_args+=("-t" "$target") | ||
| ;; | ||
| * ) | ||
| remaining_args+=("$1") | ||
| ;; | ||
| esac | ||
| shift | ||
| done | ||
|
Comment on lines
+176
to
+241
|
||
|
|
||
| ${BUILD_CMD} "${args[@]}" "$@" | ||
| if [ -z "$target" ]; then | ||
| echo "ERROR: Target (-t) is required for multi-device tests" | ||
| exit 1 | ||
| fi | ||
|
|
||
| build_multi_device_test "$test_dir" "$target" "${args[@]}" "${remaining_args[@]}" | ||
| else | ||
| BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build" | ||
| args+=("-s" "$test_folder/$sketch") | ||
| ${BUILD_CMD} "${args[@]}" "$@" | ||
| fi | ||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on line 408 says "Skip sketches that are part of multi-device tests (they are built separately)" but the conditional check and logic span multiple lines (408-415). The comment placement could be clearer by placing it directly before the
elifstatement on line 409, or by adding it as a block comment explaining the entire section.