Skip to content

Commit

Permalink
tweak(infra): use arduino-cli instead of platformio in test-avr-size.…
Browse files Browse the repository at this point in the history
…sh, run it in CI
  • Loading branch information
evgenykochetkov committed Oct 20, 2020
1 parent 8cda893 commit f377cdc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,18 @@ jobs:
docker: *docker-custom-nodejs
environment:
XOD_OUTPUT: /tmp/tabtests-cpp
XOD_ARDUINO_CLI: /tmp/arduino-cli/arduino-cli
steps:
- checkout
- restore_cache: *restore-node_modules
- run: *step-install
- run: *step-install-arduino-cli-on-linux
- run:
name: Install arduino:avr platform for arduino-cli
command: $XOD_ARDUINO_CLI core install arduino:avr
- run:
name: Test AVR Size
command: ./packages/xod-arduino/tools/test-avr-size.sh
- run:
name: Build CLI
command: yarn build:cli
Expand Down
39 changes: 13 additions & 26 deletions packages/xod-arduino/tools/test-avr-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,27 @@ set -e

echo "Testing size of fixtures compiled for AVR platform..."

ARDUINO_CLI=${XOD_ARDUINO_CLI:-"arduino-cli"}

SELF_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

WS_DIR="$SELF_DIR/../../../workspace"
BUILD_DIR="$SELF_DIR/../.pio-build"

AVR_SIZE=~/.platformio/packages/toolchain-atmelavr/bin/avr-size

mkdir -p $BUILD_DIR

test_size () {
echo "$1..."

platformio ci \
--board=uno \
--build-dir=$BUILD_DIR \
--keep-build-dir \
--project-option="lib_extra_dirs = $WS_DIR/__ardulib__" \
--verbose \
$WS_DIR/$1/__fixtures__/arduino.cpp \
> /dev/null
BUILD_DIR="/tmp/test-avr-size/$1"

AVR_SIZE_OUTPUT=$($AVR_SIZE -d -C --mcu=atmega328p $BUILD_DIR/.pioenvs/uno/firmware.elf)
EXPECTED_OUTPUT="\
AVR Memory Usage
----------------
Device: atmega328p
mkdir -p $BUILD_DIR
cp $WS_DIR/$1/__fixtures__/arduino.cpp $BUILD_DIR/$1.ino

Program:$2
(.text + .data + .bootloader)
SIZE_OUTPUT=$($ARDUINO_CLI compile --fqbn arduino:avr:uno --libraries $WS_DIR/__ardulib__ $BUILD_DIR)

Data:$3
(.data + .bss + .noinit)"
EXPECTED_OUTPUT="\
Sketch uses $2 of program storage space. Maximum is 32256 bytes.
Global variables use $3 of dynamic memory, leaving $4 bytes for local variables. Maximum is 2048 bytes."

if [[ $AVR_SIZE_OUTPUT =~ "$EXPECTED_OUTPUT" ]]; then
if [[ $SIZE_OUTPUT =~ "$EXPECTED_OUTPUT" ]]; then
echo "+ OK"
else
echo "- FAIL"
Expand All @@ -48,7 +35,7 @@ Data:$3
echo
echo "Actual ======================================================="
echo
echo "$AVR_SIZE_OUTPUT"
echo "$SIZE_OUTPUT"
echo
echo "If the size became better, fix expectation in"
echo "packages/xod-arduino/tools/test-avr-size.sh script,"
Expand All @@ -57,5 +44,5 @@ Data:$3
fi
}

test_size "blink" " 1556 bytes (4.7% Full)" " 28 bytes (1.4% Full)"
test_size "big-patch" " 25588 bytes (78.1% Full)" " 909 bytes (44.4% Full)"
test_size "blink" "1444 bytes (4%)" "25 bytes (1%)" "2023"
test_size "big-patch" "25456 bytes (78%)" "877 bytes (42%)" "1171"

0 comments on commit f377cdc

Please sign in to comment.