diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7c1a5dcce..81e547de2 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -15,9 +15,12 @@ defaults:
shell: bash
jobs:
- unit-tests:
- name: Unit tests
- runs-on: windows-latest
+ tests-run:
+ name: Tests run
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Check out Luos repository
uses: actions/checkout@v3
@@ -36,10 +39,17 @@ jobs:
- name: Run PlatformIO Unit Tests
run: |
# Clean all projects
- platformio run -t clean -c ./test/_resources/platformio.ini
+ platformio run -t clean
# Run Unit tests
- platformio test -c ./test/_resources/platformio.ini -vvv
+ platformio test -vvv
+
+ unit-tests:
+ name: Unit tests
+ needs: tests-run
+ runs-on: ubuntu-latest
+ steps:
+ - run: echo "Tests succeed!"
code-format:
name: Code format
diff --git a/test/_resources/Mock/luos_hal.c b/engine/HAL/STUB/luos_hal.c
similarity index 100%
rename from test/_resources/Mock/luos_hal.c
rename to engine/HAL/STUB/luos_hal.c
diff --git a/test/_resources/Mock/luos_hal.h b/engine/HAL/STUB/luos_hal.h
similarity index 100%
rename from test/_resources/Mock/luos_hal.h
rename to engine/HAL/STUB/luos_hal.h
diff --git a/test/_resources/Mock/luos_hal_config.h b/engine/HAL/STUB/luos_hal_config.h
similarity index 100%
rename from test/_resources/Mock/luos_hal_config.h
rename to engine/HAL/STUB/luos_hal_config.h
diff --git a/engine/core/src/luos_utils.c b/engine/core/src/luos_utils.c
index bc53b4035..91064b0fe 100644
--- a/engine/core/src/luos_utils.c
+++ b/engine/core/src/luos_utils.c
@@ -30,6 +30,7 @@ __attribute__((weak)) void node_assert(char *file, uint32_t line)
return;
}
+#ifndef UNIT_TEST
/******************************************************************************
* @brief Luos assertion management
* @param file : File name as a string
@@ -37,7 +38,7 @@ __attribute__((weak)) void node_assert(char *file, uint32_t line)
* @return None
* warning : this function can be redefined only for mock testing purpose
******************************************************************************/
-_CRITICAL _WEAKED void Luos_assert(char *file, uint32_t line)
+_CRITICAL void Luos_assert(char *file, uint32_t line)
{
// prepare a message as a node.
// To do that we have to reset the service ID and clear PTP states to unlock others.
@@ -57,15 +58,16 @@ _CRITICAL _WEAKED void Luos_assert(char *file, uint32_t line)
// wait for the transmission to finish before killing IRQ
while (MsgAlloc_TxAllComplete() == FAILED)
;
-#ifdef WITH_BOOTLOADER
+ #ifdef WITH_BOOTLOADER
// We're in a failed app,
// Restart this node in bootloader mode instead of don't do anything
// We will come back on this app after a reboot.
// Set bootloader mode, save node ID and reboot
LuosBootloader_JumpToBootloader();
-#endif
+ #endif
LuosHAL_SetIrqState(false);
while (1)
{
}
}
+#endif
diff --git a/engine/core/src/routing_table.c b/engine/core/src/routing_table.c
index b484b40ec..44384c18b 100644
--- a/engine/core/src/routing_table.c
+++ b/engine/core/src/routing_table.c
@@ -218,7 +218,7 @@ static void RoutingTB_AddNumToAlias(char *alias, uint8_t num)
* @param intro_msg : into route table message
* @return None
******************************************************************************/
-_WEAKED bool RoutingTB_WaitRoutingTable(service_t *service, msg_t *intro_msg)
+bool RoutingTB_WaitRoutingTable(service_t *service, msg_t *intro_msg)
{
const uint8_t timeout = 15; // timeout in ms
const uint16_t entry_bkp = last_routing_table_entry;
@@ -499,7 +499,7 @@ uint16_t RoutingTB_GetLastEntry(void)
/******************************************************************************
* @brief Check if result is in routing table
* @param result : Pointer to search result structure
- * @return SUCCEED : If the result address is available, else FAILED
+ * @return SUCCEED : If the result address is available, else FAILED
******************************************************************************/
error_return_t RTFilter_InitCheck(search_result_t *result)
diff --git a/test/_resources/Mock/robus_hal.c b/network/robus/HAL/STUB/robus_hal.c
similarity index 98%
rename from test/_resources/Mock/robus_hal.c
rename to network/robus/HAL/STUB/robus_hal.c
index 5fea785c3..deeb8a9d6 100644
--- a/test/_resources/Mock/robus_hal.c
+++ b/network/robus/HAL/STUB/robus_hal.c
@@ -96,6 +96,8 @@ void RobusHAL_SetRxState(uint8_t Enable)
******************************************************************************/
void RobusHAL_ComTransmit(uint8_t *data, uint16_t size)
{
+ // We consider this information sent
+ Recep_Timeout();
}
/******************************************************************************
@@ -114,6 +116,7 @@ void RobusHAL_SetRxDetecPin(uint8_t Enable)
******************************************************************************/
uint8_t RobusHAL_GetTxLockState(void)
{
+ return 0;
}
/******************************************************************************
diff --git a/test/_resources/Mock/robus_hal.h b/network/robus/HAL/STUB/robus_hal.h
similarity index 100%
rename from test/_resources/Mock/robus_hal.h
rename to network/robus/HAL/STUB/robus_hal.h
diff --git a/test/_resources/Mock/robus_hal_config.h b/network/robus/HAL/STUB/robus_hal_config.h
similarity index 100%
rename from test/_resources/Mock/robus_hal_config.h
rename to network/robus/HAL/STUB/robus_hal_config.h
diff --git a/network/robus/src/reception.c b/network/robus/src/reception.c
index 18fe0dd0a..571a8748b 100644
--- a/network/robus/src/reception.c
+++ b/network/robus/src/reception.c
@@ -460,7 +460,7 @@ _CRITICAL static inline error_return_t Recep_TopicCompare(uint16_t topic_id)
* warning : this function can be redefined only for mock testing purpose
* _CRITICAL function call in IRQ
******************************************************************************/
-_WEAKED _CRITICAL luos_localhost_t Recep_NodeConcerned(header_t *header)
+_CRITICAL luos_localhost_t Recep_NodeConcerned(header_t *header)
{
uint16_t i = 0;
diff --git a/test/_resources/platformio.ini b/platformio.ini
similarity index 88%
rename from test/_resources/platformio.ini
rename to platformio.ini
index 9552c102d..38826d289 100644
--- a/test/_resources/platformio.ini
+++ b/platformio.ini
@@ -17,12 +17,16 @@ platform = native
lib_deps=
throwtheswitch/Unity
+test_framework = unity
lib_extra_dirs = $PROJECT_DIR/../
+build_unflags = -Os
build_flags =
+ -O1
-include ./test/_resources/node_config.h
-DUNIT_TEST
+ -D LUOSHAL=STUB
build_type = debug
test_build_src = true
@@ -30,4 +34,4 @@ test_build_src = true
; To debug a test :
; 1) Copy this file in Luos root directory
; 2) Replace "test_template" by the directory test name you want to debug (example : "routing_table")
-debug_test = test_template
+;debug_test = test_template
diff --git a/source_filter_script.py b/source_filter_script.py
index 97bc84a9b..b91fe50a2 100644
--- a/source_filter_script.py
+++ b/source_filter_script.py
@@ -101,46 +101,38 @@
"\t* Telemetry disabled, please consider enabling it by removing the 'NOTELEMETRY' flag to help Luos_engine improve.", fg="red")
click.secho("")
-# Native only
-find_MOCK_HAL = False
+# Native only => we should put this on a specific script on engine/HAL/STUB
for item in env.ParseFlags(env['BUILD_FLAGS'])["CPPDEFINES"]:
if (item == 'UNIT_TEST'):
click.secho("Native unit testing:", underline=True)
current_os = pf.system()
- if find_MOCK_HAL == False:
- click.secho("\t* Native Mock HAL for %s is selected for Luos and Robus." % current_os, fg="green")
- find_MOCK_HAL = True
- find_HAL = True
- env.Replace(SRC_FILTER=sources)
- env.Append(SRC_FILTER=["-"])
+ click.secho("\t* Native Mock HAL for %s is selected for Luos and Robus." %
+ current_os, fg="green")
+
env.Append(SRC_FILTER=["+<../../../test/_resources/*>"])
for resources in scandir(getcwd() + "/test/_resources"):
if resources.is_dir():
env.Append(CPPPATH=[(resources.path)])
- if (current_os == 'Linux') or (current_os == 'Darwin'):
- env.Append(LINKFLAGS=["-m32"])
- elif current_os == 'Windows':
- env.Append(LINKFLAGS=["-lgcov"])
- env.Append(LINKFLAGS=["--coverage"])
- env.Append(LINKFLAGS=["-fprofile-arcs"])
-
- def generateCoverageInfo(source, target, env):
- for file in os.listdir("test"):
- env.Execute(".pio/build/native/program test/"+file)
- env.Execute("lcov -d .pio/build/native/ -c -o lcov.info")
- env.Execute(
- "lcov --remove lcov.info '*/tool-unity/*' '*/test/*' -o filtered_lcov.info")
- env.Execute(
- "genhtml -o cov/ --demangle-cpp filtered_lcov.info")
-
- # Generate code coverage when testing workflow is ended
- # CODE COVERAGE WILL BE ADDED SOON
- # env.AddPostAction(".pio/build/native/program", generateCoverageInfo)
- else:
- click.echo("Unit tests are not supported on your os ", current_os)
- break
- else:
+ # CODE COVERAGE WILL BE ADDED SOON
+ # if (current_os == 'Linux') or (current_os == 'Darwin') or (current_os == 'Windows'):
+ # env.Append(LINKFLAGS=["-lgcov"])
+ # env.Append(LINKFLAGS=["--coverage"])
+ # env.Append(LINKFLAGS=["-fprofile-arcs"])
+
+ # def generateCoverageInfo(source, target, env):
+ # for file in os.listdir("test"):
+ # env.Execute(".pio/build/native/program test/"+file)
+ # env.Execute("lcov -d .pio/build/native/ -c -o lcov.info")
+ # env.Execute(
+ # "lcov --remove lcov.info '*/tool-unity/*' '*/test/*' -o filtered_lcov.info")
+ # env.Execute(
+ # "genhtml -o cov/ --demangle-cpp filtered_lcov.info")
+
+ # Generate code coverage when testing workflow is ended
+ # env.AddPostAction(".pio/build/native/program", generateCoverageInfo)
+ # else:
+ # click.echo("Unit tests are not supported on your os ", current_os)
break
if not visited_key in global_env:
diff --git a/test/_resources/Mock/Mock_Luos_Assert.c b/test/_resources/Mock/Mock_Luos_Assert.c
deleted file mode 100644
index 36bcd8da7..000000000
--- a/test/_resources/Mock/Mock_Luos_Assert.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/******************************************************************************
- * @file Mock_Luos_Assert.c
- * @brief Mock function Luos_Assert()
- * @author Luos
- * @version 1.0.0
- ******************************************************************************/
-#ifdef UNIT_TEST
- #include "unit_test.h"
-#else
- #include "luos_hal.h"
-#endif
-/*******************************************************************************
- * Function
- ******************************************************************************/
-
-/******************************************************************************
- * @brief Mock : Redefine function Luos_assert
- * @param file name as a string
- * @param line number
- * @return None
- ******************************************************************************/
-void Luos_assert(char *file, uint32_t line)
-{
-#ifdef UNIT_TEST
- UNIT_TEST_ASSERT(file, line);
-#endif
-}
diff --git a/test/_resources/Mock/Mock_Recep_NodeConcerned.c b/test/_resources/Mock/Mock_Recep_NodeConcerned.c
deleted file mode 100644
index 4facee45c..000000000
--- a/test/_resources/Mock/Mock_Recep_NodeConcerned.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/******************************************************************************
- * @file Mock_Recep_NodeConcerned.c
- * @brief Mock function Recep_NodeConcerned()
- * @author Luos
- * @version 1.0.0
- ******************************************************************************/
-#include "context.h"
-#include "luos_hal.h"
-/*******************************************************************************
- * Function
- ******************************************************************************/
-/******************************************************************************
- * @brief Mock : Redefine function Recep_NodeConcerned
- * @param header of message
- * @return Always returns LOCALHOST
- ******************************************************************************/
-luos_localhost_t Recep_NodeConcerned(header_t *header)
-{
- // Right now, Mock is unable to emulate external Nodes.
- // So context is initialized to "localhost" to launch a detection without any trouble.
- uint16_t i = 0;
- switch (header->target_mode)
- {
- case SERVICEIDACK:
- case NODEIDACK:
- ctx.rx.status.rx_error = false;
- break;
- default:
- break;
- }
- return LOCALHOST;
-}
diff --git a/test/_resources/Mock/Mock_RoutingTB_WaitRoutingTable.c b/test/_resources/Mock/Mock_RoutingTB_WaitRoutingTable.c
deleted file mode 100644
index 6e2eed9cd..000000000
--- a/test/_resources/Mock/Mock_RoutingTB_WaitRoutingTable.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/******************************************************************************
- * @file Mock_RoutingTB_WaitRoutingTable.c
- * @brief Mock function RoutingTB_WaitRoutingTable()
- * @author Luos
- * @version 1.0.0
- ******************************************************************************/
-#ifdef UNIT_TEST
- #include "unit_test.h"
-#else
- #include "luos_hal.h"
-#endif
-#include "service_structs.h"
-
-/*******************************************************************************
- * Function
- ******************************************************************************/
-/******************************************************************************
- * @brief Mock : Redefine function RoutingTB_WaitRoutingTable
- * @param service receive
- * @param intro msg in route table
- * @return None
- ******************************************************************************/
-bool RoutingTB_WaitRoutingTable(service_t *service, msg_t *intro_msg)
-{
- const uint8_t timeout = 150; // timeout in ms
- Luos_SendMsg(service, intro_msg);
- uint32_t timestamp = LuosHAL_GetSystick();
- Luos_Loop();
- while ((LuosHAL_GetSystick() - timestamp) < timeout)
- ;
- Luos_Loop();
- return true;
-}
\ No newline at end of file
diff --git a/test/_resources/Scenarios/default_scenario.c b/test/_resources/Scenarios/default_scenario.c
index 2708eeab7..0a7aa9824 100644
--- a/test/_resources/Scenarios/default_scenario.c
+++ b/test/_resources/Scenarios/default_scenario.c
@@ -5,37 +5,16 @@
* @version 1.0.0
******************************************************************************/
#include
-#include "context.h"
#include "default_scenario.h"
-#include "unit_test.h"
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-#define LUOS_TASK_NUMBER 3
-#define TX_TASK_NUMBER 3
/*******************************************************************************
* Variables
******************************************************************************/
-
default_scenario_t default_sc;
-extern volatile uint8_t msg_buffer[MSG_BUFFER_SIZE];
-
-volatile uint8_t *transmit_msg;
-msg_t receive_msg[DUMMY_SERVICE_NUMBER];
-uint8_t stream_Buffer1[STREAM_BUFFER_SIZE] = {0};
-uint8_t stream_Buffer2[STREAM_BUFFER_SIZE] = {0};
-streaming_channel_t Default_StreamChannel1;
-streaming_channel_t Default_StreamChannel2;
/*******************************************************************************
* Function
******************************************************************************/
-extern void MsgAlloc_LuosTaskAlloc(ll_service_t *service_concerned_by_current_msg, msg_t *concerned_msg);
-
-static void Reset_Streaming(void);
-static void Init_Messages(void);
static void Detection(service_t *service);
static void App_1_MsgHandler(service_t *service, msg_t *msg);
static void App_2_MsgHandler(service_t *service, msg_t *msg);
@@ -48,6 +27,18 @@ static void App_3_MsgHandler(service_t *service, msg_t *msg);
******************************************************************************/
void Init_Context(void)
{
+ // Reset context
+ RESET_ASSERT();
+ Luos_ServicesClear();
+ RoutingTB_Erase(); // Delete RTB
+ Luos_Init();
+ if (IS_ASSERT())
+ {
+ printf("[FATAL] Can't reset scenario context\n");
+ TEST_ASSERT_TRUE(IS_ASSERT());
+ }
+ Luos_Loop();
+
RESET_ASSERT();
Luos_Init();
@@ -57,21 +48,10 @@ void Init_Context(void)
default_sc.App_2.app = Luos_CreateService(App_2_MsgHandler, VOID_TYPE, "Dummy_App_2", revision);
default_sc.App_3.app = Luos_CreateService(App_3_MsgHandler, VOID_TYPE, "Dummy_App_3", revision);
- Reset_Streaming();
- // Create stream channels
- Default_StreamChannel1 = Stream_CreateStreamingChannel(stream_Buffer1, STREAM_BUFFER_SIZE, 1);
- Default_StreamChannel2 = Stream_CreateStreamingChannel(stream_Buffer2, STREAM_BUFFER_SIZE, 1);
-
// Detection
Detection(default_sc.App_1.app);
Luos_Loop();
- // Init messages pointers
- transmit_msg = msg_buffer;
-
- // Fill basic messages
- Init_Messages();
-
if (IS_ASSERT())
{
printf("[FATAL] Can't initialize scenario context\n");
@@ -79,27 +59,6 @@ void Init_Context(void)
}
}
-/******************************************************************************
- * @brief Reset context to init state
- * @param None
- * @return None
- ******************************************************************************/
-void Reset_Context(void)
-{
- RESET_ASSERT();
- Luos_ServicesClear();
- RoutingTB_Erase(); // Delete RTB
- Luos_Init();
- transmit_msg = msg_buffer;
- Init_Messages();
- Reset_Streaming();
- if (IS_ASSERT())
- {
- printf("[FATAL] Can't reset scenario context\n");
- TEST_ASSERT_TRUE(IS_ASSERT());
- }
-}
-
/******************************************************************************
* @brief Launch a detection
* @param Service who launches the detection
@@ -110,123 +69,14 @@ static void Detection(service_t *service)
search_result_t result;
Luos_Detect(service);
- Luos_Loop();
+ do
+ {
+ Luos_Loop();
+ } while (!Luos_IsNodeDetected());
RTFilter_Reset(&result);
printf("[INFO] %d services are active\n", result.result_nbr);
- TEST_ASSERT_EQUAL(DUMMY_SERVICE_NUMBER, result.result_nbr);
-}
-
-/******************************************************************************
- * @brief Messages are reseted to default values
- * @param None
- * @return None
- ******************************************************************************/
-void Init_Messages(void)
-{
- // Init tx messages pointers
- default_sc.App_1.tx_msg = (msg_t *)(&msg_buffer[0]);
- default_sc.App_2.tx_msg = (msg_t *)(&msg_buffer[sizeof(msg_t)]);
- default_sc.App_3.tx_msg = (msg_t *)(&msg_buffer[0]);
-
- // Init rx messages pointers
- default_sc.App_1.last_rx_msg = &receive_msg[0];
- default_sc.App_2.last_rx_msg = &receive_msg[1];
- default_sc.App_3.last_rx_msg = &receive_msg[2];
-
- // App 1 : Send message to App 2
- // -------------------------------
- default_sc.App_1.tx_msg->header.config = PROTOCOL_REVISION;
- default_sc.App_1.tx_msg->header.source = 1;
- default_sc.App_1.tx_msg->header.target = 2;
- default_sc.App_1.tx_msg->header.target_mode = SERVICEIDACK;
- default_sc.App_1.tx_msg->header.cmd = DEFAULT_CMD;
- default_sc.App_1.tx_msg->header.size = MAX_DATA_MSG_SIZE;
-
- // App 2 : Send message to App 1
- // -------------------------------
- default_sc.App_2.tx_msg->header.config = PROTOCOL_REVISION;
- default_sc.App_2.tx_msg->header.source = 2;
- default_sc.App_2.tx_msg->header.target = 1;
- default_sc.App_2.tx_msg->header.target_mode = SERVICEIDACK;
- default_sc.App_2.tx_msg->header.cmd = DEFAULT_CMD;
- default_sc.App_2.tx_msg->header.size = MAX_DATA_MSG_SIZE; // data = half of max size
-
- // App 3 : Send message to App 2
- // -------------------------------
- default_sc.App_3.tx_msg->header.config = PROTOCOL_REVISION;
- default_sc.App_3.tx_msg->header.source = 3;
- default_sc.App_3.tx_msg->header.target = 2;
- default_sc.App_3.tx_msg->header.target_mode = SERVICEIDACK;
- default_sc.App_3.tx_msg->header.cmd = DEFAULT_CMD;
- default_sc.App_3.tx_msg->header.size = MAX_DATA_MSG_SIZE; // data = half of max size
-
- // TX message : Only fill half of datas with a counter
- for (uint16_t i = 0; i < MAX_DATA_MSG_SIZE / 2; i++)
- {
- default_sc.App_1.tx_msg->data[i] = (uint8_t)i;
- default_sc.App_2.tx_msg->data[i] = (uint8_t)i;
- default_sc.App_3.tx_msg->data[i] = (uint8_t)i;
- }
- // TX message : Last half of datas is set to 0
- for (uint16_t i = MAX_DATA_MSG_SIZE / 2; i < MAX_DATA_MSG_SIZE; i++)
- {
- default_sc.App_1.tx_msg->data[i] = 0;
- default_sc.App_2.tx_msg->data[i] = 0;
- default_sc.App_3.tx_msg->data[i] = 0;
- }
- // RX message : datas are set to 0
- for (uint16_t i = 0; i < MAX_DATA_MSG_SIZE; i++)
- {
- default_sc.App_1.last_rx_msg->data[i] = 0;
- default_sc.App_2.last_rx_msg->data[i] = 0;
- default_sc.App_3.last_rx_msg->data[i] = 0;
- }
-}
-
-/******************************************************************************
- * @brief Create a streaming channel
- * @param None
- * @return None
- ******************************************************************************/
-static void Reset_Streaming(void)
-{
- // Stream Channel reset
- Stream_ResetStreamingChannel(&Default_StreamChannel1);
- Stream_ResetStreamingChannel(&Default_StreamChannel2);
- default_sc.streamChannel1 = &Default_StreamChannel1;
- default_sc.streamChannel2 = &Default_StreamChannel2;
- for (uint16_t i = 0; i < STREAM_BUFFER_SIZE; i++)
- {
- stream_Buffer1[i] = (uint8_t)(i);
- stream_Buffer2[i] = (uint8_t)(i);
- }
-}
-/******************************************************************************
- * @brief Loop Service App_1
- * @param None
- * @return None
- ******************************************************************************/
-void App_1_Loop(void)
-{
-}
-
-/******************************************************************************
- * @brief Loop Service App_2
- * @param None
- * @return None
- ******************************************************************************/
-void App_2_Loop(void)
-{
-}
-
-/******************************************************************************
- * @brief Loop Service App_3
- * @param None
- * @return None
- ******************************************************************************/
-void App_3_Loop(void)
-{
+ TEST_ASSERT_EQUAL(3, result.result_nbr);
}
/******************************************************************************
@@ -237,23 +87,7 @@ void App_3_Loop(void)
******************************************************************************/
static void App_1_MsgHandler(service_t *service, msg_t *msg)
{
- default_sc.App_1.last_rx_msg->header.config = msg->header.config;
- default_sc.App_1.last_rx_msg->header.source = msg->header.source;
- default_sc.App_1.last_rx_msg->header.target = msg->header.target;
- default_sc.App_1.last_rx_msg->header.target_mode = msg->header.target_mode;
- default_sc.App_1.last_rx_msg->header.cmd = msg->header.cmd;
- default_sc.App_1.last_rx_msg->header.size = msg->header.size;
- for (uint16_t i = 0; i < msg->header.size; i++)
- {
- default_sc.App_1.last_rx_msg->data[i] = msg->data[i];
- }
- if (msg->header.config == TIMESTAMP_PROTOCOL)
- {
- for (uint16_t i = 0; i < sizeof(time_luos_t); i++)
- {
- default_sc.App_1.last_rx_msg->data[msg->header.size + i] = msg->data[msg->header.size + i];
- }
- }
+ memcpy(&default_sc.App_1.last_rx_msg, msg, sizeof(msg_t));
}
/******************************************************************************
@@ -264,23 +98,7 @@ static void App_1_MsgHandler(service_t *service, msg_t *msg)
******************************************************************************/
static void App_2_MsgHandler(service_t *service, msg_t *msg)
{
- default_sc.App_2.last_rx_msg->header.config = msg->header.config;
- default_sc.App_2.last_rx_msg->header.source = msg->header.source;
- default_sc.App_2.last_rx_msg->header.target = msg->header.target;
- default_sc.App_2.last_rx_msg->header.target_mode = msg->header.target_mode;
- default_sc.App_2.last_rx_msg->header.cmd = msg->header.cmd;
- default_sc.App_2.last_rx_msg->header.size = msg->header.size;
- for (uint16_t i = 0; i < msg->header.size; i++)
- {
- default_sc.App_2.last_rx_msg->data[i] = msg->data[i];
- }
- if (msg->header.config == TIMESTAMP_PROTOCOL)
- {
- for (uint16_t i = 0; i < sizeof(time_luos_t); i++)
- {
- default_sc.App_2.last_rx_msg->data[msg->header.size + i] = msg->data[msg->header.size + i];
- }
- }
+ memcpy(&default_sc.App_2.last_rx_msg, msg, sizeof(msg_t));
}
/******************************************************************************
@@ -291,23 +109,5 @@ static void App_2_MsgHandler(service_t *service, msg_t *msg)
******************************************************************************/
static void App_3_MsgHandler(service_t *service, msg_t *msg)
{
- // Save last message
- default_sc.App_3.last_rx_msg->header.config = msg->header.config;
- default_sc.App_3.last_rx_msg->header.source = msg->header.source;
- default_sc.App_3.last_rx_msg->header.target = msg->header.target;
- default_sc.App_3.last_rx_msg->header.target_mode = msg->header.target_mode;
- default_sc.App_3.last_rx_msg->header.cmd = msg->header.cmd;
- default_sc.App_3.last_rx_msg->header.size = msg->header.size;
- for (uint16_t i = 0; i < msg->header.size; i++)
- {
- default_sc.App_3.last_rx_msg->data[i] = msg->data[i];
- }
-
- if (msg->header.config == TIMESTAMP_PROTOCOL)
- {
- for (uint16_t i = 0; i < sizeof(time_luos_t); i++)
- {
- default_sc.App_3.last_rx_msg->data[msg->header.size + i] = msg->data[msg->header.size + i];
- }
- }
+ memcpy(&default_sc.App_3.last_rx_msg, msg, sizeof(msg_t));
}
diff --git a/test/_resources/Scenarios/default_scenario.h b/test/_resources/Scenarios/default_scenario.h
index dbb33199b..8a0a5ba91 100644
--- a/test/_resources/Scenarios/default_scenario.h
+++ b/test/_resources/Scenarios/default_scenario.h
@@ -6,15 +6,10 @@
/*******************************************************************************
* Definitions
******************************************************************************/
-#define DUMMY_SERVICE_NUMBER 3
-#define DUMMY_STREAMING_CHANNEL_NUMBER 3
-#define STREAM_BUFFER_SIZE 1024
-
typedef struct
{
service_t *app;
- msg_t *tx_msg;
- msg_t *last_rx_msg;
+ msg_t last_rx_msg;
} dummy_app_t;
typedef struct
@@ -22,26 +17,16 @@ typedef struct
dummy_app_t App_1;
dummy_app_t App_2;
dummy_app_t App_3;
- streaming_channel_t *streamChannel1;
- streaming_channel_t *streamChannel2;
} default_scenario_t;
typedef enum
{
- DEFAULT_CMD = REVISION // a dummy command for apps
+ DEFAULT_CMD = LUOS_LAST_STD_CMD // a dummy command for apps
} default_scenario_cmd_t;
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-
/*******************************************************************************
* Function
******************************************************************************/
-void Reset_Context(void);
void Init_Context(void);
-void App_1_Loop(void);
-void App_2_Loop(void);
-void App_3_Loop(void);
#endif // DEFAULT_SCENARIO_H
diff --git a/test/_resources/Unity/unit_test.c b/test/_resources/Unity/unit_test.c
index 893abc2f1..42b14d326 100644
--- a/test/_resources/Unity/unit_test.c
+++ b/test/_resources/Unity/unit_test.c
@@ -11,7 +11,7 @@
/*******************************************************************************
* Variables
******************************************************************************/
-ut_luos_assert_t ut_assert = {.state = 0, .enable = 1};
+bool ut_assert = false;
/*******************************************************************************
* Variables
@@ -19,6 +19,10 @@ ut_luos_assert_t ut_assert = {.state = 0, .enable = 1};
uint16_t test_case_number;
uint16_t step_number;
+// external error context
+jmp_buf err_ctx;
+bool try_state = false;
+
/*******************************************************************************
* Function
******************************************************************************/
@@ -83,7 +87,7 @@ void NEW_STEP(char *title)
******************************************************************************/
void NEW_STEP_IN_LOOP(char title[], uint32_t index)
{
- char index2string[5];
+ char index2string[11];
char step_title[128];
memset((void *)step_title, 0, sizeof(step_title));
@@ -104,43 +108,9 @@ void NEW_STEP_IN_LOOP(char title[], uint32_t index)
******************************************************************************/
bool IS_ASSERT(void)
{
- if ((ut_assert.enable == 1) && (ut_assert.state == 1))
- {
- ut_assert.state = 0;
-
-#ifdef UNIT_TEST_DEBUG
- uint32_t line = (ut_assert.msg.data[0]);
- if (ut_assert.line_size > 3)
- {
- line += (ut_assert.msg.data[2] << 4) + (ut_assert.msg.data[1] << 8) + (ut_assert.msg.data[3] << 12);
- }
- else if (ut_assert.line_size > 2)
- {
- line += (ut_assert.msg.data[2] << 4) + (ut_assert.msg.data[1] << 8);
- }
- else if (ut_assert.line_size > 1)
- {
- line += (ut_assert.msg.data[2] << 4);
- }
-
- printf("\n*\t[INFO] Assert message received\t");
- printf("- Line : ");
- printf("%d - ", line);
- printf("\t- File : ");
- for (uint32_t i = 0; i < ut_assert.file_size; i++)
- {
- printf("%c", ut_assert.msg.data[i + ut_assert.line_size]);
- }
- printf("\n");
-#endif
-
- return true;
- }
- else
- {
- ut_assert.state = 0;
- return false;
- }
+ bool ret_val = ut_assert;
+ ut_assert = false;
+ return ret_val;
}
/******************************************************************************
@@ -150,25 +120,7 @@ bool IS_ASSERT(void)
******************************************************************************/
void RESET_ASSERT(void)
{
- ut_assert.state = 0;
-}
-
-/******************************************************************************
- * @brief Assert activation or desactivation
- * @param activation : Set to 1 to activate asserts
- * @return None
- ******************************************************************************/
-void ASSERT_ACTIVATION(uint8_t activation)
-{
- if (activation)
- {
- ut_assert.enable = 1;
- }
- else
- {
- ut_assert.enable = 0;
- }
- RESET_ASSERT();
+ ut_assert = false;
}
/******************************************************************************
@@ -177,21 +129,19 @@ void ASSERT_ACTIVATION(uint8_t activation)
* @param line number
* @return None
******************************************************************************/
-void UNIT_TEST_ASSERT(char *file, uint32_t line)
+void Luos_assert(char *file, uint32_t line)
{
- msg_t msg;
-
- ut_assert.state = 1;
- ut_assert.line_size = sizeof(line);
- ut_assert.file_size = strlen(file);
-
- msg.header.target_mode = BROADCAST;
- msg.header.target = BROADCAST_VAL;
- msg.header.cmd = ASSERT;
- msg.header.size = sizeof(line) + strlen(file);
- memcpy(msg.data, &line, sizeof(line));
- memcpy(&msg.data[sizeof(line)], file, strlen(file));
- ut_assert.msg = msg;
+#ifdef UNIT_TEST_DEBUG
+ printf("\n*\t[INFO] Assert message received\n");
+ printf("\t- Line : %d\n\t- File : %s\n", line, file);
+#endif
+ ut_assert = true;
+ // This is the THROW of the TRY CATCH
+ if (try_state)
+ {
+ _LONGJMP(err_ctx, 1);
+ try_state = false;
+ }
}
void setUp(void)
diff --git a/test/_resources/Unity/unit_test.h b/test/_resources/Unity/unit_test.h
index 3fe6c639a..efabfdc2b 100644
--- a/test/_resources/Unity/unit_test.h
+++ b/test/_resources/Unity/unit_test.h
@@ -13,36 +13,41 @@
#include "luos_engine.h"
#include "luos_utils.h"
#include "robus_struct.h"
+#include
/*******************************************************************************
* Definitions
******************************************************************************/
+#ifdef _WIN32
+ #define _SETJMP __builtin_setjmp
+ #define _LONGJMP __builtin_longjmp
+#else
+ #define _SETJMP setjmp
+ #define _LONGJMP longjmp
+#endif
+
+extern jmp_buf err_ctx;
+extern bool try_state;
+
#ifndef UNIT_TEST_RUN
#define UNIT_TEST_RUN(f) RUN(#f, f)
#endif
-/* This structure is used for unit test assert
- */
-typedef struct
-{
- uint8_t enable; // enable = 0 to disable asserts
- uint8_t state; // state = 1 when an assert has occured
- uint32_t file_size;
- uint32_t line_size;
- msg_t msg;
-} ut_luos_assert_t;
+#define TRY \
+ try_state = true; \
+ if (!_SETJMP(err_ctx))
+
+#define CATCH else
/*******************************************************************************
* Function
******************************************************************************/
void RESET_ASSERT(void);
-void ASSERT_ACTIVATION(uint8_t activation);
bool IS_ASSERT(void);
void NEW_TEST_CASE(char *title);
void NEW_STEP(char *title);
void RUN(const char *name, void (*f)(void));
void NEW_STEP_IN_LOOP(char message[], uint32_t index);
-void UNIT_TEST_ASSERT(char *file, uint32_t line);
void setUp(void);
void tearDown(void);
diff --git a/test/_template/README.md b/test/_template/README.md
deleted file mode 100644
index e69de29bb..000000000
diff --git a/test/_template/main.c b/test/_template/main.c
deleted file mode 100644
index 1c6b2888b..000000000
--- a/test/_template/main.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "main.h"
-#include "unit_test.h"
-
-int main(int argc, char **argv)
-{
- UNITY_BEGIN();
-
- UNIT_TEST_RUN(unittest_TEMPLATE);
- UNIT_TEST_RUN(unittest_TEMPLATE_2);
-
- UNITY_END();
-}
diff --git a/test/_template/main.h b/test/_template/main.h
deleted file mode 100644
index ad0f2a334..000000000
--- a/test/_template/main.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef MAIN_H
-#define MAIN_H
-
-void unittest_TEMPLATE(void);
-void unittest_TEMPLATE_2(void);
-
-#endif //MAIN_H
\ No newline at end of file
diff --git a/test/_template/scenario/scenario_template.c b/test/_template/scenario/scenario_template.c
deleted file mode 100644
index ad6358fa6..000000000
--- a/test/_template/scenario/scenario_template.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/******************************************************************************
- * @file template
- * @brief App x8
- * @author Luos
- * @version 1.0.0
- ******************************************************************************/
-#include
-#include "context.h"
-#include "unit_test.h"
-#include "scenario_template.h"
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-enum detection_machine_state
-{
- NOT_DETECTED = 0,
- DETECT_FIRST_APP,
- DETECT_SECOND_APP,
- DETECTION_IS_OK
-};
-
-typedef enum
-{
- detection_TYPE = LUOS_LAST_STD_CMD,
- DUMMY_TYPE_1,
- DUMMY_TYPE_2,
- SCENARIO_template_LAST_TYPE
-} scenario_template_type_t;
-
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-uint8_t detection_state = STATE_NO_DETECTION;
-
-/*******************************************************************************
- * Function
- ******************************************************************************/
-static void App_Detection_Init(void);
-static void dummy_App_1_Init(void);
-static void dummy_App_2_Init(void);
-
-static void launch_detection(void);
-
-static void App_Detection_MsgHandler(service_t *service, msg_t *msg);
-static void dummy_App_1_MsgHandler(service_t *service, msg_t *msg);
-static void dummy_App_2_MsgHandler(service_t *service, msg_t *msg);
-
-/******************************************************************************
- * @brief Launch a detection to detect local dummy services
- * @param None
- * @return None
- ******************************************************************************/
-void launch_detection(void)
-{
- uint32_t last_detection_date;
- search_result_t result;
-
- RTFilter_Reset(&result);
- printf("*** [INFO] %d services are active before detection\n", result.result_nbr);
-
- last_detection_date = 0;
- printf("*** [INFO] Launch Detection\n");
-
- Luos_Detect(detect_app);
- Luos_Loop();
-
- // Verify all dummy services are created
- RTFilter_Reset(&result);
- printf("*** [INFO] %d services are active\n", result.result_nbr);
- TEST_ASSERT_EQUAL(DUMMY_SERVICE_NUMBER, result.result_nbr);
-}
-
-void Scenario_template_Context_Init(int detection)
-{
- uint32_t last_detection_date;
- uint16_t services_nb;
-
- // Init Luos Context
- Luos_Init();
- RoutingTB_Erase();
-
- // Init dummy Apps
- App_Detection_Init();
- dummy_App_1_Init();
- dummy_App_2_Init();
-
- if (detection == STATE_DETECTION)
- {
- launch_detection();
- }
-}
-
-/******************************************************************************
- * @brief Init Service App_Detection
- * @param None
- * @return None
- ******************************************************************************/
-void App_Detection_Init(void)
-{
- revision_t revision = {.major = 1, .minor = 0, .build = 0};
- detect_app = Luos_CreateService(App_Detection_MsgHandler, detection_TYPE, "App_Detect", revision);
-}
-
-/******************************************************************************
- * @brief Init Service dummy_App_1
- * @param None
- * @return None
- ******************************************************************************/
-void dummy_App_1_Init(void)
-{
- revision_t revision = {.major = 1, .minor = 0, .build = 0};
- dummy_App_1 = Luos_CreateService(dummy_App_1_MsgHandler, DUMMY_TYPE_1, "dummy_App_1", revision);
-}
-
-/******************************************************************************
- * @brief Init Service dummy_App_2
- * @param None
- * @return None
- ******************************************************************************/
-void dummy_App_2_Init(void)
-{
- revision_t revision = {.major = 1, .minor = 0, .build = 0};
- dummy_App_2 = Luos_CreateService(dummy_App_2_MsgHandler, DUMMY_TYPE_2, "dummy_App_2", revision);
-}
-
-/******************************************************************************
- * @brief Loop Service Detection
- * @param stop is set to 1 when detection scenario is finished
- * @return None
- ******************************************************************************/
-void Scenario_template_Loop(int *stop)
-{
- static uint32_t last_detection_time = 0;
- static uint8_t first_detection = 0;
- uint16_t id;
- search_result_t result;
-
- switch (detection_state)
- {
- case DETECTION_IS_OK:
- *stop = 1;
- break;
-
- case NOT_DETECTED:
- if (first_detection == 0)
- {
- if (Luos_GetSystick() - last_detection_time > DETECTION_LATENCY)
- {
- first_detection = 1;
- printf("*** Launch Detection\n");
- Luos_Detect(detect_app);
- }
- }
- break;
-
- case DETECT_FIRST_APP:
- RTFilter_ID(RTFilter_Reset(&result), 3);
- if (result.result_nbr == 1)
- {
- msg_t msg;
- msg.header.source = 1;
- msg.header.target = 2;
- msg.header.target_mode = SERVICEIDACK;
- msg.header.cmd = SET_CMD;
- msg.header.size = sizeof(uint8_t);
- msg.data[0] = 1;
- while (Luos_SendMsg(detect_app, &msg) != SUCCEED)
- {
- Luos_Loop();
- }
- }
- break;
-
- case DETECT_SECOND_APP:
- RTFilter_ID(RTFilter_Reset(&result), 3);
- if (result.result_nbr == 1)
- {
- msg_t msg;
- msg.header.source = 1;
- msg.header.target = 3;
- msg.header.target_mode = SERVICEIDACK;
- msg.header.cmd = SET_CMD;
- msg.header.size = sizeof(uint8_t);
- msg.data[0] = 2;
- while (Luos_SendMsg(detect_app, &msg) != SUCCEED)
- {
- Luos_Loop();
- }
- }
- break;
-
- default:
- break;
- }
-}
-
-/******************************************************************************
- * @brief Msg Handler call back when a msg receive for this service
- * @param service destination
- * @param Msg receive
- * @return None
- ******************************************************************************/
-static void App_Detection_MsgHandler(service_t *service, msg_t *msg)
-{
- if (msg->header.cmd == END_DETECTION)
- {
- printf("[ Rx ] - [APP Detection] - End detection\n");
- detection_state = DETECT_FIRST_APP;
- }
- // printf("*** MsgHandler - APP detect: %d\n", msg->header.cmd);
-}
-
-/******************************************************************************
- * @brief Msg Handler call back when a msg receive for this service
- * @param service destination
- * @param Msg receive
- * @return None
- ******************************************************************************/
-static void dummy_App_1_MsgHandler(service_t *service, msg_t *msg)
-{
- if (msg->header.cmd == SET_CMD)
- {
- printf("[ Rx ] - [Dummy App 1] - Receive data: %d\n", msg->data[0]);
- detection_state = DETECT_SECOND_APP;
- }
- // printf("*** MsgHandler - APP 1: %d\n", msg->header.cmd);
-}
-
-/******************************************************************************
- * @brief Msg Handler call back when a msg receive for this service
- * @param service destination
- * @param Msg receive
- * @return None
- ******************************************************************************/
-static void dummy_App_2_MsgHandler(service_t *service, msg_t *msg)
-{
- if (msg->header.cmd == SET_CMD)
- {
- printf("[ Rx ] - [Dummy App 2] - Receive data: %d\n", msg->data[0]);
- detection_state = DETECTION_IS_OK;
- }
- // printf("*** MsgHandler - APP 2: %d\n", msg->header.cmd);
-}
diff --git a/test/_template/scenario/scenario_template.h b/test/_template/scenario/scenario_template.h
deleted file mode 100644
index 32c3f8087..000000000
--- a/test/_template/scenario/scenario_template.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef SCENARIO_TEMPLATE_H
-#define SCENARIO_TEMPLATE_H
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-#define DETECTION_LATENCY 500 //ms
-#define DUMMY_SERVICE_NUMBER 3
-
-enum detection_activation
-{
- STATE_NO_DETECTION = 0,
- STATE_DETECTION
-};
-
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-service_t *detect_app;
-service_t *dummy_App_1;
-service_t *dummy_App_2;
-
-/*******************************************************************************
- * Function
- ******************************************************************************/
-void Scenario_template_Context_Init(int detection);
-void Scenario_template_Loop(int *stop);
-
-#endif //SCENARIO_TEMPLATE_H
diff --git a/test/_template/template_1.c b/test/_template/template_1.c
deleted file mode 100644
index 41113c1a6..000000000
--- a/test/_template/template_1.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#include
-#include "main.h"
-#include "unit_test.h"
-#include "scenario/scenario_template.h"
-
-void unittest_TEMPLATE(void)
-{
- NEW_TEST_CASE("TEST SOMETHING");
- {
-
- // Init default dummy context
- //----------------------------
- Scenario_template_Context_Init(STATE_DETECTION);
-
- search_result_t result;
- RTFilter_Reset(&result);
- printf("Number of services after init : %d\n", result.result_nbr);
-
- // Test step
- // **************************************************************
- NEW_STEP("Explain the step : this step checks something");
-
- // Init context
- // -------------
- // eg : uint8_t a,b = 0;
-
- // Call the function to test
- // --------------------------
- // eg : b = my function(a);
-
- // If needed, call "Luos_loop();""
- // -------------------------------
-
- // Verify
- // --------
- // eg : TEST_ASSERT_EQUAL(10, b);
-
- // Another test steps
- // **************************************************************
- NEW_STEP("Explain the step : this step checks something else");
- // etc...
- }
-
- NEW_TEST_CASE("ANOTHER TEST CASE");
- {
- // etc...
- }
-}
diff --git a/test/_template/template_2.c b/test/_template/template_2.c
deleted file mode 100644
index 081bd97cb..000000000
--- a/test/_template/template_2.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include
-#include "main.h"
-#include "unit_test.h"
-#include "scenario/scenario_template.h"
-
-#define TEST_TIMEOUT 10000 //ms
-
-void unittest_TEMPLATE_2(void)
-{
- NEW_TEST_CASE("Template example");
- {
- uint32_t start_time;
- int is_finished = 0;
-
- // Init default dummy context : no detection is asked
- //---------------------------------------------------
- Scenario_template_Context_Init(NO_DETECTION);
-
- // Template scenario : check services are detected
- //---------------------------------------------------
- NEW_STEP("Check there are exactly 3 services detected\n");
- start_time = Luos_GetSystick();
- while (Luos_GetSystick() - start_time < TEST_TIMEOUT)
- {
- //printf("\n\n[Current Time] %lu ms\n", Luos_GetSystick());
- Luos_Loop();
- Scenario_template_Loop(&is_finished);
-
- //
- // Here you should add the function you have to test
- //
-
- // In this example, test is stopped after TEST_TIMEOUT
- // or when App_Detection_Loop has finished its job
- if (is_finished)
- {
- break;
- }
- }
-
- //--------------------------------------------------------------------
- // Verify
- //--------------------------------------------------------------------
- search_result_t result;
- RTFilter_Reset(&result);
- printf("Number of services : %d\n", result.result_nbr);
- // Test is OK if there are 3 activated services.
- TEST_ASSERT_EQUAL(DUMMY_SERVICE_NUMBER, result.result_nbr);
- }
-}
diff --git a/test/test_luos/main.c b/test/test_luos/main.c
index dc520b548..f778a8522 100644
--- a/test/test_luos/main.c
+++ b/test/test_luos/main.c
@@ -1,6 +1,7 @@
#include "main.h"
#include
#include
+#define STREAM_BUFFER_SIZE 1024
extern default_scenario_t default_sc;
@@ -9,46 +10,61 @@ void unittest_Streaming_SendStreamingSize()
NEW_TEST_CASE("Sample size sent to streaming < Available samples");
{
uint32_t ExpectedMaxSize;
+ msg_t tx_msg;
+ tx_msg.header.target = 2;
+ tx_msg.header.target_mode = SERVICEIDACK;
+ tx_msg.header.cmd = DEFAULT_CMD;
+ uint8_t stream_Buffer[STREAM_BUFFER_SIZE] = {0};
+ streaming_channel_t streamChannel = Stream_CreateStreamingChannel(stream_Buffer, STREAM_BUFFER_SIZE, 1);
- Reset_Context();
// Init default scenario context
Init_Context();
// Init variable
ExpectedMaxSize = 1;
// Add samples
- Stream_AddAvailableSampleNB(default_sc.streamChannel1, 2);
+ Stream_AddAvailableSampleNB(&streamChannel, 2);
NEW_STEP("Verify 1 byte is received when stream channels size is 2");
- Luos_SendStreamingSize(default_sc.App_1.app, default_sc.App_1.tx_msg, default_sc.streamChannel1, 1);
+ Luos_SendStreamingSize(default_sc.App_1.app, &tx_msg, &streamChannel, 1);
Luos_Loop();
// Verify
- TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_2.last_rx_msg->header.size);
+ TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_2.last_rx_msg.header.size);
}
NEW_TEST_CASE("Sample size sent to streaming = available samples");
{
uint32_t ExpectedMaxSize;
+ msg_t tx_msg;
+ tx_msg.header.target = 2;
+ tx_msg.header.target_mode = SERVICEIDACK;
+ tx_msg.header.cmd = DEFAULT_CMD;
+ uint8_t stream_Buffer[STREAM_BUFFER_SIZE] = {0};
+ streaming_channel_t streamChannel = Stream_CreateStreamingChannel(stream_Buffer, STREAM_BUFFER_SIZE, 1);
- Reset_Context();
// Init default scenario context
Init_Context();
// Init variable
ExpectedMaxSize = 2;
// Add samples
- Stream_AddAvailableSampleNB(default_sc.streamChannel1, 2);
+ Stream_AddAvailableSampleNB(&streamChannel, 2);
NEW_STEP("Verify 2 byte are received when stream channels size is 2");
- Luos_SendStreamingSize(default_sc.App_1.app, default_sc.App_1.tx_msg, default_sc.streamChannel1, 2);
+ Luos_SendStreamingSize(default_sc.App_1.app, &tx_msg, &streamChannel, 2);
Luos_Loop();
// Verify
- TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_2.last_rx_msg->header.size);
+ TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_2.last_rx_msg.header.size);
}
NEW_TEST_CASE("Sample size sent to streaming > available samples");
{
uint32_t ExpectedMaxSize;
+ msg_t tx_msg;
+ tx_msg.header.target = 2;
+ tx_msg.header.target_mode = SERVICEIDACK;
+ tx_msg.header.cmd = DEFAULT_CMD;
+ uint8_t stream_Buffer[STREAM_BUFFER_SIZE] = {0};
+ streaming_channel_t streamChannel = Stream_CreateStreamingChannel(stream_Buffer, STREAM_BUFFER_SIZE, 1);
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -57,18 +73,23 @@ void unittest_Streaming_SendStreamingSize()
NEW_STEP("Verify 2 byte are received when we try to send 3 bytes");
// Add samples
- Stream_AddAvailableSampleNB(default_sc.streamChannel1, 2);
- Luos_SendStreamingSize(default_sc.App_1.app, default_sc.App_1.tx_msg, default_sc.streamChannel1, 3);
+ Stream_AddAvailableSampleNB(&streamChannel, 2);
+ Luos_SendStreamingSize(default_sc.App_1.app, &tx_msg, &streamChannel, 3);
Luos_Loop();
// Verify
- TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_2.last_rx_msg->header.size);
+ TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_2.last_rx_msg.header.size);
}
NEW_TEST_CASE("Limit test");
{
uint32_t ExpectedMaxSize;
+ msg_t tx_msg;
+ tx_msg.header.target = 2;
+ tx_msg.header.target_mode = SERVICEIDACK;
+ tx_msg.header.cmd = DEFAULT_CMD;
+ uint8_t stream_Buffer[STREAM_BUFFER_SIZE] = {0};
+ streaming_channel_t streamChannel = Stream_CreateStreamingChannel(stream_Buffer, STREAM_BUFFER_SIZE, 1);
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -77,28 +98,28 @@ void unittest_Streaming_SendStreamingSize()
NEW_STEP("Try to send 0 byte : it does nothing");
// Init variable new step
- ExpectedMaxSize = 0;
- default_sc.App_1.tx_msg->header.target = 3;
+ ExpectedMaxSize = 0;
+ tx_msg.header.target = 3;
// Add samples
- Stream_AddAvailableSampleNB(default_sc.streamChannel1, 2);
- Luos_SendStreamingSize(default_sc.App_1.app, default_sc.App_1.tx_msg, default_sc.streamChannel1, 0);
+ Stream_AddAvailableSampleNB(&streamChannel, 2);
+ Luos_SendStreamingSize(default_sc.App_1.app, &tx_msg, &streamChannel, 0);
Luos_Loop();
// Verify
- TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_3.last_rx_msg->header.size);
+ TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_3.last_rx_msg.header.size);
NEW_STEP("try to send 128 byte the max size of a msg");
// Init variable
- ExpectedMaxSize = 128;
- default_sc.App_1.tx_msg->header.target = 2;
+ ExpectedMaxSize = 128;
+ tx_msg.header.target = 2;
// Add samples
- Stream_AddAvailableSampleNB(default_sc.streamChannel1, 128);
- Luos_SendStreamingSize(default_sc.App_1.app, default_sc.App_1.tx_msg, default_sc.streamChannel1, 128);
+ Stream_AddAvailableSampleNB(&streamChannel, 128);
+ Luos_SendStreamingSize(default_sc.App_1.app, &tx_msg, &streamChannel, 128);
Luos_Loop();
// Verify
- TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_2.last_rx_msg->header.size);
+ TEST_ASSERT_EQUAL(ExpectedMaxSize, default_sc.App_2.last_rx_msg.header.size);
}
}
@@ -106,7 +127,6 @@ void unittest_Luos_ReceiveData()
{
NEW_TEST_CASE("Try to send a void message argument");
{
- Reset_Context();
// Init default scenario context
Init_Context();
revision_t revision = {.major = 1, .minor = 0, .build = 0};
@@ -121,7 +141,6 @@ void unittest_Luos_ReceiveData()
NEW_TEST_CASE("Try to send a void table argument");
{
- Reset_Context();
// Init default scenario context
Init_Context();
revision_t revision = {.major = 1, .minor = 0, .build = 0};
@@ -135,18 +154,16 @@ void unittest_Luos_ReceiveData()
NEW_TEST_CASE("Try to send a shity service argument");
{
- Reset_Context();
// Init default scenario context
Init_Context();
msg_t msg;
uint32_t bin_data[64] = {0xDEADBEEF};
NEW_STEP("Verify if we return an error");
- TEST_ASSERT_EQUAL(Luos_ReceiveData(10, &msg, bin_data), -1);
+ TEST_ASSERT_EQUAL(Luos_ReceiveData((service_t *)10, &msg, bin_data), -1);
}
NEW_TEST_CASE("Test the regular usage");
{
- Reset_Context();
// Init default scenario context
Init_Context();
revision_t revision = {.major = 1, .minor = 0, .build = 0};
@@ -173,7 +190,6 @@ void unittest_Luos_ReceiveData()
NEW_TEST_CASE("Try to send a void service argument to reset the data reception");
{
- Reset_Context();
// Init default scenario context
Init_Context();
revision_t revision = {.major = 1, .minor = 0, .build = 0};
@@ -199,7 +215,6 @@ void unittest_Luos_ReceiveData()
int main(int argc, char **argv)
{
UNITY_BEGIN();
- ASSERT_ACTIVATION(1);
// Big data reception
UNIT_TEST_RUN(unittest_Luos_ReceiveData);
diff --git a/test/test_msg_alloc/main.c b/test/test_msg_alloc/main.c
index 4ec5d3813..ce3f1a18e 100644
--- a/test/test_msg_alloc/main.c
+++ b/test/test_msg_alloc/main.c
@@ -6,8 +6,6 @@ int main(int argc, char **argv)
{
UNITY_BEGIN();
- ASSERT_ACTIVATION(1);
-
// Static functions
UNIT_TEST_RUN(unittest_DoWeHaveSpace);
UNIT_TEST_RUN(unittest_CheckMsgSpace);
diff --git a/test/test_msg_alloc/main.h b/test/test_msg_alloc/main.h
index 4f0af5f68..4074e811e 100644
--- a/test/test_msg_alloc/main.h
+++ b/test/test_msg_alloc/main.h
@@ -1,11 +1,6 @@
#ifndef MAIN_H
#define MAIN_H
-// Node config to default values
-#define MAX_SERVICE_NUMBER 5
-#define MSG_BUFFER_SIZE 3 * sizeof(msg_t)
-#define MAX_MSG_NB 10
-
// Static functions
void unittest_DoWeHaveSpace(void);
void unittest_CheckMsgSpace(void);
@@ -54,4 +49,4 @@ void unittest_SetTxTask_ACK(void);
void unittest_SetTxTask_internal_localhost(void);
void unittest_SetTxTask_multihost(void);
-#endif //MAIN_H
\ No newline at end of file
+#endif // MAIN_H
\ No newline at end of file
diff --git a/test/test_msg_alloc/unit_test_mem_alloc_generic.c b/test/test_msg_alloc/unit_test_mem_alloc_generic.c
index acd5c2856..5cda96c1c 100644
--- a/test/test_msg_alloc/unit_test_mem_alloc_generic.c
+++ b/test/test_msg_alloc/unit_test_mem_alloc_generic.c
@@ -1033,7 +1033,7 @@ void unittest_MsgAlloc_LuosTaskAlloc()
// Init variables
luos_tasks_stack_id = i;
expected_luos_tasks_stack_id = i + 1;
- expected_mem_stat = (i + 1) * 10;
+ expected_mem_stat = ((i + 1) * 100 / MAX_MSG_NB);
message = (msg_t *)&msg_buffer[0];
service_concerned = (ll_service_t *)&msg_buffer[0];
@@ -1101,7 +1101,7 @@ void unittest_MsgAlloc_PullMsg()
// Init variables
luos_tasks_stack_id = MAX_MSG_NB - 1;
- for (uint32_t i = 0; i < MAX_MSG_NB; i++)
+ for (uintptr_t i = 0; i < MAX_MSG_NB; i++)
{
luos_tasks[i].ll_service_pt = (ll_service_t *)i;
}
@@ -1329,7 +1329,7 @@ void unittest_MsgAlloc_LookAtLuosTask()
ll_service_t *oldest_ll_service = NULL;
luos_tasks_stack_id = MAX_MSG_NB;
- for (uint32_t i = 0; i < MAX_MSG_NB; i++)
+ for (uintptr_t i = 0; i < MAX_MSG_NB; i++)
{
luos_tasks[i].ll_service_pt = (ll_service_t *)i;
}
@@ -1788,7 +1788,7 @@ void unittest_MsgAlloc_PullMsgFromTxTask()
for (uint8_t i = 0; i < MAX_MSG_NB; i++)
{
- tx_tasks[i].data_pt = &msg_buffer[i];
+ tx_tasks[i].data_pt = (uint8_t *)&msg_buffer[i];
tx_tasks[i].size = i;
}
@@ -1888,9 +1888,10 @@ void unittest_MsgAlloc_PullServiceFromTxTask()
// Init variables
//---------------
- tx_tasks_stack_id = 10;
+ const int task_number = 10;
+ tx_tasks_stack_id = task_number;
- for (uint16_t i = 0; i < MAX_MSG_NB; i++)
+ for (uint16_t i = 0; i < task_number; i++)
{
msg_tasks[i] = (msg_t *)&msg_buffer[i * 20];
msg_tasks[i]->header.target = i + 1;
@@ -1905,13 +1906,13 @@ void unittest_MsgAlloc_PullServiceFromTxTask()
expected_tx_tasks[0].data_pt = tx_tasks[1].data_pt;
expected_tx_tasks[1].data_pt = tx_tasks[3].data_pt;
- for (uint16_t i = 2; i < MAX_MSG_NB - 3; i++)
+ for (uint16_t i = 2; i < task_number - 3; i++)
{
expected_tx_tasks[i].data_pt = tx_tasks[i + 3].data_pt;
}
- expected_tx_tasks[MAX_MSG_NB - 1].data_pt = 0;
- expected_tx_tasks[MAX_MSG_NB - 2].data_pt = 0;
- expected_tx_tasks[MAX_MSG_NB - 3].data_pt = 0;
+ expected_tx_tasks[task_number - 1].data_pt = 0;
+ expected_tx_tasks[task_number - 2].data_pt = 0;
+ expected_tx_tasks[task_number - 3].data_pt = 0;
// Call function
//---------------
@@ -1919,7 +1920,7 @@ void unittest_MsgAlloc_PullServiceFromTxTask()
// Verify
//---------------
- for (uint16_t i = 0; i < MAX_MSG_NB; i++)
+ for (uint16_t i = 0; i < task_number; i++)
{
NEW_STEP_IN_LOOP("Check Tx task message pointer are correctly allocated after pulling expected service tx task", i);
TEST_ASSERT_EQUAL(expected_tx_tasks[i].data_pt, tx_tasks[i].data_pt);
diff --git a/test/test_msg_alloc/unit_test_mem_alloc_static.c b/test/test_msg_alloc/unit_test_mem_alloc_static.c
index bd3fe5219..7f6c4f489 100644
--- a/test/test_msg_alloc/unit_test_mem_alloc_static.c
+++ b/test/test_msg_alloc/unit_test_mem_alloc_static.c
@@ -298,7 +298,7 @@ void unittest_BufferAvailableSpaceComputation(void)
//---------------
current_msg = (msg_t *)&msg_buffer[i];
data_end_estimation = (uint8_t *)&msg_buffer[i + 1];
- for (uint8_t j = 0; j < MSG_BUFFER_SIZE - 1; j++)
+ for (uint32_t j = 0; j < MSG_BUFFER_SIZE - 1; j++)
{
// Test is launched only if "data_end_estimation" doesn't overflows "msg_buffer" size
if (data_end_estimation < (uint8_t *)&msg_buffer[MSG_BUFFER_SIZE])
@@ -532,8 +532,8 @@ void unittest_ValidDataIntegrity(void)
//
uint8_t expected_msg_buffer[MSG_BUFFER_SIZE];
- mem_clear_needed = 0;
- copy_task_pointer == NULL;
+ mem_clear_needed = 0;
+ copy_task_pointer = NULL;
memset((void *)&msg_buffer[0], 0xAA, MSG_BUFFER_SIZE);
memset((void *)&expected_msg_buffer[0], 0xAA, MSG_BUFFER_SIZE);
@@ -750,8 +750,8 @@ void unittest_ClearMsgSpace(void)
TEST_ASSERT_EQUAL(100, memory_stats.buffer_occupation_ratio);
NEW_STEP("Check \"luos tasks stack id\" equals 2");
TEST_ASSERT_EQUAL(2, luos_tasks_stack_id);
- NEW_STEP("Check that 8 messages has been dropped");
- TEST_ASSERT_EQUAL(8, memory_stats.msg_drop_number);
+ NEW_STEP("Check that MAX_MSG_NB - 2 messages has been dropped");
+ TEST_ASSERT_EQUAL(MAX_MSG_NB - 2, memory_stats.msg_drop_number);
NEW_STEP("Check Luos Tasks are all reseted");
for (uint16_t i = 0; i < MAX_MSG_NB - 2; i++)
{
@@ -834,8 +834,8 @@ void unittest_ClearMsgSpace(void)
TEST_ASSERT_EQUAL(100, memory_stats.buffer_occupation_ratio);
NEW_STEP("Check \"luos tasks stack id\" equals 2");
TEST_ASSERT_EQUAL(2, msg_tasks_stack_id);
- NEW_STEP("Check that 8 messages has been dropped");
- TEST_ASSERT_EQUAL(8, memory_stats.msg_drop_number);
+ NEW_STEP("Check that MAX_MSG_NB - 2 messages has been dropped");
+ TEST_ASSERT_EQUAL(MAX_MSG_NB - 2, memory_stats.msg_drop_number);
NEW_STEP("Check Message Tasks are all reseted");
for (uint16_t i = 0; i < MAX_MSG_NB - 2; i++)
{
@@ -918,8 +918,8 @@ void unittest_ClearMsgSpace(void)
TEST_ASSERT_EQUAL(100, memory_stats.buffer_occupation_ratio);
NEW_STEP("Check \"luos tasks stack id\" equals 2");
TEST_ASSERT_EQUAL(2, tx_tasks_stack_id);
- NEW_STEP("Check that 8 messages has been dropped");
- TEST_ASSERT_EQUAL(8, memory_stats.msg_drop_number);
+ NEW_STEP("Check that MAX_MSG_NB - 2 messages has been dropped");
+ TEST_ASSERT_EQUAL(MAX_MSG_NB - 2, memory_stats.msg_drop_number);
NEW_STEP("Check Tx Tasks are all reseted");
for (uint16_t i = 0; i < MAX_MSG_NB - 2; i++)
{
@@ -1065,8 +1065,6 @@ void unittest_ClearLuosTask(void)
luos_task_t expected_luos_tasks[MAX_MSG_NB];
- ASSERT_ACTIVATION(0);
-
NEW_STEP("Check Luos Task is cleared in all cases");
for (uint16_t task_id = 0; task_id < MAX_MSG_NB; task_id++)
{
@@ -1112,6 +1110,5 @@ void unittest_ClearLuosTask(void)
}
}
}
- ASSERT_ACTIVATION(1);
}
}
diff --git a/test/test_robus/main.c b/test/test_robus/main.c
index 3c8d16e56..4c9862a7c 100644
--- a/test/test_robus/main.c
+++ b/test/test_robus/main.c
@@ -46,14 +46,18 @@ void unittest_Robus_IDMaskCalculation()
NEW_TEST_CASE("Limit 4096");
{
Robus_MaskInit();
- Robus_IDMaskCalculation(4096 - SERVICE_NUMBER, SERVICE_NUMBER);
- TEST_ASSERT_EQUAL(511, ctx.IDShiftMask);
+ Robus_IDMaskCalculation(4096 - MAX_SERVICE_NUMBER, SERVICE_NUMBER);
+ TEST_ASSERT_EQUAL(508, ctx.IDShiftMask);
}
NEW_TEST_CASE("Limit 0");
{
+ RESET_ASSERT();
Robus_MaskInit();
- Robus_IDMaskCalculation(0, SERVICE_NUMBER);
+ TRY
+ {
+ Robus_IDMaskCalculation(0, SERVICE_NUMBER);
+ }
TEST_ASSERT_TRUE(IS_ASSERT());
RESET_ASSERT();
}
@@ -63,7 +67,6 @@ void unittest_Robus_TopicSubscribe(void)
{
NEW_TEST_CASE("Normal Add to node topic list");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -80,7 +83,6 @@ void unittest_Robus_TopicSubscribe(void)
}
NEW_TEST_CASE("Assert when adding last topic");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -89,14 +91,14 @@ void unittest_Robus_TopicSubscribe(void)
Robus_TopicSubscribe(default_sc.App_1.app->ll_service, LAST_TOPIC);
TEST_ASSERT_FALSE(IS_ASSERT());
- Robus_TopicSubscribe(default_sc.App_1.app->ll_service, LAST_TOPIC + 1);
+ TRY
+ {
+ Robus_TopicSubscribe(default_sc.App_1.app->ll_service, LAST_TOPIC + 1);
+ }
TEST_ASSERT_TRUE(IS_ASSERT());
-
- RESET_ASSERT();
}
NEW_TEST_CASE("Add same topic multiple times");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -120,7 +122,6 @@ void unittest_Robus_TopicUnsubscribe(void)
{
NEW_TEST_CASE("Remove from an empty list");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -129,7 +130,6 @@ void unittest_Robus_TopicUnsubscribe(void)
}
NEW_TEST_CASE("Normal Remove from topic list");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -160,7 +160,6 @@ void unittest_Robus_TopicUnsubscribe(void)
}
NEW_TEST_CASE("Demand to remove last topic");
{
- Reset_Context();
// Init default scenario context
Init_Context();
Robus_TopicSubscribe(default_sc.App_1.app->ll_service, LAST_TOPIC - 1);
@@ -174,7 +173,6 @@ void unittest_Robus_TopicUnsubscribe(void)
}
NEW_TEST_CASE("Remove multiple times same topic");
{
- Reset_Context();
// Init default scenario context
Init_Context();
Robus_TopicSubscribe(default_sc.App_1.app->ll_service, 0);
@@ -223,7 +221,6 @@ void unittest_Robus_TopicUnsubscribe(void)
int main(int argc, char **argv)
{
UNITY_BEGIN();
- ASSERT_ACTIVATION(1);
// Big data reception
UNIT_TEST_RUN(unittest_Robus_IDMaskCalculation);
diff --git a/test/test_routing_table/main.c b/test/test_routing_table/main.c
index 083aef48e..65a44e627 100644
--- a/test/test_routing_table/main.c
+++ b/test/test_routing_table/main.c
@@ -10,7 +10,6 @@ void unittest_RTFilter_Reset(void)
{
uint32_t ExpectedServiceNB;
- Reset_Context();
// Init default scenario context
Init_Context();
// Init variables
@@ -44,7 +43,6 @@ void unittest_RTFilter_InitCheck(void)
{
NEW_TEST_CASE("Test the result initialization check function");
{
- Reset_Context();
// Init default scenario context
Init_Context();
// Init variables
@@ -70,7 +68,6 @@ void unittest_RTFilter_Type(void)
{
RESET_ASSERT();
- Reset_Context();
// Init default scenario context
Init_Context();
// Init variables
@@ -85,7 +82,6 @@ void unittest_RTFilter_Type(void)
RESET_ASSERT();
uint32_t ExpectedServiceNB;
- Reset_Context();
// Init default scenario context
Init_Context();
// Init variables
@@ -103,7 +99,6 @@ void unittest_RTFilter_Type(void)
NEW_TEST_CASE("Add new service and retest");
{
uint32_t ExpectedServiceNB;
- Reset_Context();
// Init default scenario context
Init_Context();
revision_t revision = {.major = 1, .minor = 0, .build = 0};
@@ -111,14 +106,21 @@ void unittest_RTFilter_Type(void)
Luos_CreateService(0, STATE_TYPE, "mycustom_service", revision);
Luos_Detect(default_sc.App_1.app);
- Luos_Loop();
+ do
+ {
+ Luos_Loop();
+ } while (!Luos_IsNodeDetected());
// Init variables
- ExpectedServiceNB = 3;
search_result_t result;
- // Add samples
+
+ NEW_STEP("Verify that we have the 4 services");
+ RTFilter_Reset(&result);
+ ExpectedServiceNB = 4;
+ TEST_ASSERT_EQUAL(ExpectedServiceNB, result.result_nbr);
NEW_STEP("Verify that we have the 3 VOID_TYPE services");
RTFilter_Type(RTFilter_Reset(&result), VOID_TYPE);
+ ExpectedServiceNB = 3;
TEST_ASSERT_EQUAL(ExpectedServiceNB, result.result_nbr);
NEW_STEP("Verify that we have the STATE_TYPE service");
@@ -139,7 +141,6 @@ void unittest_RTFilter_Node(void)
{
uint32_t ExpectedServiceNB;
- Reset_Context();
// Init default scenario context
Init_Context();
// Init variables
@@ -164,7 +165,6 @@ void unittest_RTFilter_ID(void)
{
uint32_t ExpectedServiceNB;
- Reset_Context();
// Init default scenario context
Init_Context();
// Init variables
@@ -197,7 +197,6 @@ void unittest_RTFilter_Service(void)
{
uint32_t ExpectedServiceNB;
- Reset_Context();
// Init default scenario context
Init_Context();
ExpectedServiceNB = 1;
@@ -225,7 +224,6 @@ void unittest_RTFilter_Alias()
{
uint32_t ExpectedServiceNB;
- Reset_Context();
// Init default scenario context
Init_Context();
revision_t revision = {.major = 1, .minor = 0, .build = 0};
@@ -233,7 +231,10 @@ void unittest_RTFilter_Alias()
Luos_CreateService(0, STATE_TYPE, "Custom_App", revision);
Luos_Detect(default_sc.App_1.app);
- Luos_Loop();
+ do
+ {
+ Luos_Loop();
+ } while (!Luos_IsNodeDetected());
// Init variables
ExpectedServiceNB = 3;
search_result_t result;
@@ -272,7 +273,6 @@ void unittest_RTFilter_Alias()
int main(int argc, char **argv)
{
UNITY_BEGIN();
- ASSERT_ACTIVATION(1);
// Streaming functions
UNIT_TEST_RUN(unittest_RTFilter_Reset);
diff --git a/test/test_timestamp/main.c b/test/test_timestamp/main.c
index 017a8f5ec..b5536f533 100644
--- a/test/test_timestamp/main.c
+++ b/test/test_timestamp/main.c
@@ -7,11 +7,11 @@ extern default_scenario_t default_sc;
static void MessageHandler(service_t *service, msg_t *msg)
{
- default_sc.App_1.last_rx_msg->header.config = msg->header.config;
- default_sc.App_1.last_rx_msg->header.size = msg->header.size;
- for (uint16_t i = 0; i < default_sc.App_1.last_rx_msg->header.size; i++)
+ default_sc.App_1.last_rx_msg.header.config = msg->header.config;
+ default_sc.App_1.last_rx_msg.header.size = msg->header.size;
+ for (uint16_t i = 0; i < default_sc.App_1.last_rx_msg.header.size; i++)
{
- default_sc.App_1.last_rx_msg->data[i] = msg->data[i];
+ default_sc.App_1.last_rx_msg.data[i] = msg->data[i];
}
}
@@ -20,7 +20,6 @@ void unittest_Timestamp()
NEW_TEST_CASE("Timestamp measurement");
{
NEW_STEP("Save events");
- Reset_Context();
// Init default scenario context
Init_Context();
Luos_Loop();
@@ -44,7 +43,6 @@ void unittest_Timestamp()
NEW_STEP("Transmit timestamps");
// Init scenario context
- Reset_Context();
// Init default scenario context
Init_Context();
Luos_Loop();
@@ -63,7 +61,7 @@ void unittest_Timestamp()
// Get the message received
msg_t *rx_msg;
- rx_msg = default_sc.App_2.last_rx_msg;
+ rx_msg = &default_sc.App_2.last_rx_msg;
uint64_t low_level_rx_timestamp;
// Get back the 1st timestamp
time_luos_t rx_event_a_timestamp = Timestamp_GetTimestamp(rx_msg);
@@ -73,7 +71,7 @@ void unittest_Timestamp()
Luos_Loop();
// Get the message received
- rx_msg = default_sc.App_2.last_rx_msg;
+ rx_msg = &default_sc.App_2.last_rx_msg;
// Get back the 2nd timestamp
time_luos_t rx_event_b_timestamp = Timestamp_GetTimestamp(rx_msg);
@@ -87,7 +85,6 @@ void unittest_Timestamp()
int main(int argc, char **argv)
{
UNITY_BEGIN();
- ASSERT_ACTIVATION(1);
// Timestamp function
UNIT_TEST_RUN(unittest_Timestamp);
diff --git a/test/test_topic/main.c b/test/test_topic/main.c
index d10622c6d..746df66b4 100644
--- a/test/test_topic/main.c
+++ b/test/test_topic/main.c
@@ -11,7 +11,6 @@ void unittest_Topic_IsTopicSubscribed(void)
{
NEW_TEST_CASE("Search Topics");
{
- Reset_Context();
// Init default scenario context
Init_Context();
Robus_TopicSubscribe(default_sc.App_1.app->ll_service, 1);
@@ -28,7 +27,6 @@ void unittest_Topic_Subscribe(void)
{
NEW_TEST_CASE("Add random Topics");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -43,7 +41,6 @@ void unittest_Topic_Subscribe(void)
}
NEW_TEST_CASE("Add max topics number");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -64,7 +61,6 @@ void unittest_Topic_Unsubscribe(void)
{
NEW_TEST_CASE("Remove random topics");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -95,7 +91,6 @@ void unittest_Topic_Unsubscribe(void)
}
NEW_TEST_CASE("Remove same topic");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -113,7 +108,6 @@ void unittest_Topic_Unsubscribe(void)
NEW_TEST_CASE("Last topic position is corrupted");
{
- Reset_Context();
// Init default scenario context
Init_Context();
@@ -129,7 +123,6 @@ void unittest_Topic_Unsubscribe(void)
int main(int argc, char **argv)
{
UNITY_BEGIN();
- ASSERT_ACTIVATION(1);
UNIT_TEST_RUN(unittest_Topic_IsTopicSubscribed);
UNIT_TEST_RUN(unittest_Topic_Subscribe);