Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like manage my Arduino source code (projects and libraries) under source control with continuous testing. How can I automatically compile the code with continuous integration tools, to make sure each version compiles cleanly? In the best case one should be able to configure builds for multiple processors, optionally run unit tests and check for maximum binary size.

share|improve this question
    
Other than passing it through Ino and avr-size? – Ignacio Vazquez-Abrams Jan 16 '15 at 17:01
    
@IgnacioVazquez-Abrams I don't mind which tools to use, but it should run automatically on some cloud hosting or continuous integration service. – Jakob Jan 16 '15 at 17:03
1  
Compiling binary size isn't that hard, but to do unit tests, you would have to structure your code in such a way that it is unit-testable, which is hard enough if you want to keep size small. Besides, you will need to run those test on a chip or in an emulator to get a test that is more or less reliable. – GolezTrol Jan 16 '15 at 19:46
    
I found github.com/kyab/travis-test-arduino but its experimental and a comprehensive answer/tutorial as answer would be better. – Jakob Jan 18 '15 at 16:58
2  
The issue with this is it goes against the original purpose of continuous integration: it's meant to push changes and then have it automatically build and deploy within minutes. This allows your customers to get the latest features and fixes as they happen, instead of every two months. For Arduino it's just "cloud making sure it builds." For unit tests you might have to bypass the Arduino libraries to build functions and send example data over the "pins." – Anonymous Penguin Jan 18 '15 at 17:13

Newest version of Arduino ide has a command line interface to build and upload code. But you can obviously do it by makefile and avrdude. Now, you have compiled your code BUT you need testing. As simulator are complex,incomplete, expansive and.. Just a simulation, and because the chip are relatively cheap, building a board witch will make HW interaction AND check the results its the fastest and easiest way. On that "special" board you may upload something like an interpreter witch take a test from the PC and execute it, something similar to firmata for arduino. At least that is how I would build it. And as far as I know there are no know implementation of this, even if I'm quite sure many industries should and probably do that.

share|improve this answer

I would recommend you to look into PlatformIO, cross-platform code builder and the missing library manager. It can build the same code for the famous embedded development platforms and the most popular embedded boards.

PlatformIO can be be integrated with the popular Continuous Integration (CI) systems (or your own). See documentation with examples.

Let's look into .travis.yml config/template for Travis CI:

language: python
python:
    - "2.7"

env:
    - PLATFORMIO_CI_SRC=path/to/source/file.c
    - PLATFORMIO_CI_SRC=path/to/source/file.ino
    - PLATFORMIO_CI_SRC=path/to/source/directory

install:
    - python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"

script:
    - platformio ci --board=TYPE_1 --board=TYPE_2 --board=TYPE_N

Example

Integration for USB_Host_Shield_2.0 project. The .travis.yml configuration file:

language: python
python:
    - "2.7"

env:
    - PLATFORMIO_CI_SRC=examples/acm/acm_terminal
    - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiIRCamera PLATFORMIO_BUILD_FLAGS="-DWIICAMERA"
    - PLATFORMIO_CI_SRC=examples/ftdi/USBFTDILoopback
    - PLATFORMIO_CI_SRC=examples/Xbox/XBOXUSB
    # - ...

install:
    - python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"

    # Libraries from PlatformIO Library Registry
    # http://platformio.org/#!/lib/show/416/TinyGPS
    # http://platformio.org/#!/lib/show/417/SPI4Teensy3
    - platformio lib install 416 417

script:
    - platformio ci --board=uno --board=teensy31 --board=due --lib="."
share|improve this answer

One example of setting up Jenkins continuous integration for Arduino project can be found here: Continuous integration for embedded systems

The example shows how to build and upload image to Arduino and execute Selenium web tests (the system under test is Arduino-based web-server).

share|improve this answer
    
nice because it use some existing software witch is feature rich. but it seems to do only web testing; can you please expand the answer? also link-based answer are bad. – lesto Mar 3 '15 at 15:59

I would advice to use the arduino eclipse plugin named sloeber sloeber.io of which I'm the project lead.
It integrates with version control and allows building on multiple platforms as it supports multiple configurations.
Though it is not yet idiot proof I have documented and demonstrated using unit testing of arduino code on the local pc using the google test framework.
Here is a link to a blog containing a presentation of how you can do it. http://blog.baeyens.it/#post25

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.