diff options
Diffstat (limited to 'tests')
28 files changed, 354 insertions, 622 deletions
diff --git a/tests/AnalogInOutSerial/AnalogInOutSerial.ino b/tests/AnalogInOutSerial/AnalogInOutSerial.ino deleted file mode 100644 index e142f69..0000000 --- a/tests/AnalogInOutSerial/AnalogInOutSerial.ino +++ /dev/null @@ -1,53 +0,0 @@ -/* - Analog input, analog output, serial output - - Reads an analog input pin, maps the result to a range from 0 to 255 - and uses the result to set the pulsewidth modulation (PWM) of an output pin. - Also prints the results to the serial monitor. - - The circuit: - * potentiometer connected to analog pin 0. - Center pin of the potentiometer goes to the analog pin. - side pins of the potentiometer go to +5V and ground - * LED connected from digital pin 9 to ground - - created 29 Dec. 2008 - modified 30 Aug 2011 - by Tom Igoe - - This example code is in the public domain. - - */ - -// These constants won't change. They're used to give names -// to the pins used: -const int analogInPin = A0; // Analog input pin that the potentiometer is attached to -const int analogOutPin = 9; // Analog output pin that the LED is attached to - -int sensorValue = 0; // value read from the pot -int outputValue = 0; // value output to the PWM (analog out) - -void setup() { - // initialize serial communications at 9600 bps: - Serial.begin(9600); -} - -void loop() { - // read the analog in value: - sensorValue = analogRead(analogInPin); - // map it to the range of the analog out: - outputValue = map(sensorValue, 0, 1023, 0, 255); - // change the analog out value: - analogWrite(analogOutPin, outputValue); - - // print the results to the serial monitor: - Serial.print("sensor = " ); - Serial.print(sensorValue); - Serial.print("\t output = "); - Serial.println(outputValue); - - // wait 10 milliseconds before the next loop - // for the analog-to-digital converter to settle - // after the last reading: - delay(10); -} diff --git a/tests/AnalogInOutSerial/Makefile b/tests/AnalogInOutSerial/Makefile deleted file mode 100644 index 872d069..0000000 --- a/tests/AnalogInOutSerial/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../TestSuiteCommon.mk -include ../../Arduino.mk diff --git a/tests/Blink/Blink.ino b/tests/Blink/Blink.ino deleted file mode 100644 index 1953c39..0000000 --- a/tests/Blink/Blink.ino +++ /dev/null @@ -1,19 +0,0 @@ -/* - Blink - Turns on an LED on for one second, then off for one second, repeatedly. - - This example code is in the public domain. - */ - -void setup() { - // initialize the digital pin as an output. - // Pin 13 has an LED connected on most Arduino boards: - pinMode(13, OUTPUT); -} - -void loop() { - digitalWrite(13, HIGH); // set the LED on - delay(1000); // wait for a second - digitalWrite(13, LOW); // set the LED off - delay(1000); // wait for a second -} diff --git a/tests/Blink/Makefile b/tests/Blink/Makefile deleted file mode 100644 index d41effa..0000000 --- a/tests/Blink/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../TestSuiteCommon.mk -include ../../Arduino.mk - diff --git a/tests/BlinkChipKIT/BlinkChipKIT.pde b/tests/BlinkChipKIT/BlinkChipKIT.pde deleted file mode 100644 index 1953c39..0000000 --- a/tests/BlinkChipKIT/BlinkChipKIT.pde +++ /dev/null @@ -1,19 +0,0 @@ -/* - Blink - Turns on an LED on for one second, then off for one second, repeatedly. - - This example code is in the public domain. - */ - -void setup() { - // initialize the digital pin as an output. - // Pin 13 has an LED connected on most Arduino boards: - pinMode(13, OUTPUT); -} - -void loop() { - digitalWrite(13, HIGH); // set the LED on - delay(1000); // wait for a second - digitalWrite(13, LOW); // set the LED off - delay(1000); // wait for a second -} diff --git a/tests/BlinkChipKIT/Makefile b/tests/BlinkChipKIT/Makefile deleted file mode 100644 index bec2794..0000000 --- a/tests/BlinkChipKIT/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -BOARD_TAG = mega_pic32 -ARDUINO_LIBS = - -include ../TestSuiteCommon.mk -include ../../chipKIT.mk - diff --git a/tests/BlinkInAVRC/Makefile b/tests/BlinkInAVRC/Makefile deleted file mode 100644 index 9080b24..0000000 --- a/tests/BlinkInAVRC/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# This sample Makefile, explains how you can compile plain AVR C file. -# -# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile - -NO_CORE = Yes - -BOARD_TAG = atmega16 -MCU = atmega16 -F_CPU = 8000000L - -ISP_PROG = stk500v1 -AVRDUDE_ISP_BAUDRATE = 19200 - -include ../TestSuiteCommon.mk -include $(ARDMK_DIR)/Arduino.mk - -# !!! Important. You have to use make ispload to upload when using ISP programmer diff --git a/tests/BlinkInAVRC/blink.c b/tests/BlinkInAVRC/blink.c deleted file mode 100644 index d8b7c8f..0000000 --- a/tests/BlinkInAVRC/blink.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * © Anil Kumar Pugalia, 2010. Email: email@sarika-pugs.com - * - * ATmega48/88/168, ATmega16/32 - * - * Example Blink. Toggles all IO pins at 1Hz - */ - -#include <avr/io.h> -#include <util/delay.h> - -void init_io(void) -{ - // 1 = output, 0 = input - DDRB = 0b11111111; // All outputs - DDRC = 0b11111111; // All outputs - DDRD = 0b11111110; // PORTD (RX on PD0). Just for demo -} - -int main(void) -{ - init_io(); - - while (1) - { - PORTC = 0xFF; - PORTB = 0xFF; - PORTD = 0xFF; - _delay_ms(500); - - PORTC = 0x00; - PORTB = 0x00; - PORTD = 0x00; - _delay_ms(500); - } - - return 0; -} diff --git a/tests/BlinkWithoutDelay/BlinkWithoutDelay.ino b/tests/BlinkWithoutDelay/BlinkWithoutDelay.ino deleted file mode 100644 index 0143571..0000000 --- a/tests/BlinkWithoutDelay/BlinkWithoutDelay.ino +++ /dev/null @@ -1,65 +0,0 @@ -/* Blink without Delay - - Turns on and off a light emitting diode(LED) connected to a digital - pin, without using the delay() function. This means that other code - can run at the same time without being interrupted by the LED code. - - The circuit: - * LED attached from pin 13 to ground. - * Note: on most Arduinos, there is already an LED on the board - that's attached to pin 13, so no hardware is needed for this example. - - - created 2005 - by David A. Mellis - modified 8 Feb 2010 - by Paul Stoffregen - - This example code is in the public domain. - - - http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay - */ - -// constants won't change. Used here to -// set pin numbers: -const int ledPin = 13; // the number of the LED pin - -// Variables will change: -int ledState = LOW; // ledState used to set the LED -long previousMillis = 0; // will store last time LED was updated - -// the follow variables is a long because the time, measured in miliseconds, -// will quickly become a bigger number than can be stored in an int. -long interval = 1000; // interval at which to blink (milliseconds) - -void setup() { - // set the digital pin as output: - pinMode(ledPin, OUTPUT); -} - -void loop() -{ - // here is where you'd put code that needs to be running all the time. - - // check to see if it's time to blink the LED; that is, if the - // difference between the current time and last time you blinked - // the LED is bigger than the interval at which you want to - // blink the LED. - unsigned long currentMillis = millis(); - - if(currentMillis - previousMillis > interval) { - // save the last time you blinked the LED - previousMillis = currentMillis; - - // if the LED is off turn it on and vice-versa: - if (ledState == LOW) - ledState = HIGH; - else - ledState = LOW; - - // set the LED with the ledState of the variable: - digitalWrite(ledPin, ledState); - } -} - diff --git a/tests/BlinkWithoutDelay/Makefile b/tests/BlinkWithoutDelay/Makefile deleted file mode 100644 index 872d069..0000000 --- a/tests/BlinkWithoutDelay/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../TestSuiteCommon.mk -include ../../Arduino.mk diff --git a/tests/Fade/Fade.ino b/tests/Fade/Fade.ino deleted file mode 100644 index b47bf43..0000000 --- a/tests/Fade/Fade.ino +++ /dev/null @@ -1,31 +0,0 @@ -/* - Fade - - This example shows how to fade an LED on pin 9 - using the analogWrite() function. - - This example code is in the public domain. - - */ -int brightness = 0; // how bright the LED is -int fadeAmount = 5; // how many points to fade the LED by - -void setup() { - // declare pin 9 to be an output: - pinMode(9, OUTPUT); -} - -void loop() { - // set the brightness of pin 9: - analogWrite(9, brightness); - - // change the brightness for next time through the loop: - brightness = brightness + fadeAmount; - - // reverse the direction of the fading at the ends of the fade: - if (brightness == 0 || brightness == 255) { - fadeAmount = -fadeAmount ; - } - // wait for 30 milliseconds to see the dimming effect - delay(30); -} diff --git a/tests/Fade/Makefile b/tests/Fade/Makefile deleted file mode 100644 index 872d069..0000000 --- a/tests/Fade/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../TestSuiteCommon.mk -include ../../Arduino.mk diff --git a/tests/HelloWorld/HelloWorld.ino b/tests/HelloWorld/HelloWorld.ino deleted file mode 100644 index e99957d..0000000 --- a/tests/HelloWorld/HelloWorld.ino +++ /dev/null @@ -1,58 +0,0 @@ -/* - LiquidCrystal Library - Hello World - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch prints "Hello World!" to the LCD - and shows the time. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - */ - -// include the library code: -#include <LiquidCrystal.h> - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the LCD. - lcd.print("hello, world!"); -} - -void loop() { - // set the cursor to column 0, line 1 - // (note: line 1 is the second row, since counting begins with 0): - lcd.setCursor(0, 1); - // print the number of seconds since reset: - lcd.print(millis()/1000); -} - diff --git a/tests/HelloWorld/Makefile b/tests/HelloWorld/Makefile deleted file mode 100644 index 0af2ed4..0000000 --- a/tests/HelloWorld/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = LiquidCrystal - -include ../TestSuiteCommon.mk -include ../../Arduino.mk diff --git a/tests/TestSuiteCommon.mk b/tests/TestSuiteCommon.mk deleted file mode 100644 index 5fa4f50..0000000 --- a/tests/TestSuiteCommon.mk +++ /dev/null @@ -1,13 +0,0 @@ -ARDMK_DIR=../../ -DEPENDENCIES_FOLDER = ../../dependencies -DEPENDENCIES_MPIDE_DIR = $(DEPENDENCIES_FOLDER)/mpide-0023-linux64-20130817-test - -ifeq ($(MPIDE_DIR),) - MPIDE_DIR = $(DEPENDENCIES_MPIDE_DIR) -endif - -DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_FOLDER)/arduino-1.0.5 - -ifeq ($(ARDUINO_DIR),) - ARDUINO_DIR = $(DEPENDENCIES_ARDUINO_DIR) -endif diff --git a/tests/WebServer/Makefile b/tests/WebServer/Makefile deleted file mode 100644 index 5fbefae..0000000 --- a/tests/WebServer/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile - -BOARD_TAG = uno -ARDUINO_LIBS = Ethernet SPI - -include ../TestSuiteCommon.mk -include ../../Arduino.mk diff --git a/tests/WebServer/WebServer.ino b/tests/WebServer/WebServer.ino deleted file mode 100644 index fb2a1b9..0000000 --- a/tests/WebServer/WebServer.ino +++ /dev/null @@ -1,82 +0,0 @@ -/* - Web Server - - A simple web server that shows the value of the analog input pins. - using an Arduino Wiznet Ethernet shield. - - Circuit: - * Ethernet shield attached to pins 10, 11, 12, 13 - * Analog inputs attached to pins A0 through A5 (optional) - - created 18 Dec 2009 - by David A. Mellis - modified 4 Sep 2010 - by Tom Igoe - - */ - -#include <SPI.h> -#include <Ethernet.h> - -// Enter a MAC address and IP address for your controller below. -// The IP address will be dependent on your local network: -byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; -IPAddress ip(192,168,1, 178); - -// Initialize the Ethernet server library -// with the IP address and port you want to use -// (port 80 is default for HTTP): -EthernetServer server(80); - -void setup() -{ - // start the Ethernet connection and the server: - Ethernet.begin(mac, ip); - server.begin(); -} - -void loop() -{ - // listen for incoming clients - EthernetClient client = server.available(); - if (client) { - // an http request ends with a blank line - boolean currentLineIsBlank = true; - while (client.connected()) { - if (client.available()) { - char c = client.read(); - // if you've gotten to the end of the line (received a newline - // character) and the line is blank, the http request has ended, - // so you can send a reply - if (c == '\n' && currentLineIsBlank) { - // send a standard http response header - client.println("HTTP/1.1 200 OK"); - client.println("Content-Type: text/html"); - client.println(); - - // output the value of each analog input pin - for (int analogChannel = 0; analogChannel < 6; analogChannel++) { - client.print("analog input "); - client.print(analogChannel); - client.print(" is "); - client.print(analogRead(analogChannel)); - client.println("<br />"); - } - break; - } - if (c == '\n') { - // you're starting a new line - currentLineIsBlank = true; - } - else if (c != '\r') { - // you've gotten a character on the current line - currentLineIsBlank = false; - } - } - } - // give the web browser time to receive the data - delay(1); - // close the connection: - client.stop(); - } -} diff --git a/tests/master_reader/Makefile b/tests/master_reader/Makefile deleted file mode 100644 index 8a42a8e..0000000 --- a/tests/master_reader/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile - -BOARD_TAG = uno -ARDUINO_LIBS = Wire - -include ../TestSuiteCommon.mk -include ../../Arduino.mk diff --git a/tests/master_reader/master_reader.ino b/tests/master_reader/master_reader.ino deleted file mode 100644 index 4124d7d..0000000 --- a/tests/master_reader/master_reader.ino +++ /dev/null @@ -1,32 +0,0 @@ -// Wire Master Reader -// by Nicholas Zambetti <http://www.zambetti.com> - -// Demonstrates use of the Wire library -// Reads data from an I2C/TWI slave device -// Refer to the "Wire Slave Sender" example for use with this - -// Created 29 March 2006 - -// This example code is in the public domain. - - -#include <Wire.h> - -void setup() -{ - Wire.begin(); // join i2c bus (address optional for master) - Serial.begin(9600); // start serial for output -} - -void loop() -{ - Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 - - while(Wire.available()) // slave may send less than requested - { - char c = Wire.read(); // receive a byte as character - Serial.print(c); // print the character - } - - delay(500); -} diff --git a/tests/script/bootstrap.sh b/tests/script/bootstrap.sh new file mode 100755 index 0000000..083bf5d --- /dev/null +++ b/tests/script/bootstrap.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +pushd $SCRIPTS_DIR/.. + +source $SCRIPTS_DIR/bootstrap/chipkit.sh +source $SCRIPTS_DIR/bootstrap/arduino.sh diff --git a/tests/script/bootstrap/arduino.sh b/tests/script/bootstrap/arduino.sh new file mode 100644 index 0000000..3c7e9d7 --- /dev/null +++ b/tests/script/bootstrap/arduino.sh @@ -0,0 +1,44 @@ +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $BOOTSTRAP_DIR/common.sh + +echo "Installing dependencies for building for the Arduino" + +if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then + + echo "Installing Arduino..." + + ARDUINO_BASENAME="arduino-1.0.5" + if [ $OS == "cygwin" ]; then + ARDUINO_FILE="$ARDUINO_BASENAME-r2-windows".zip + EXTRACT_COMMAND="unzip -q" + elif [ $OS == "mac" ]; then + ARDUINO_FILE="$ARDUINO_BASENAME-macosx".zip + EXTRACT_COMMAND="unzip -q" + else + ARDUINO_FILE="$ARDUINO_BASENAME-linux64".tgz + EXTRACT_COMMAND="tar -xzf" + fi + + ARDUINO_URL=http://arduino.googlecode.com/files/$ARDUINO_FILE + + _pushd $DEPENDENCIES_FOLDER + if ! test -e $ARDUINO_FILE + then + echo "Downloading Arduino IDE..." + download $ARDUINO_URL $ARDUINO_FILE + fi + + if ! test -d $ARDUINO_BASENAME + then + echo "Installing Arduino to local folder..." + $EXTRACT_COMMAND $ARDUINO_FILE + echo "Arduino installed" + fi + + _popd + +fi + +echo +echo "${bldgreen}Arduino dependencies installed.$txtrst" diff --git a/tests/script/bootstrap/chipkit.sh b/tests/script/bootstrap/chipkit.sh new file mode 100644 index 0000000..efe9615 --- /dev/null +++ b/tests/script/bootstrap/chipkit.sh @@ -0,0 +1,61 @@ +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $BOOTSTRAP_DIR/common.sh + +echo "Installing dependencies for building for the chipKIT" + + +if [ -z "$MPIDE_DIR" ] || ! test -e $MPIDE_DIR || [ $OS == "cygwin" ]; then + + echo "Installing MPIDE..." + + if [ $OS == "cygwin" ]; then + MPIDE_BASENAME="mpide-0023-windows-20130715" + MPIDE_FILE="$MPIDE_BASENAME".zip + EXTRACT_COMMAND="unzip -q" + if ! command -v unzip >/dev/null 2>&1; then + _cygwin_error "unzip" + fi + elif [ $OS == "mac" ]; then + MPIDE_BASENAME=mpide-0023-macosx-20130715 + MPIDE_FILE="$MPIDE_BASENAME".dmg + else + MPIDE_BASENAME=mpide-0023-linux64-20130817-test + MPIDE_FILE="$MPIDE_BASENAME".tgz + EXTRACT_COMMAND="tar -xzf" + fi + + MPIDE_URL=http://chipkit.s3.amazonaws.com/builds/$MPIDE_FILE + + _pushd $DEPENDENCIES_FOLDER + if ! test -e $MPIDE_FILE + then + echo "Downloading MPIDE..." + download $MPIDE_URL $MPIDE_FILE + fi + + if ! test -d $MPIDE_BASENAME + then + echo "Installing MPIDE to local folder..." + if [ $OS == "mac" ]; then + hdiutil attach $MPIDE_FILE + cp -R /Volumes/Mpide/Mpide.app/Contents/Resources/Java $MPIDE_BASENAME + hdiutil detach /Volumes/Mpide + else + $EXTRACT_COMMAND $MPIDE_FILE + fi + echo "MPIDE installed" + fi + + if [ $OS == "cygwin" ]; then + chmod a+x mpide/hardware/pic32/compiler/pic32-tools/bin/* + chmod a+x -R mpide/hardware/pic32/compiler/pic32-tools/pic32mx/ + chmod a+x mpide/*.dll + chmod a+x mpide/hardware/tools/avr/bin/* + fi + _popd + +fi + +echo +echo "${bldgreen}chipKIT dependencies installed.$txtrst" diff --git a/tests/script/bootstrap/common.sh b/tests/script/bootstrap/common.sh new file mode 100644 index 0000000..a6b6415 --- /dev/null +++ b/tests/script/bootstrap/common.sh @@ -0,0 +1,191 @@ +#!/usr/bin/env bash + +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +if [ -z $COMMON_SOURCED ]; then + + # TODO this is kind of a hacky way of determining if root is required - + # ideally we wouuld set up a little virtualenv in the dependencies folder + SUDO_CMD= + if command -v sudo >/dev/null 2>&1; then + SUDO_CMD="sudo -E" + + if [ -z $CI ] && [ -z $VAGRANT ]; then + echo "The bootstrap script needs to install a few packages to your system as an admin, and we will use the 'sudo' command - enter your password to continue" + $SUDO_CMD ls > /dev/null + fi + fi + + KERNEL=`uname` + ARCH=`uname -m` + if [ ${KERNEL:0:7} == "MINGW32" ]; then + OS="windows" + elif [ ${KERNEL:0:6} == "CYGWIN" ]; then + OS="cygwin" + elif [ $KERNEL == "Darwin" ]; then + OS="mac" + else + OS="linux" + if ! command -v lsb_release >/dev/null 2>&1; then + # Arch Linux + if command -v pacman>/dev/null 2>&1; then + $SUDO_CMD pacman -S lsb-release + fi + fi + + DISTRO=`lsb_release -si` + fi + + + die() { + echo >&2 "${bldred}$@${txtrst}" + exit 1 + } + + _cygwin_error() { + echo + echo "${bldred}Missing \"$1\"${txtrst} - run the Cygwin installer again and select the base package set:" + echo " $CYGWIN_PACKAGES" + echo "After installing the packages, re-run this bootstrap script." + die + } + + if ! command -v tput >/dev/null 2>&1; then + if [ $OS == "cygwin" ]; then + echo "OPTIONAL: Install the \"ncurses\" package in Cygwin to get colored shell output" + fi + else + set +e + # These exit with 1 when provisioning in a Vagrant box...? + txtrst=$(tput sgr0) # reset + bldred=${txtbld}$(tput setaf 1) + bldgreen=${txtbld}$(tput setaf 2) + set -e + fi + + + _pushd() { + pushd $1 > /dev/null + } + + _popd() { + popd > /dev/null + } + + _wait() { + if [ -z $CI ] && [ -z $VAGRANT ]; then + echo "Press Enter when done" + read + fi + } + + _install() { + if [ $OS == "cygwin" ]; then + _cygwin_error $1 + elif [ $OS == "mac" ]; then + # brew exists with 1 if it's already installed + set +e + brew install $1 + set -e + else + if [ -z $DISTRO ]; then + echo + echo "Missing $1 - install it using your distro's package manager or build from source" + _wait + else + if [ $DISTRO == "arch" ]; then + $SUDO_CMD pacman -S $1 + elif [ $DISTRO == "Ubuntu" ]; then + $SUDO_CMD apt-get update -qq + $SUDO_CMD apt-get install $1 -y + else + echo + echo "Missing $1 - install it using your distro's package manager or build from source" + _wait + fi + fi + fi + } + + download() { + url=$1 + filename=$2 + curl $url -L -o $filename + } + + if [ `id -u` == 0 ]; then + die "Error: running as root - don't use 'sudo' with this script" + fi + + if ! command -v unzip >/dev/null 2>&1; then + _install "unzip" + fi + + if ! command -v curl >/dev/null 2>&1; then + if [ $OS == "cygwin" ]; then + _cygwin_error "curl" + else + _install curl + fi + fi + + echo "Storing all downloaded dependencies in the \"dependencies\" folder" + + DEPENDENCIES_FOLDER="/var/tmp/Arduino-Makefile-testing-dependencies" + mkdir -p $DEPENDENCIES_FOLDER + + if ! command -v make >/dev/null 2>&1; then + if [ $OS == "cygwin" ]; then + _cygwin_error "make" + elif [ $OS == "mac" ]; then + die "Missing 'make' - install the Xcode CLI tools" + else + if [ $DISTRO == "arch" ]; then + _install "base-devel" + elif [ $DISTRO == "Ubuntu" ]; then + _install "build-essential" + fi + fi + fi + + if [ $DISTRO == "Ubuntu" ] && [ $ARCH == "x86_64" ]; then + _install "libc6-i386" + _install "lib32gcc1" + fi + + if ! command -v g++ >/dev/null 2>&1; then + if [ $DISTRO == "Ubuntu" ]; then + _install "g++" + fi + fi + + if ! command -v python >/dev/null 2>&1; then + echo "Installing Python..." + _install "python" + fi + + if ! command -v pip >/dev/null 2>&1; then + echo "Installing Pip..." + if ! command -v easy_install >/dev/null 2>&1; then + _install "python-setuptools" + fi + + if ! command -v easy_install >/dev/null 2>&1; then + die "easy_install not available, can't install pip" + fi + + $SUDO_CMD easy_install pip + fi + + PIP_SUDO_CMD= + if [ -z $VIRTUAL_ENV ]; then + # Only use sudo if the user doesn't have an active virtualenv + PIP_SUDO_CMD=$SUDO_CMD + fi + + $PIP_SUDO_CMD pip install --upgrade setuptools + $PIP_SUDO_CMD pip install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt + + COMMON_SOURCED=1 +fi diff --git a/tests/script/bootstrap/pip-requirements.txt b/tests/script/bootstrap/pip-requirements.txt new file mode 100644 index 0000000..8313187 --- /dev/null +++ b/tests/script/bootstrap/pip-requirements.txt @@ -0,0 +1 @@ +pyserial==2.7 diff --git a/tests/script/runtests.sh b/tests/script/runtests.sh new file mode 100755 index 0000000..5f513da --- /dev/null +++ b/tests/script/runtests.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +TESTS_DIR=examples + +failures=() + +# 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. +NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial) + +for dir in $TESTS_DIR/*/ +do + dir=${dir%*/} + example=${dir##*/} + example_is_testable=true + for non_testable_example in "${NON_TESTABLE_EXAMPLES[@]}"; do + if [[ $example == $non_testable_example ]]; then + example_is_testable=false + break + fi + done + + if ! $example_is_testable; then + echo "Skipping non-testable example $example..." + continue + fi + + pushd $dir + echo "Compiling $example..." + make_output=`make clean` + make_output=`make` + if [[ $? -ne 0 ]]; then + failures+=("$example") + echo "Example $example failed" + fi + popd +done + +for failure in "${failures[@]}"; do + echo "Example $failure failed" +done + +if [[ ${#failures[@]} -eq 0 ]]; then + echo "All tests passed." +else + exit 1 +fi diff --git a/tests/toneMelody/Makefile b/tests/toneMelody/Makefile deleted file mode 100644 index 872d069..0000000 --- a/tests/toneMelody/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../TestSuiteCommon.mk -include ../../Arduino.mk diff --git a/tests/toneMelody/pitches.h b/tests/toneMelody/pitches.h deleted file mode 100644 index 55c7d54..0000000 --- a/tests/toneMelody/pitches.h +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************* - * Public Constants - *************************************************/ - -#define NOTE_B0 31 -#define NOTE_C1 33 -#define NOTE_CS1 35 -#define NOTE_D1 37 -#define NOTE_DS1 39 -#define NOTE_E1 41 -#define NOTE_F1 44 -#define NOTE_FS1 46 -#define NOTE_G1 49 -#define NOTE_GS1 52 -#define NOTE_A1 55 -#define NOTE_AS1 58 -#define NOTE_B1 62 -#define NOTE_C2 65 -#define NOTE_CS2 69 -#define NOTE_D2 73 -#define NOTE_DS2 78 -#define NOTE_E2 82 -#define NOTE_F2 87 -#define NOTE_FS2 93 -#define NOTE_G2 98 -#define NOTE_GS2 104 -#define NOTE_A2 110 -#define NOTE_AS2 117 -#define NOTE_B2 123 -#define NOTE_C3 131 -#define NOTE_CS3 139 -#define NOTE_D3 147 -#define NOTE_DS3 156 -#define NOTE_E3 165 -#define NOTE_F3 175 -#define NOTE_FS3 185 -#define NOTE_G3 196 -#define NOTE_GS3 208 -#define NOTE_A3 220 -#define NOTE_AS3 233 -#define NOTE_B3 247 -#define NOTE_C4 262 -#define NOTE_CS4 277 -#define NOTE_D4 294 -#define NOTE_DS4 311 -#define NOTE_E4 330 -#define NOTE_F4 349 -#define NOTE_FS4 370 -#define NOTE_G4 392 -#define NOTE_GS4 415 -#define NOTE_A4 440 -#define NOTE_AS4 466 -#define NOTE_B4 494 -#define NOTE_C5 523 -#define NOTE_CS5 554 -#define NOTE_D5 587 -#define NOTE_DS5 622 -#define NOTE_E5 659 -#define NOTE_F5 698 -#define NOTE_FS5 740 -#define NOTE_G5 784 -#define NOTE_GS5 831 -#define NOTE_A5 880 -#define NOTE_AS5 932 -#define NOTE_B5 988 -#define NOTE_C6 1047 -#define NOTE_CS6 1109 -#define NOTE_D6 1175 -#define NOTE_DS6 1245 -#define NOTE_E6 1319 -#define NOTE_F6 1397 -#define NOTE_FS6 1480 -#define NOTE_G6 1568 -#define NOTE_GS6 1661 -#define NOTE_A6 1760 -#define NOTE_AS6 1865 -#define NOTE_B6 1976 -#define NOTE_C7 2093 -#define NOTE_CS7 2217 -#define NOTE_D7 2349 -#define NOTE_DS7 2489 -#define NOTE_E7 2637 -#define NOTE_F7 2794 -#define NOTE_FS7 2960 -#define NOTE_G7 3136 -#define NOTE_GS7 3322 -#define NOTE_A7 3520 -#define NOTE_AS7 3729 -#define NOTE_B7 3951 -#define NOTE_C8 4186 -#define NOTE_CS8 4435 -#define NOTE_D8 4699 -#define NOTE_DS8 4978 - - diff --git a/tests/toneMelody/toneMelody.ino b/tests/toneMelody/toneMelody.ino deleted file mode 100644 index 8593ab7..0000000 --- a/tests/toneMelody/toneMelody.ino +++ /dev/null @@ -1,49 +0,0 @@ -/* - Melody - - Plays a melody - - circuit: - * 8-ohm speaker on digital pin 8 - - created 21 Jan 2010 - modified 30 Aug 2011 - by Tom Igoe - -This example code is in the public domain. - - http://arduino.cc/en/Tutorial/Tone - - */ - #include "pitches.h" - -// notes in the melody: -int melody[] = { - NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4}; - -// note durations: 4 = quarter note, 8 = eighth note, etc.: -int noteDurations[] = { - 4, 8, 8, 4,4,4,4,4 }; - -void setup() { - // iterate over the notes of the melody: - for (int thisNote = 0; thisNote < 8; thisNote++) { - - // to calculate the note duration, take one second - // divided by the note type. - //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. - int noteDuration = 1000/noteDurations[thisNote]; - tone(8, melody[thisNote],noteDuration); - - // to distinguish the notes, set a minimum time between them. - // the note's duration + 30% seems to work well: - int pauseBetweenNotes = noteDuration * 1.30; - delay(pauseBetweenNotes); - // stop the tone playing: - noTone(8); - } -} - -void loop() { - // no need to repeat the melody. -} |
