Enable Teensy 3.5 unit testing (#1038)
* Add missing forward declarations Found while compiling teensy35 unit tests * Unit test should not rely on EEPROM * Fix bad lib_dep Teensy35 #includes FlexCAN_4 headers * Fix circular include logger.h needs FPU_MAX_SIZE which is defined in globals.h. Globals.h includes logger.h! * Ambguity in integer typedefs
This commit is contained in:
parent
8c85b0c998
commit
d1399a0f33
|
@ -28,20 +28,25 @@ build_unflags = -Os
|
||||||
build_flags = -DUSE_LIBDIVIDE -O3 -ffast-math -Wall -Wextra -std=c99
|
build_flags = -DUSE_LIBDIVIDE -O3 -ffast-math -Wall -Wextra -std=c99
|
||||||
lib_deps = EEPROM, Time
|
lib_deps = EEPROM, Time
|
||||||
test_build_src = yes
|
test_build_src = yes
|
||||||
|
test_ignore = test_table3d_native
|
||||||
|
|
||||||
[env:teensy35]
|
[env:teensy35]
|
||||||
;platform=teensy
|
;platform=teensy
|
||||||
platform=https://github.com/platformio/platform-teensy.git
|
platform=https://github.com/platformio/platform-teensy.git
|
||||||
board=teensy35
|
board=teensy35
|
||||||
framework=arduino
|
framework=arduino
|
||||||
lib_deps = EEPROM, FlexCAN, Time
|
lib_deps = EEPROM, FlexCAN_T4, Time
|
||||||
|
test_build_src = yes
|
||||||
|
test_ignore = test_table3d_native
|
||||||
|
|
||||||
[env:teensy36]
|
[env:teensy36]
|
||||||
;platform=teensy
|
;platform=teensy
|
||||||
platform=https://github.com/platformio/platform-teensy.git
|
platform=https://github.com/platformio/platform-teensy.git
|
||||||
board=teensy36
|
board=teensy36
|
||||||
framework=arduino
|
framework=arduino
|
||||||
lib_deps = EEPROM, FlexCAN, Time
|
lib_deps = EEPROM, FlexCAN_T4, Time
|
||||||
|
test_build_src = yes
|
||||||
|
test_ignore = test_table3d_native
|
||||||
|
|
||||||
[env:teensy41]
|
[env:teensy41]
|
||||||
;platform=teensy
|
;platform=teensy
|
||||||
|
@ -49,6 +54,8 @@ platform=https://github.com/platformio/platform-teensy.git
|
||||||
board=teensy41
|
board=teensy41
|
||||||
framework=arduino
|
framework=arduino
|
||||||
lib_deps = EEPROM, FlexCAN_T4, Time
|
lib_deps = EEPROM, FlexCAN_T4, Time
|
||||||
|
test_build_src = yes
|
||||||
|
test_ignore = test_table3d_native
|
||||||
|
|
||||||
;Not currently working
|
;Not currently working
|
||||||
;[env:LaunchPad_tm4c1294ncpdt]
|
;[env:LaunchPad_tm4c1294ncpdt]
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#else
|
#else
|
||||||
#include "SdFat.h"
|
#include "SdFat.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "logger.h"
|
||||||
//#include <SdSpiCard.h>
|
//#include <SdSpiCard.h>
|
||||||
#include "RingBuf.h"
|
#include "RingBuf.h"
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,9 @@ void readSDSectors(uint8_t* buffer, uint32_t sectorNumber, uint16_t sectorCount)
|
||||||
sd.card()->readSectors(sectorNumber, buffer, sectorCount);
|
sd.card()->readSectors(sectorNumber, buffer, sectorCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward declare
|
||||||
|
void writeSDLogHeader();
|
||||||
|
|
||||||
void beginSDLogging()
|
void beginSDLogging()
|
||||||
{
|
{
|
||||||
if(SD_status == SD_STATUS_READY)
|
if(SD_status == SD_STATUS_READY)
|
||||||
|
@ -217,6 +220,10 @@ void endSDLogging()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward declare
|
||||||
|
void checkForSDStart();
|
||||||
|
void checkForSDStop();
|
||||||
|
|
||||||
void writeSDLogEntry()
|
void writeSDLogEntry()
|
||||||
{
|
{
|
||||||
//Check if we're already running a log
|
//Check if we're already running a log
|
||||||
|
|
|
@ -10,6 +10,9 @@ This is for handling the data broadcasted to various CAN dashes and instrument c
|
||||||
#if defined(NATIVE_CAN_AVAILABLE)
|
#if defined(NATIVE_CAN_AVAILABLE)
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
|
// Forward declare
|
||||||
|
void DashMessage(uint16_t DashMessageID);
|
||||||
|
|
||||||
void sendBMWCluster()
|
void sendBMWCluster()
|
||||||
{
|
{
|
||||||
DashMessage(CAN_BMW_DME1);
|
DashMessage(CAN_BMW_DME1);
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "table2d.h"
|
#include "table2d.h"
|
||||||
#include "table3d.h"
|
#include "table3d.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "logger.h"
|
|
||||||
#include "src/FastCRC/FastCRC.h"
|
#include "src/FastCRC/FastCRC.h"
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
||||||
|
|
|
@ -94,9 +94,13 @@ void initialiseAll(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Unit tests should be independent of any stored configuration on the board!
|
||||||
|
#if !defined(UNIT_TEST)
|
||||||
loadConfig();
|
loadConfig();
|
||||||
doUpdates(); //Check if any data items need updating (Occurs with firmware updates)
|
doUpdates(); //Check if any data items need updating (Occurs with firmware updates)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//Always start with a clean slate on the bootloader capabilities level
|
//Always start with a clean slate on the bootloader capabilities level
|
||||||
//This should be 0 until we hear otherwise from the 16u2
|
//This should be 0 until we hear otherwise from the 16u2
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#define LOGGER_H
|
#define LOGGER_H
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include "globals.h" // Needed for FPU_MAX_SIZE
|
||||||
|
|
||||||
#ifndef UNIT_TEST // Scope guard for unit testing
|
#ifndef UNIT_TEST // Scope guard for unit testing
|
||||||
#define LOG_ENTRY_SIZE 125 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */
|
#define LOG_ENTRY_SIZE 125 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <globals.h>
|
|
||||||
#include <init.h>
|
|
||||||
#include <unity.h>
|
#include <unity.h>
|
||||||
#include <storage.h>
|
#include "globals.h"
|
||||||
|
#include "init.h"
|
||||||
#include "tests_init.h"
|
#include "tests_init.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +120,6 @@ void test_initialisation_outputs_PWM_idle(void)
|
||||||
configPage6.iacChannels = 1;
|
configPage6.iacChannels = 1;
|
||||||
configPage6.iacAlgorithm = 2;
|
configPage6.iacAlgorithm = 2;
|
||||||
|
|
||||||
writeAllConfig(); //Have to save config here to prevent initialiseAll() from overwriting it
|
|
||||||
initialiseAll(); //Run the main initialise function
|
initialiseAll(); //Run the main initialise function
|
||||||
|
|
||||||
bool isIdlePWM = (configPage6.iacAlgorithm > 0) && ((configPage6.iacAlgorithm <= 3) || (configPage6.iacAlgorithm == 6));
|
bool isIdlePWM = (configPage6.iacAlgorithm > 0) && ((configPage6.iacAlgorithm <= 3) || (configPage6.iacAlgorithm == 6));
|
||||||
|
@ -152,6 +150,10 @@ void test_initialisation_outputs_VVT(void)
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_2), "VVT2");
|
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_2), "VVT2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(NOT_A_PIN)
|
||||||
|
#define NOT_A_PIN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t getPinMode(uint8_t pin)
|
uint8_t getPinMode(uint8_t pin)
|
||||||
{
|
{
|
||||||
uint8_t bit = digitalPinToBitMask(pin);
|
uint8_t bit = digitalPinToBitMask(pin);
|
||||||
|
|
|
@ -131,6 +131,15 @@ void test_maths_div100_S16(void)
|
||||||
void test_maths_div100_S32(void)
|
void test_maths_div100_S32(void)
|
||||||
{
|
{
|
||||||
//Check both the signed and unsigned results
|
//Check both the signed and unsigned results
|
||||||
|
#if defined(__arm__)
|
||||||
|
TEST_ASSERT_EQUAL_INT32(1000000L, div100((int)100000000L));
|
||||||
|
TEST_ASSERT_EQUAL_INT32(0, div100((int)0));
|
||||||
|
TEST_ASSERT_EQUAL_INT32(0, div100((int)50));
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT32(-1000000L, div100((int)-100000000L));
|
||||||
|
TEST_ASSERT_EQUAL_INT32(0, div100((int)-50));
|
||||||
|
TEST_ASSERT_EQUAL_INT32(-1, div100((int)-120));
|
||||||
|
#else
|
||||||
TEST_ASSERT_EQUAL_INT32(1000000L, div100((int32_t)100000000L));
|
TEST_ASSERT_EQUAL_INT32(1000000L, div100((int32_t)100000000L));
|
||||||
TEST_ASSERT_EQUAL_INT32(0, div100((int32_t)0));
|
TEST_ASSERT_EQUAL_INT32(0, div100((int32_t)0));
|
||||||
TEST_ASSERT_EQUAL_INT32(0, div100((int32_t)50));
|
TEST_ASSERT_EQUAL_INT32(0, div100((int32_t)50));
|
||||||
|
@ -138,4 +147,5 @@ void test_maths_div100_S32(void)
|
||||||
TEST_ASSERT_EQUAL_INT32(-1000000L, div100((int32_t)-100000000L));
|
TEST_ASSERT_EQUAL_INT32(-1000000L, div100((int32_t)-100000000L));
|
||||||
TEST_ASSERT_EQUAL_INT32(0, div100((int32_t)-50));
|
TEST_ASSERT_EQUAL_INT32(0, div100((int32_t)-50));
|
||||||
TEST_ASSERT_EQUAL_INT32(-1, div100((int32_t)-120));
|
TEST_ASSERT_EQUAL_INT32(-1, div100((int32_t)-120));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue