Additonal schedule initialization unit tests (#1046)
* const * Add RUN_TEST_P * Reduce test memory usage. * More granular fuel tests - better failure reports * More granular ignition tests - better failure reports * Add unit tests for no injection timing * Add fuel schedule oddfire tests * Unit test ignition odd fire
This commit is contained in:
parent
805a535238
commit
18501d4cbd
|
@ -269,4 +269,6 @@ void tachoOutputOff(void);
|
|||
|
||||
void nullCallback(void);
|
||||
|
||||
typedef void (*voidVoidCallback)(void);
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,8 +4,9 @@
|
|||
#include "init.h"
|
||||
#include "schedule_calcs.h"
|
||||
#include "scheduledIO.h"
|
||||
#include "..\test_utils.h"
|
||||
|
||||
static void assert_ignition_channel(uint16_t angle, uint8_t channel, int channelInjDegrees, void (*startFunction)(void), void (*endFunction)(void))
|
||||
static void assert_ignition_channel(uint16_t angle, uint8_t channel, int channelInjDegrees, voidVoidCallback startFunction, voidVoidCallback endFunction)
|
||||
{
|
||||
char msg[32];
|
||||
|
||||
|
@ -17,7 +18,7 @@ static void assert_ignition_channel(uint16_t angle, uint8_t channel, int channel
|
|||
TEST_ASSERT_TRUE_MESSAGE(channel>=maxIgnOutputs || (endFunction!=nullCallback), msg);
|
||||
}
|
||||
|
||||
static void assert_ignition_schedules(uint16_t crankAngle, uint16_t expectedOutputs, uint16_t angle[])
|
||||
static void assert_ignition_schedules(uint16_t crankAngle, uint16_t expectedOutputs, const uint16_t angle[])
|
||||
{
|
||||
char msg[48];
|
||||
|
||||
|
@ -44,170 +45,264 @@ static void assert_ignition_schedules(uint16_t crankAngle, uint16_t expectedOutp
|
|||
#endif
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_1_cylinder(void)
|
||||
static void cylinder1_stroke4_seq_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 1U, angle);
|
||||
}
|
||||
|
||||
static void cylinder1_stroke4_wasted_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 1U, angle);
|
||||
}
|
||||
|
||||
static void cylinder1_stroke4_seq_odd(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = ODD_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 1U, angle);
|
||||
}
|
||||
|
||||
static void run_1_cylinder_4stroke_tests(void)
|
||||
{
|
||||
configPage2.nCylinders = 1;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 1U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 1U, angle);
|
||||
}
|
||||
RUN_TEST_P(cylinder1_stroke4_seq_even);
|
||||
RUN_TEST_P(cylinder1_stroke4_wasted_even);
|
||||
RUN_TEST_P(cylinder1_stroke4_seq_odd);
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_2_cylinder(void)
|
||||
static void cylinder2_stroke4_seq_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 2U, angle);
|
||||
}
|
||||
|
||||
static void cylinder2_stroke4_wasted_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 2U, angle);
|
||||
}
|
||||
|
||||
static void cylinder2_stroke4_seq_odd(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = ODD_FIRE;
|
||||
configPage2.oddfire2 = 13;
|
||||
configPage2.oddfire3 = 111;
|
||||
configPage2.oddfire4 = 217;
|
||||
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,13,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 2U, angle);
|
||||
}
|
||||
|
||||
static void run_2_cylinder_4stroke_tests(void)
|
||||
{
|
||||
configPage2.nCylinders = 2;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 2U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 2U, angle);
|
||||
}
|
||||
RUN_TEST_P(cylinder2_stroke4_seq_even);
|
||||
RUN_TEST_P(cylinder2_stroke4_wasted_even);
|
||||
RUN_TEST_P(cylinder2_stroke4_seq_odd);
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_3_cylinder(void)
|
||||
static void cylinder3_stroke4_seq_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,240,480,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 3U, angle);
|
||||
}
|
||||
|
||||
static void cylinder3_stroke4_wasted_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
}
|
||||
|
||||
static void cylinder3_stroke4_wasted_odd(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
configPage2.engineType = ODD_FIRE;
|
||||
configPage2.oddfire2 = 13;
|
||||
configPage2.oddfire3 = 111;
|
||||
configPage2.oddfire4 = 217;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,13,111,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
}
|
||||
|
||||
static void run_3_cylinder_4stroke_tests(void)
|
||||
{
|
||||
configPage2.nCylinders = 3;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,240,480,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 3U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
}
|
||||
RUN_TEST_P(cylinder3_stroke4_seq_even);
|
||||
RUN_TEST_P(cylinder3_stroke4_wasted_even);
|
||||
RUN_TEST_P(cylinder3_stroke4_wasted_odd);
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_4_cylinder(void)
|
||||
static void cylinder4_stroke4_seq_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,180,360,540,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 4U, angle);
|
||||
}
|
||||
|
||||
static void cylinder4_stroke4_wasted_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 2U, angle);
|
||||
}
|
||||
|
||||
static void cylinder4_stroke4_seq_odd(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = ODD_FIRE;
|
||||
configPage2.oddfire2 = 13;
|
||||
configPage2.oddfire3 = 111;
|
||||
configPage2.oddfire4 = 217;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,13,111,217,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 4U, angle);
|
||||
}
|
||||
|
||||
|
||||
static void run_4_cylinder_4stroke_tests(void)
|
||||
{
|
||||
configPage2.nCylinders = 4;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,180,360,540,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 4U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 2U, angle);
|
||||
}
|
||||
RUN_TEST_P(cylinder4_stroke4_seq_even);
|
||||
RUN_TEST_P(cylinder4_stroke4_wasted_even);
|
||||
RUN_TEST_P(cylinder4_stroke4_seq_odd);
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_5_cylinder(void)
|
||||
static void cylinder5_stroke4_seq_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,144,288,432,576,0,0,0};
|
||||
assert_ignition_schedules(720U, 5U, angle);
|
||||
}
|
||||
|
||||
static void cylinder5_stroke4_wasted_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,72,144,216,288,0,0,0};
|
||||
assert_ignition_schedules(360U, 5U, angle);
|
||||
}
|
||||
|
||||
static void run_5_cylinder_4stroke_tests(void)
|
||||
{
|
||||
configPage2.nCylinders = 5;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,144,288,432,576,0,0,0};
|
||||
assert_ignition_schedules(720U, 5U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,72,144,216,288,0,0,0};
|
||||
assert_ignition_schedules(360U, 5U, angle);
|
||||
}
|
||||
RUN_TEST_P(cylinder5_stroke4_seq_even);
|
||||
RUN_TEST_P(cylinder5_stroke4_wasted_even);
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_6_cylinder(void)
|
||||
static void cylinder6_stroke4_seq_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
#if IGN_CHANNELS >= 6
|
||||
const uint16_t angle[] = {0,120,240,360,480,540,0,0};
|
||||
assert_ignition_schedules(720U, 6U, angle);
|
||||
#else
|
||||
const uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cylinder6_stroke4_wasted_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
}
|
||||
|
||||
static void run_6_cylinder_4stroke_tests(void)
|
||||
{
|
||||
configPage2.nCylinders = 6;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if IGN_CHANNELS >= 6
|
||||
uint16_t angle[] = {0,120,240,360,480,540,0,0};
|
||||
assert_ignition_schedules(720U, 6U, angle);
|
||||
#else
|
||||
uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
}
|
||||
RUN_TEST_P(cylinder6_stroke4_seq_even);
|
||||
RUN_TEST_P(cylinder6_stroke4_wasted_even);
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_8_cylinder(void)
|
||||
|
||||
static void cylinder8_stroke4_seq_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
#if IGN_CHANNELS >= 8
|
||||
const uint16_t angle[] = {0,90,180,270,360,450,540,630};
|
||||
assert_ignition_schedules(720U, 8U, angle);
|
||||
#else
|
||||
const uint16_t angle[] = {0,90,180,270,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 4U, angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cylinder8_stroke4_wasted_even(void)
|
||||
{
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
const uint16_t angle[] = {0,90,180,270,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 4U, angle);
|
||||
}
|
||||
|
||||
static void run_8_cylinder_4stroke_tests(void)
|
||||
{
|
||||
configPage2.nCylinders = 8;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if IGN_CHANNELS >= 8
|
||||
uint16_t angle[] = {0,90,180,270,360,450,540,630};
|
||||
assert_ignition_schedules(720U, 8U, angle);
|
||||
#else
|
||||
uint16_t angle[] = {0,90,180,270,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 4U, angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,90,180,270,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 4U, angle);
|
||||
}
|
||||
RUN_TEST_P(cylinder8_stroke4_seq_even);
|
||||
RUN_TEST_P(cylinder8_stroke4_wasted_even);
|
||||
}
|
||||
|
||||
void testIgnitionScheduleInit()
|
||||
{
|
||||
RUN_TEST(test_ignition_schedule_1_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_2_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_3_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_4_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_5_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_6_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_8_cylinder);
|
||||
run_1_cylinder_4stroke_tests();
|
||||
run_2_cylinder_4stroke_tests();
|
||||
run_3_cylinder_4stroke_tests();
|
||||
run_4_cylinder_4stroke_tests();
|
||||
run_5_cylinder_4stroke_tests();
|
||||
run_6_cylinder_4stroke_tests();
|
||||
run_8_cylinder_4stroke_tests();
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
#include <unity.h>
|
||||
#include "globals.h"
|
||||
#include "init.h"
|
||||
#include "..\test_utils.h"
|
||||
|
||||
#define UNKNOWN_PIN 0xFF
|
||||
|
||||
|
@ -220,12 +221,12 @@ void test_initialisation_outputs_VVT(void)
|
|||
|
||||
void testInitialisation()
|
||||
{
|
||||
RUN_TEST(test_initialisation_complete);
|
||||
RUN_TEST(test_initialisation_ports);
|
||||
RUN_TEST(test_initialisation_outputs_V03);
|
||||
RUN_TEST(test_initialisation_outputs_V04);
|
||||
RUN_TEST(test_initialisation_outputs_MX5_8995);
|
||||
RUN_TEST(test_initialisation_outputs_PWM_idle);
|
||||
RUN_TEST(test_initialisation_outputs_boost);
|
||||
RUN_TEST(test_initialisation_outputs_VVT);
|
||||
RUN_TEST_P(test_initialisation_complete);
|
||||
RUN_TEST_P(test_initialisation_ports);
|
||||
RUN_TEST_P(test_initialisation_outputs_V03);
|
||||
RUN_TEST_P(test_initialisation_outputs_V04);
|
||||
RUN_TEST_P(test_initialisation_outputs_MX5_8995);
|
||||
RUN_TEST_P(test_initialisation_outputs_PWM_idle);
|
||||
RUN_TEST_P(test_initialisation_outputs_boost);
|
||||
RUN_TEST_P(test_initialisation_outputs_VVT);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
// Unity macro to reduce memory usage (RAM, .bss)
|
||||
//
|
||||
// Unity supplied RUN_TEST captures the function name
|
||||
// using #func directly in the call to UnityDefaultTestRun.
|
||||
// This is a raw string that is placed in the data segment,
|
||||
// which consumes RAM.
|
||||
//
|
||||
// So instead, place the function name in flash memory and
|
||||
// load it at run time.
|
||||
#define RUN_TEST_P(func) \
|
||||
{ \
|
||||
char funcName[64]; \
|
||||
strcpy_P(funcName, PSTR(#func)); \
|
||||
UnityDefaultTestRun(func, funcName, __LINE__); \
|
||||
}
|
Loading…
Reference in New Issue