#!/bin/bash
#
# @file benchmark/run
# @version 1.0
#
# @section License
# Copyright (C) 2014-2015, Mikael Patel
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# @section Description
# Build and run all benchmarks. Parameters are board and version
# of Arduino IDE. Default are nano and 1.6.5. Note: The cosa build
# script version is not changed.
#
# This file is part of the Arduino Che Cosa project.

board=nano
if [ "$1" ]; then
  board=$1
fi

version=1.6.5
if [ "$2" ]; then
  version=$2
fi

echo `date`: BOARD=$board,VERSION=$version
for dir in $(ls)
do
  if [ -d "$dir" ]; then
    echo -n `date`: $dir": "
    cd $dir
    echo -n build..
    cosa $board ARDUINO_VER=$version &> arduino-$version.log
    echo -n upload..
    cosa $board upload ARDUINO_VER=$version &>> arduino-$version.log
    echo -n monitor..
    cosa $board monitor ARDUINO_VER=$version > arduino-$version.run
    echo -n clean..
    cosa $board clean ARDUINO_VER=$version > /dev/null
    rm arduino-$version.log
    echo done
    cd ..
  fi
done

