Skip to content

Commit

Permalink
Fixed Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabryelreyes committed Nov 20, 2023
1 parent 28b17d4 commit 2ac3ad0
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions test/test_SerialMuxProt/test_SerialMuxProt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

static void setup();
static void loop();
static void testChannelCallback(const uint8_t *payload, uint8_t payloadSize);
static void testChannelCallback(const uint8_t* payload, uint8_t payloadSize);
static void testCmdSync();
static void testCmdSyncRsp();
static void testCmdScrb();
Expand All @@ -68,11 +68,11 @@ static void testDataSend();
* Local Variables
*****************************************************************************/

static uint8_t emptyOutputBuffer[MAX_FRAME_LEN];
static TestStream gTestStream;
static uint8_t emptyOutputBuffer[MAX_FRAME_LEN];
static TestStream gTestStream;
static const uint8_t controlChannelFrameLength = (HEADER_LEN + CONTROL_CHANNEL_PAYLOAD_LENGTH);
static const uint8_t testPayload[4U] = {0x12, 0x34, 0x56, 0x78};
static bool callbackCalled = false;
static const uint8_t testPayload[4U] = {0x12, 0x34, 0x56, 0x78};
static bool callbackCalled = false;

/******************************************************************************
* Public Methods
Expand All @@ -95,7 +95,7 @@ static bool callbackCalled = false;
* @param[in] argc Number of arguments
* @param[in] argv Arguments
*/
int main(int argc, char **argv)
int main(int argc, char** argv)
{
setup(); /* Prepare test */
loop(); /* Run test once */
Expand Down Expand Up @@ -165,8 +165,9 @@ extern void tearDown(void)
* Callback for incoming data from test channel.
* @param[in] payload Byte buffer containing incomming data.
* @param[in] payloadSize Number of bytes received.
* @param[in] userData User data provided by the application.
*/
static void testChannelCallback(const uint8_t *payload, uint8_t payloadSize)
static void testChannelCallback(const uint8_t* payload, uint8_t payloadSize, void* userData)
{
callbackCalled = true;
TEST_ASSERT_EQUAL_UINT8_ARRAY(testPayload, payload, payloadSize);
Expand All @@ -178,7 +179,7 @@ static void testChannelCallback(const uint8_t *payload, uint8_t payloadSize)
static void testCmdSync()
{
SerialMuxProtServer<2U> testSerialMuxProtServer(gTestStream);
uint8_t expectedOutputBufferVector[6U][MAX_FRAME_LEN] = {
uint8_t expectedOutputBufferVector[6U][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0xFA, 0x00, 0x00, 0x00, 0x03, 0xE8}, /* SYNC 1000ms*/
{0x00, 0x0F, 0xE6, 0x00, 0x00, 0x00, 0x07, 0xD0}, /* SYNC 2000ms*/
{0x00, 0x0F, 0x82, 0x00, 0x00, 0x00, 0x1B, 0x58}, /* SYNC 7000ms*/
Expand Down Expand Up @@ -289,9 +290,9 @@ static void testCmdSync()
static void testCmdSyncRsp()
{
SerialMuxProtServer<2U> testSerialMuxProtServer(gTestStream);
uint8_t testTime = 0U;
uint8_t numberOfCases = 3U;
uint8_t expectedOutputBufferVector[numberOfCases][MAX_FRAME_LEN] = {
uint8_t testTime = 0U;
uint8_t numberOfCases = 3U;
uint8_t expectedOutputBufferVector[numberOfCases][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x0F, 0x25, 0x01, 0x12, 0x34, 0x56, 0x78},
{0x00, 0x0F, 0x10, 0x01, 0xFF, 0xFF, 0xFF, 0xFF}};
Expand Down Expand Up @@ -322,9 +323,9 @@ static void testCmdSyncRsp()
static void testCmdScrb()
{
SerialMuxProtServer<2U> testSerialMuxProtServer(gTestStream);
uint8_t testTime = 0U;
uint8_t numberOfCases = 2U;
uint8_t expectedOutputBufferVector[numberOfCases][MAX_FRAME_LEN] = {
uint8_t testTime = 0U;
uint8_t numberOfCases = 2U;
uint8_t expectedOutputBufferVector[numberOfCases][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0x53, 0x03, 0x00, 'T', 'E', 'S', 'T'}, {0x00, 0x0F, 0x54, 0x03, 0x01, 'T', 'E', 'S', 'T'}};
uint8_t inputQueueVector[numberOfCases][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0x52, 0x02, 'T', 'E', 'S', 'T', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
Expand Down Expand Up @@ -374,9 +375,9 @@ static void testCmdScrb()
static void testCmdScrbRsp()
{
SerialMuxProtServer<2U> testSerialMuxProtServer(gTestStream);
uint8_t testTime = 1U;
uint8_t numberOfCases = 3U;
uint8_t expectedOutputBufferVector[numberOfCases][MAX_FRAME_LEN] = {
uint8_t testTime = 1U;
uint8_t numberOfCases = 3U;
uint8_t expectedOutputBufferVector[numberOfCases][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0x52, 0x02, 'T', 'E', 'S', 'T', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
uint8_t inputQueueVector[numberOfCases][MAX_FRAME_LEN] = {{0x00, 0x0F, 0x10, 0x01, 0x00, 0x00, 0x00},
{0x00, 0x0F, 0x53, 0x03, 0x00, 'T', 'E', 'S', 'T'},
Expand Down Expand Up @@ -462,7 +463,7 @@ static void testCmdScrbRsp()
*/
static void testChannelCreation()
{
const uint8_t maxChannels = 5U;
const uint8_t maxChannels = 5U;
SerialMuxProtServer<maxChannels> testSerialMuxProtServer(gTestStream);

/* No Channels Configured on Start */
Expand Down Expand Up @@ -505,7 +506,7 @@ static void testDataSend()
{
SerialMuxProtServer<1U> testSerialMuxProtServer(gTestStream);
uint8_t expectedOutputBufferVector[1U][MAX_FRAME_LEN] = {{0x01, 0x04, 0x1A, 0x12, 0x34, 0x56, 0x78}};
uint8_t inputQueueVector[1U][MAX_FRAME_LEN] = {{0x00, 0x0F, 0x10, 0x01, 0x00, 0x00, 0x00}};
uint8_t inputQueueVector[1U][MAX_FRAME_LEN] = {{0x00, 0x0F, 0x10, 0x01, 0x00, 0x00, 0x00}};

/* Flush Stream */
gTestStream.flushInputBuffer();
Expand Down

0 comments on commit 2ac3ad0

Please sign in to comment.