Skip to content

Commit

Permalink
kinda functional sendcarcan test with new test framework way of writi…
Browse files Browse the repository at this point in the history
…y of writing tests, may be deemed un-useful and removed later on. going to keep it on sendcarcan_test branch for now.
  • Loading branch information
IshDeshpa committed Sep 25, 2023
1 parent 923eee9 commit 5278640
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions Tests/Leader/Test_App_SendCarCAN.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,57 @@

#include "BSP_ADC.h"

#define TEST_USE_RTOS 1
// Import test runner
#define USE_OS
#include "Test_Runner.h"

// static OS_TMR IOStateTestTmr;

static CANDATA_t checkData;

// Test Functions (Each test function should test one aspect of code functionality)
// Test Cases
static void Test_IOState(){
OS_ERR err;

// Check for IO State CAN message here
// Data should be default system state
OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT);
__asm("bkpt");
OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT, &err);

// Change state for some outputs
Contactors_Set(MOTOR_CONTACTOR, true, true);
Minions_Write(BRAKELIGHT, true);

// Check for IO State CAN message here
// Data should be changed according to change in outputs
OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT);
__asm("bkpt");

// Once breakpoint is hit, change some inputs to system
// Then check if appropriate change has been made to CAN message
OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT);
__asm("bkpt");
OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT, &err);

for(int i=0; i<5; i++){
// Once breakpoint is hit, change some inputs to system
// Then check if appropriate change has been made to CAN message
OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT, &err); // Breakpoint here
}
}

static void Test_Send
static void Test_ControlMode(){
OS_ERR err;

OSTaskCreate(
(OS_TCB *)&SendTritium_TCB,
(CPU_CHAR *)"SendTritium",
(OS_TASK_PTR)Task_SendTritium,
(void *)NULL,
(OS_PRIO)TASK_SEND_TRITIUM_PRIO,
(CPU_STK *)SendTritium_Stk,
(CPU_STK_SIZE)DEFAULT_STACK_SIZE,
(CPU_STK_SIZE)DEFAULT_STACK_SIZE,
(OS_MSG_QTY)0,
(OS_TICK)NULL,
(void *)NULL,
(OS_OPT)(OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);

for(int i=0; i<5; i++){
// Once breakpoint is hit, change some inputs to system
// Then check if appropriate change has been made to CAN message
OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT, &err); // Breakpoint here
}
}

// Test Drivers
void Test_Setup(){
Expand All @@ -51,16 +70,13 @@ void Test_Setup(){
Pedals_Init();
Minions_Init();

checkData.ID = IO_STATE;
return;
}

void Test_Start(){
// Spawn necessary applications
OS_ERR err;

SendCarCAN_Init();

OSTaskCreate(
(OS_TCB *)&SendCarCAN_TCB,
(CPU_CHAR *)"SendCarCAN",
Expand All @@ -76,20 +92,10 @@ void Test_Start(){
(OS_OPT)(OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
assertOSError(OS_MAIN_LOC, err);

// OSTmrCreate(&IOStateTestTmr,
// "IO State Test Timer",
// 0,
// IO_STATE_TMR_DLY_TS,
// OS_OPT_TMR_ONE_SHOT,
// IOStateTestHandler,
// NULL,
// &err
// );
// assertOSError(OS_MAIN_LOC, err);

// Run all test functions here
Test_IOState();
Test_ControlMode();

return;
}

0 comments on commit 5278640

Please sign in to comment.