Skip to content
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

Test fixes #618

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
build-cli
/.project
build-*
.tags
10 changes: 8 additions & 2 deletions Common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@ $(call show_config_variable,CURRENT_OS,[AUTODETECTED])
ifneq ($(TEST),)
DEPENDENCIES_DIR = /var/tmp/Arduino-Makefile-testing-dependencies

DEPENDENCIES_MPIDE_DIR = $(DEPENDENCIES_DIR)/mpide-0023-linux64-20130817-test
DEPENDENCIES_MPIDE_DIR = $(shell find $(DEPENDENCIES_DIR) -name 'mpide-0023-*' -type d -exec ls -dt {} + | head -n 1)
ifeq ($(MPIDE_DIR),)
MPIDE_DIR = $(DEPENDENCIES_MPIDE_DIR)
endif

DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/arduino-1.0.6
ifeq ($(CURRENT_OS),MAC)
IDE_DIRNAME=Arduino.app/Contents/Resources/Java
else
IDE_DIRNAME=arduino-1.0.6
endif

DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/$(IDE_DIRNAME)
ifeq ($(ARDUINO_DIR),)
ARDUINO_DIR = $(DEPENDENCIES_ARDUINO_DIR)
endif
Expand Down
17 changes: 16 additions & 1 deletion tests/script/bootstrap/arduino.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then
echo "Installing Arduino..."

ARDUINO_BASENAME="arduino-1.0.6"

if [ $OS == "cygwin" ]; then
ARDUINO_FILE="$ARDUINO_BASENAME-windows".zip
EXTRACT_COMMAND="unzip -q"
Expand All @@ -20,13 +21,27 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then
EXTRACT_COMMAND="tar -xzf"
fi

ARDUINO_URL=http://arduino.cc/download.php?f=/$ARDUINO_FILE
ARDUINO_URL=https://downloads.arduino.cc/$ARDUINO_FILE

_pushd $DEPENDENCIES_FOLDER
if ! test -e $ARDUINO_FILE
then
echo "Downloading Arduino IDE..."
download $ARDUINO_URL $ARDUINO_FILE

download_type="$(file --mime-type $DEPENDENCIES_FOLDER/$ARDUINO_FILE)"
if [[ ! "$download_type" =~ zip ]]; then
mv $ARDUINO_FILE "bad-$ARDUINO_FILE"

echo
echo "[ERROR] Unable to download valid IDE for testing"
echo " Downloaded file should be a zip but is: ${download_type##* }."
echo
echo " Download the IDE manually then try again."
echo " Download from: https://www.arduino.cc/en/Main/Software"
echo " Save to : $DEPENDENCIES_FOLDER"
exit 1
fi
fi

if ! test -d $ARDUINO_BASENAME
Expand Down
2 changes: 1 addition & 1 deletion tests/script/bootstrap/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ if [ -z $COMMON_SOURCED ]; then
PIP_SUDO_CMD=$SUDO_CMD
fi

$PIP_SUDO_CMD pip install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt
$PIP_SUDO_CMD pip install --ignore-installed --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt

COMMON_SOURCED=1
fi
68 changes: 50 additions & 18 deletions tests/script/runtests.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
#!/usr/bin/env bash

SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TESTS_DIR=examples

failures=()

if [[ "$1" == "-q" ]]; then
QUIET=1
fi

runtest() {
if [[ $QUIET ]]; then
make $* TEST=1 > /dev/null 2>&1
else
output=`make $* TEST=1`
fi
}

run() {
if [[ $QUIET ]]; then
"$@" > /dev/null 2>&1
else
"$@"
fi
}

info() {
if [[ $QUIET ]]; then
return
fi

echo "$@"
}

run pushd $SCRIPTS_DIR/../..

# These examples cannot be tested easily at the moment as they require
# alternate cores. The MakefileExample doesn't actually contain any source code
# to compile.
Expand All @@ -22,46 +53,47 @@ do
done

if ! $example_is_testable; then
echo "Skipping non-testable example $example..."
info "Skipping non-testable example $example..."
continue
fi

pushd $dir
echo "Compiling $example..."
make_output=`make clean TEST=1`
make_output=`make TEST=1`
run pushd $dir
info "Compiling $example..."
runtest clean
runtest

if [[ $? -ne 0 ]]; then
failures+=("$example")
echo "Example $example failed"
info "Example $example failed"
fi

make_output=`make disasm TEST=1`
runtest disasm
if [[ $? -ne 0 ]]; then
failures+=("$example disasm")
echo "Example $example disasm failed"
info "Example $example disasm failed"
fi

make_output=`make generate_assembly TEST=1`
runtest generate_assembly
if [[ $? -ne 0 ]]; then
failures+=("$example generate_assembly")
echo "Example $example generate_assembly failed"
info "Example $example generate_assembly failed"
fi

make_output=`make symbol_sizes TEST=1`
runtest symbol_sizes
if [[ $? -ne 0 ]]; then
failures+=("$example symbol_sizes")
echo "Example $example symbol_sizes failed"
info "Example $example symbol_sizes failed"
fi

popd
done

for failure in "${failures[@]}"; do
echo "Example $failure failed"
run popd
done

if [[ ${#failures[@]} -eq 0 ]]; then
echo "All tests passed."
else
exit 1
for failure in "${failures[@]}"; do
echo "Example $failure failed"
done

exit 1
fi