Skip to content

Commit

Permalink
Fixed some minor inclusion errors and got all unit tests running.
Browse files Browse the repository at this point in the history
  • Loading branch information
srlm-io committed Aug 23, 2013
1 parent 99db562 commit 10502c8
Show file tree
Hide file tree
Showing 21 changed files with 174 additions and 74 deletions.
18 changes: 13 additions & 5 deletions 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;
Expand All @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions 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.
*
Expand Down Expand Up @@ -203,4 +203,4 @@ class EEPROM {

};

#endif // LIBREDNINE_EEPROM_H_
#endif // LIBPROPELLER_EEPROM_H_
4 changes: 2 additions & 2 deletions libpropeller/elum/elum.h
Expand Up @@ -3,8 +3,8 @@
#include <propeller.h>


#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
Expand Down
6 changes: 3 additions & 3 deletions libpropeller/gpsparser/gpsparser.test.h
@@ -1,9 +1,9 @@
#include <string.h>
#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.
Expand Down
6 changes: 3 additions & 3 deletions 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 <stdint.h>

Expand Down Expand Up @@ -274,4 +274,4 @@ class I2C {

};

#endif // LIBREDNINE_I2C_H_
#endif // LIBPROPELLER_I2C_H_
6 changes: 3 additions & 3 deletions libpropeller/i2c/i2c.test.h
@@ -1,7 +1,7 @@
// Copyright 2013 SRLM and Red9
#include <propeller.h>
#include "unity.h"
#include "i2c.h"
#include "libpropeller/i2c/i2c.h"

const int kSDAPin = 1;
const int kSCLPin = 0;
Expand All @@ -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;
Expand Down Expand Up @@ -122,4 +122,4 @@ class UnityTests {



};
};
6 changes: 3 additions & 3 deletions 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 <propeller.h>

Expand Down Expand Up @@ -210,4 +210,4 @@ class I2CBase {



#endif // LIBREDNINE_I2C_BASE_H_
#endif // LIBPROPELLER_I2C_BASE_H_
8 changes: 4 additions & 4 deletions 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
*
Expand Down Expand Up @@ -120,4 +120,4 @@ class MAX17048 {
};


#endif // LIBREDNINE_MAX17048_H_
#endif // LIBPROPELLER_MAX17048_H_
4 changes: 2 additions & 2 deletions 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;
Expand Down
15 changes: 8 additions & 7 deletions libpropeller/max8819/max8819.h
@@ -1,3 +1,10 @@
#ifndef LIBPROPELLER_MAX8819_H_
#define LIBPROPELLER_MAX8819_H_

#include <stdint.h>
#include <propeller.h>


/** Max8819.h - Max8819 class to allow access to single pins
The low level interface code is based on Pins.h from David Michael Betz.
Expand All @@ -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 <stdint.h>
#include <propeller.h>

class Max8819 {
private:
uint32_t cen_mask;
Expand Down Expand Up @@ -162,4 +163,4 @@ inline void Max8819::SetCharge(int rate) {
}
}

#endif // __SRLM_PROPGCC_MAX8819_H__
#endif // LIBPROPELLER_MAX8819_H_
2 changes: 1 addition & 1 deletion libpropeller/ms5611/ms5611.h
Expand Up @@ -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) {

Expand Down
2 changes: 1 addition & 1 deletion libpropeller/numbers/numbers.cpp
@@ -1,3 +1,3 @@
#include "librednine/numbers/numbers.h"
#include "libpropeller/numbers/numbers.h"

char Numbers::internalBuffer[33];
6 changes: 3 additions & 3 deletions 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 <string.h>

Expand Down Expand Up @@ -245,4 +245,4 @@ class Numbers {
static char internalBuffer[];
};

#endif // LIBREDNINE_NUMBERS_H_
#endif // LIBPROPELLER_NUMBERS_H_
8 changes: 4 additions & 4 deletions 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 <propeller.h>
#include "librednine/i2c/i2c.h"
#include "libpropeller/i2c/i2c.h"

/** Interface to the PCF8523 Real Time Clock (RTC).
*
Expand Down Expand Up @@ -224,4 +224,4 @@ class PCF8523 {
};


#endif // LIBREDNINE_PCF8523_H_
#endif // LIBPROPELLER_PCF8523_H_
6 changes: 3 additions & 3 deletions 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
Expand Down Expand Up @@ -191,5 +191,5 @@ INLINE void Pin::setOutput() {
}


#endif // __libpropeller_pin_h_
#endif // LIBPROPELLER_PIN_H_

75 changes: 75 additions & 0 deletions 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"
6 changes: 3 additions & 3 deletions 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
Expand Down Expand Up @@ -82,4 +82,4 @@ class Scheduler {
unsigned int period_ticks_;
};

#endif // LIBREDNINE_SCHEDULER_H_
#endif // LIBPROPELLER_SCHEDULER_H_
28 changes: 14 additions & 14 deletions libpropeller/sd/sd.h
@@ -1,3 +1,17 @@
#ifndef LIBPROPELLER_SD_H_
#define LIBPROPELLER_SD_H_

#include <propeller.h>
#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!
Expand Down Expand Up @@ -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 <propeller.h>
#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;
Expand Down

0 comments on commit 10502c8

Please sign in to comment.