Skip to content

Commit 034241a

Browse files
committed
controller: Test zwave_controller_transport for empty frames
Origin: SiliconLabsSoftware#124 Bug-SiliconLabs: UIC-3668 Relate-to: SLVDBBP-3169975 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#42 -off-by: Philippe Coval <[email protected]>
1 parent 1685c27 commit 034241a

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

applications/zpc/components/zwave/zwave_controller/test/zwave_controller_transport_test.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*****************************************************************************/
1313
#include "unity.h"
1414
#include "zwave_controller_transport.h"
15+
#include "zwave_controller_transport_internal.h"
1516
#include "zwave_controller_transport_test_callbacks_mock.h"
1617
#include "zwave_controller_internal.h"
1718
#include "zwave_tx_mock.h"
@@ -216,4 +217,29 @@ void test_encapsulation_cc_versions_test()
216217
TEST_ASSERT_EQUAL(
217218
t12.version,
218219
zwave_controller_transport_is_encapsulation_cc(t12.command_class));
219-
}
220+
}
221+
222+
void test_zwave_controller_transport_empty_frame_test()
223+
{
224+
zwave_controller_connection_info_t conn = {};
225+
zwave_rx_receive_options_t opt = {};
226+
227+
// Test with a NULL frame_data pointer
228+
TEST_ASSERT_EQUAL(
229+
SL_STATUS_INVALID_PARAMETER,
230+
zwave_controller_transport_on_frame_received(&conn, &opt, NULL, 0));
231+
232+
// Test with frame_length set to 0
233+
const uint8_t empty_frame[] = {};
234+
TEST_ASSERT_EQUAL(
235+
SL_STATUS_INVALID_PARAMETER,
236+
zwave_controller_transport_on_frame_received(&conn, &opt, empty_frame, 0));
237+
238+
// Test with frame_length less than 1
239+
const uint8_t invalid_frame[] = {0x01};
240+
TEST_ASSERT_EQUAL(SL_STATUS_INVALID_PARAMETER,
241+
zwave_controller_transport_on_frame_received(&conn,
242+
&opt,
243+
invalid_frame,
244+
0));
245+
}

0 commit comments

Comments
 (0)