From 10502c8d252ab9be81c85e30a83571a16217605c Mon Sep 17 00:00:00 2001 From: srlm Date: Fri, 23 Aug 2013 04:32:44 -0700 Subject: [PATCH] Fixed some minor inclusion errors and got all unit tests running. --- libpropeller/board/board_unit_tester.h | 18 ++++-- libpropeller/eeprom/eeprom.h | 8 +-- libpropeller/elum/elum.h | 4 +- libpropeller/gpsparser/gpsparser.test.h | 6 +- libpropeller/i2c/i2c.h | 6 +- libpropeller/i2c/i2c.test.h | 6 +- libpropeller/i2c/i2c_base.h | 6 +- libpropeller/max17048/max17048.h | 8 +-- libpropeller/max17048/max17048.test.h | 4 +- libpropeller/max8819/max8819.h | 15 ++--- libpropeller/ms5611/ms5611.h | 2 +- libpropeller/numbers/numbers.cpp | 2 +- libpropeller/numbers/numbers.h | 6 +- libpropeller/pcf8523/pcf8523.h | 8 +-- libpropeller/pin/pin.h | 6 +- libpropeller/run_all_tests | 75 +++++++++++++++++++++++++ libpropeller/scheduler/scheduler.h | 6 +- libpropeller/sd/sd.h | 28 ++++----- libpropeller/serial/serial.h | 8 +-- libpropeller/stopwatch/stopwatch.h | 6 +- libpropeller/unity_tools/run_unit | 20 ++++++- 21 files changed, 174 insertions(+), 74 deletions(-) create mode 100755 libpropeller/run_all_tests diff --git a/libpropeller/board/board_unit_tester.h b/libpropeller/board/board_unit_tester.h index fadd30d..76e7b31 100644 --- a/libpropeller/board/board_unit_tester.h +++ b/libpropeller/board/board_unit_tester.h @@ -1,6 +1,8 @@ -#ifndef libpropeller_board_h_ -#define libpropeller_board_h_ - +#ifndef LIBPROPELLER_BOARD_H_ +#define LIBPROPELLER_BOARD_H_ +/** +This nameplace defines the standard unit testing board. +*/ namespace Board{ const int kPinI2CSCL = 0; @@ -10,17 +12,23 @@ namespace Board{ const int kPinMCP3208Clock = 3; const int kPinMCP3208Select = 4; + // 32.768KHz square wave const int kPinSqw = 5; - - const int kPinDac = 6; + // DAC output + const int kPinDac = 6; + + //SD Card const int kPinSDDo = 10; const int kPinSDClk = 11; const int kPinSDDi = 12; const int kPinSDCs = 13; + // Pins are tied together with a 10kOhm resistor. const int kPinTie1a = 18; const int kPinTie1b = 19; + + // Pins are tied together with a 10kOhm resistor. const int kPinTie2a = 20; const int kPinTie2b = 21; diff --git a/libpropeller/eeprom/eeprom.h b/libpropeller/eeprom/eeprom.h index ec68826..b2085d7 100644 --- a/libpropeller/eeprom/eeprom.h +++ b/libpropeller/eeprom/eeprom.h @@ -1,7 +1,7 @@ -#ifndef LIBREDNINE_EEPROM_H_ -#define LIBREDNINE_EEPROM_H_ +#ifndef LIBPROPELLER_EEPROM_H_ +#define LIBPROPELLER_EEPROM_H_ -#include "librednine/i2c/i2c_base.h" +#include "libpropeller/i2c/i2c_base.h" /** Access I2C EEPROMs. * @@ -203,4 +203,4 @@ class EEPROM { }; -#endif // LIBREDNINE_EEPROM_H_ +#endif // LIBPROPELLER_EEPROM_H_ diff --git a/libpropeller/elum/elum.h b/libpropeller/elum/elum.h index a6dc0dc..4dca42e 100644 --- a/libpropeller/elum/elum.h +++ b/libpropeller/elum/elum.h @@ -3,8 +3,8 @@ #include -#ifndef SRLM_PROPGCC_ELUM_H_ -#define SRLM_PROPGCC_ELUM_H_ +#ifndef LIBPROPELLER_ELUM_H_ +#define LIBPROPELLER_ELUM_H_ /** Elum class to allow access to single Elums diff --git a/libpropeller/gpsparser/gpsparser.test.h b/libpropeller/gpsparser/gpsparser.test.h index 1c7cde4..651e479 100644 --- a/libpropeller/gpsparser/gpsparser.test.h +++ b/libpropeller/gpsparser/gpsparser.test.h @@ -1,9 +1,9 @@ #include #include "unity.h" -#include "c++-alloc.h" +#include "libpropeller/c++allocate/c++allocate.h" -#include "librednine/serial/serial.h" -#include "gpsparser.h" +#include "libpropeller/serial/serial.h" +#include "libpropeller/gpsparser/gpsparser.h" // TODO(SRLM) Get rid of the hardcoded test pins. diff --git a/libpropeller/i2c/i2c.h b/libpropeller/i2c/i2c.h index 7b36311..191b818 100644 --- a/libpropeller/i2c/i2c.h +++ b/libpropeller/i2c/i2c.h @@ -1,7 +1,7 @@ -#ifndef LIBREDNINE_I2C_H_ -#define LIBREDNINE_I2C_H_ +#ifndef LIBPROPELLER_I2C_H_ +#define LIBPROPELLER_I2C_H_ #include @@ -274,4 +274,4 @@ class I2C { }; -#endif // LIBREDNINE_I2C_H_ +#endif // LIBPROPELLER_I2C_H_ diff --git a/libpropeller/i2c/i2c.test.h b/libpropeller/i2c/i2c.test.h index e63421a..a93b30f 100644 --- a/libpropeller/i2c/i2c.test.h +++ b/libpropeller/i2c/i2c.test.h @@ -1,7 +1,7 @@ // Copyright 2013 SRLM and Red9 #include #include "unity.h" -#include "i2c.h" +#include "libpropeller/i2c/i2c.h" const int kSDAPin = 1; const int kSCLPin = 0; @@ -14,7 +14,7 @@ static const unsigned char Magn = 0b00111100; static const unsigned char BARO = 0b11101110; static const unsigned char Fuel = 0b01101100; -i2c sut; +I2C sut; int registerAddress = 4; int randomAddress = 0; @@ -122,4 +122,4 @@ class UnityTests { -}; \ No newline at end of file +}; diff --git a/libpropeller/i2c/i2c_base.h b/libpropeller/i2c/i2c_base.h index 39cd5ba..89f13a5 100644 --- a/libpropeller/i2c/i2c_base.h +++ b/libpropeller/i2c/i2c_base.h @@ -1,5 +1,5 @@ -#ifndef LIBREDNINE_I2C_BASE_H_ -#define LIBREDNINE_I2C_BASE_H_ +#ifndef LIBPROPELLER_I2C_BASE_H_ +#define LIBPROPELLER_I2C_BASE_H_ #include @@ -210,4 +210,4 @@ class I2CBase { -#endif // LIBREDNINE_I2C_BASE_H_ +#endif // LIBPROPELLER_I2C_BASE_H_ diff --git a/libpropeller/max17048/max17048.h b/libpropeller/max17048/max17048.h index 785ba0d..d292e86 100644 --- a/libpropeller/max17048/max17048.h +++ b/libpropeller/max17048/max17048.h @@ -1,8 +1,8 @@ -#ifndef LIBREDNINE_MAX17048_H_ -#define LIBREDNINE_MAX17048_H_ +#ifndef LIBPROPELLER_MAX17048_H_ +#define LIBPROPELLER_MAX17048_H_ -#include "librednine/i2c/i2c.h" +#include "libpropeller/i2c/i2c.h" /**Interface to the MAX17048 Fuel Chip * @@ -120,4 +120,4 @@ class MAX17048 { }; -#endif // LIBREDNINE_MAX17048_H_ +#endif // LIBPROPELLER_MAX17048_H_ diff --git a/libpropeller/max17048/max17048.test.h b/libpropeller/max17048/max17048.test.h index 247ba4c..d97e6b9 100644 --- a/libpropeller/max17048/max17048.test.h +++ b/libpropeller/max17048/max17048.test.h @@ -1,7 +1,7 @@ #include "unity.h" #include "c++-alloc.h" -#include "librednine/i2c/i2c.h" -#include "librednine/max17048/max17048.h" +#include "libpropeller/i2c/i2c.h" +#include "libpropeller/max17048/max17048.h" MAX17048 * sut; I2C * bus; diff --git a/libpropeller/max8819/max8819.h b/libpropeller/max8819/max8819.h index 8f6caf0..b17e7bf 100644 --- a/libpropeller/max8819/max8819.h +++ b/libpropeller/max8819/max8819.h @@ -1,3 +1,10 @@ +#ifndef LIBPROPELLER_MAX8819_H_ +#define LIBPROPELLER_MAX8819_H_ + +#include +#include + + /** Max8819.h - Max8819 class to allow access to single pins The low level interface code is based on Pins.h from David Michael Betz. @@ -11,12 +18,6 @@ page 18 of datasheet) when CHG outputs a 2Hz square wave. @date 1-1-2013 */ -#ifndef __SRLM_PROPGCC_MAX8819_H__ -#define __SRLM_PROPGCC_MAX8819_H__ - -#include -#include - class Max8819 { private: uint32_t cen_mask; @@ -162,4 +163,4 @@ inline void Max8819::SetCharge(int rate) { } } -#endif // __SRLM_PROPGCC_MAX8819_H__ +#endif // LIBPROPELLER_MAX8819_H_ diff --git a/libpropeller/ms5611/ms5611.h b/libpropeller/ms5611/ms5611.h index d6ec1be..277cfeb 100644 --- a/libpropeller/ms5611/ms5611.h +++ b/libpropeller/ms5611/ms5611.h @@ -46,7 +46,7 @@ class MS5611 { * initialization. * * @param newbus The I2C bus to use. - * @param AddressLSB The least significant byte of the I2C address. Use the enum constants. + * @param address The least significant byte of the I2C address. Use the enum constants. */ bool Init(I2C * newbus, const AddressLSB address = LSB_0) { diff --git a/libpropeller/numbers/numbers.cpp b/libpropeller/numbers/numbers.cpp index 412857a..b342914 100644 --- a/libpropeller/numbers/numbers.cpp +++ b/libpropeller/numbers/numbers.cpp @@ -1,3 +1,3 @@ -#include "librednine/numbers/numbers.h" +#include "libpropeller/numbers/numbers.h" char Numbers::internalBuffer[33]; diff --git a/libpropeller/numbers/numbers.h b/libpropeller/numbers/numbers.h index 3cdc7ae..df1a458 100644 --- a/libpropeller/numbers/numbers.h +++ b/libpropeller/numbers/numbers.h @@ -1,5 +1,5 @@ -#ifndef LIBREDNINE_NUMBERS_H_ -#define LIBREDNINE_NUMBERS_H_ +#ifndef LIBPROPELLER_NUMBERS_H_ +#define LIBPROPELLER_NUMBERS_H_ #include @@ -245,4 +245,4 @@ class Numbers { static char internalBuffer[]; }; -#endif // LIBREDNINE_NUMBERS_H_ +#endif // LIBPROPELLER_NUMBERS_H_ diff --git a/libpropeller/pcf8523/pcf8523.h b/libpropeller/pcf8523/pcf8523.h index 14624d5..8981161 100644 --- a/libpropeller/pcf8523/pcf8523.h +++ b/libpropeller/pcf8523/pcf8523.h @@ -1,8 +1,8 @@ -#ifndef LIBREDNINE_PCF8523_H_ -#define LIBREDNINE_PCF8523_H_ +#ifndef LIBPROPELLER_PCF8523_H_ +#define LIBPROPELLER_PCF8523_H_ #include -#include "librednine/i2c/i2c.h" +#include "libpropeller/i2c/i2c.h" /** Interface to the PCF8523 Real Time Clock (RTC). * @@ -224,4 +224,4 @@ class PCF8523 { }; -#endif // LIBREDNINE_PCF8523_H_ +#endif // LIBPROPELLER_PCF8523_H_ diff --git a/libpropeller/pin/pin.h b/libpropeller/pin/pin.h index 2bd87dc..8ba98ce 100644 --- a/libpropeller/pin/pin.h +++ b/libpropeller/pin/pin.h @@ -1,5 +1,5 @@ -#ifndef __libpropeller_pin_h_ -#define __libpropeller_pin_h_ +#ifndef LIBPROPELLER_PIN_H_ +#define LIBPROPELLER_PIN_H_ // Comment out one definition of INLINE. #define INLINE __attribute__((always_inline)) inline @@ -191,5 +191,5 @@ INLINE void Pin::setOutput() { } -#endif // __libpropeller_pin_h_ +#endif // LIBPROPELLER_PIN_H_ diff --git a/libpropeller/run_all_tests b/libpropeller/run_all_tests new file mode 100755 index 0000000..1c950ef --- /dev/null +++ b/libpropeller/run_all_tests @@ -0,0 +1,75 @@ +#!/usr/bin/python +#from subprocess import call +import subprocess +import os + +tests_run = [] +previous_line = "" +failed_tests = False + +ignore_folders = ["board", "max8819", "elum", "c++allocate", "fullduplexserial", "quadrature_encoder", "unity_tools", "vnh2sp30"] + +folders = [d for d in os.listdir(os.getcwd()) if os.path.isdir(d)] + +tests = list(set(folders).difference(set(ignore_folders))) + +"**************************************" +print "Testing folders:" +for test in tests: + print "--- " + test + + +for test in tests: + print "**************************************" + print "Testing folder " + test + print "" + os.chdir(test) +# call(["./run_all", "-t115200"]) + p = subprocess.Popen(["./run_unit", "-m"], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) + + for line in iter(p.stdout.readline, ''): + print line.rstrip() + # if not all(c.isspace() for c in line): + + if line.strip() == "OK": + tests_run.append((test + ": ").ljust(20) + previous_line) + p.stdin.write("\x1B[A") #Send up key + break + if line.strip() == "FAIL": + tests_run.append((test + ": ").ljust(20) + previous_line) + p.stdin.write("\x1B[A") #Send up key + failed_tests = True + break + if line.strip() == "error: load failed": + tests_run.append((test + ": ").ljust(20) + "error: load failed"); + break + + + previous_line = line + print "" + for line in iter(p.stderr.readline, ''): + print line.rstrip() + + + os.chdir("..") + + print "" + +print "**************************************" +print "Folders ignored:" +for i_f in ignore_folders: + print "--- " + i_f +for test in tests_run: + print test.rstrip() + +print "**************************************" + +if failed_tests == False: + print "OK" +else: + print "FAIL" + +print "" +print "" +print "To add all .elf files to git, run the following command: " +print "git ls-files | grep '\.elf$' | xargs git add" diff --git a/libpropeller/scheduler/scheduler.h b/libpropeller/scheduler/scheduler.h index d49728c..4a17258 100644 --- a/libpropeller/scheduler/scheduler.h +++ b/libpropeller/scheduler/scheduler.h @@ -1,5 +1,5 @@ -#ifndef LIBREDNINE_SCHEDULER_H_ -#define LIBREDNINE_SCHEDULER_H_ +#ifndef LIBPROPELLER_SCHEDULER_H_ +#define LIBPROPELLER_SCHEDULER_H_ #ifndef UNIT_TEST @@ -82,4 +82,4 @@ class Scheduler { unsigned int period_ticks_; }; -#endif // LIBREDNINE_SCHEDULER_H_ +#endif // LIBPROPELLER_SCHEDULER_H_ diff --git a/libpropeller/sd/sd.h b/libpropeller/sd/sd.h index 6512a80..9cf3a20 100644 --- a/libpropeller/sd/sd.h +++ b/libpropeller/sd/sd.h @@ -1,3 +1,17 @@ +#ifndef LIBPROPELLER_SD_H_ +#define LIBPROPELLER_SD_H_ + +#include +#include "libpropeller/sd/sdsafespi.h" + + +#define RET_IF_ERROR_NULL if(HasError()){return NULL;} +#define RET_IF_ERROR if(HasError()){return;} +#define THROW_NULL(value) {SetErrorCode((value)); return NULL;} +//#define THROW_FALSE(value) {SetErrorCode((value)); return false;} +#define THROW(value) {SetErrorCode((value)); return;} + + /** FAT16/32 SD card interface. * * This class is based on the Spin version of FSRW 2.6 by Rokicki and Lonesock. Thanks! @@ -45,20 +59,6 @@ * Write a function that gets a string: * int Get(char * Ubuf, char EndOfStringChar); */ - -#ifndef LIBPROPELLER_SD_H_ -#define LIBPROPELLER_SD_H_ - -#include -#include "librednine/sd/sdsafespi.h" - - -#define RET_IF_ERROR_NULL if(HasError()){return NULL;} -#define RET_IF_ERROR if(HasError()){return;} -#define THROW_NULL(value) {SetErrorCode((value)); return NULL;} -//#define THROW_FALSE(value) {SetErrorCode((value)); return false;} -#define THROW(value) {SetErrorCode((value)); return;} - class SD { public: static const int kNoError = SDSafeSPI::kNoError; diff --git a/libpropeller/serial/serial.h b/libpropeller/serial/serial.h index 61d4b0d..5f70c0c 100644 --- a/libpropeller/serial/serial.h +++ b/libpropeller/serial/serial.h @@ -1,9 +1,9 @@ -#ifndef LIBREDNINE_SERIAL_H_ -#define LIBREDNINE_SERIAL_H_ +#ifndef LIBPROPELLER_SERIAL_H_ +#define LIBPROPELLER_SERIAL_H_ #include #include -#include "librednine/numbers/numbers.h" +#include "libpropeller/numbers/numbers.h" extern char _load_start_serial_cog[]; @@ -529,4 +529,4 @@ class Serial { // return buffer_bytes; //} -#endif // LIBREDNINE_SERIAL_H_ +#endif // LIBPROPELLER_SERIAL_H_ diff --git a/libpropeller/stopwatch/stopwatch.h b/libpropeller/stopwatch/stopwatch.h index 4657008..bba1d89 100644 --- a/libpropeller/stopwatch/stopwatch.h +++ b/libpropeller/stopwatch/stopwatch.h @@ -1,5 +1,5 @@ -#ifndef LIBREDNINE_STOPWATCH_H_ -#define LIBREDNINE_STOPWATCH_H_ +#ifndef LIBPROPELLER_STOPWATCH_H_ +#define LIBPROPELLER_STOPWATCH_H_ #ifndef UNIT_TEST @@ -77,4 +77,4 @@ class Stopwatch { -#endif // LIBREDNINE_STOPWATCH_H_ +#endif // LIBPROPELLER_STOPWATCH_H_ diff --git a/libpropeller/unity_tools/run_unit b/libpropeller/unity_tools/run_unit index 138064f..5ce0a39 100755 --- a/libpropeller/unity_tools/run_unit +++ b/libpropeller/unity_tools/run_unit @@ -1,2 +1,18 @@ -#!/bin/sh -/opt/parallax/bin/propeller-load -r -t -q main.elf +#!/usr/bin/python +import os +import sys +import argparse +from subprocess import call + + +parser = argparse.ArgumentParser() + +parser.add_argument("-m", "--make", action="store_true", help="Make clean and make before loading.") +args = parser.parse_args() + +if args.make: + os.system("make clean") + os.system("make") + +sys.exit(os.system("/opt/parallax/bin/propeller-load -r -q -t115200 main.elf")) +