3333
3434static fhss_api_t fhss_test_api ;
3535static fhss_timer_t fhss_test_timer ;
36- static fhss_structure_t * fhss_struct ;
36+ static fhss_structure_t * fhss_struct = NULL ;
3737
3838
3939static void test_alloc_fhss_struct (void )
4040{
4141 nsdynmemlib_stub .returnCounter += 1 ;
42+ fhss_test_timer .fhss_timer_stop = & fhss_timer_stop_stub ;
4243 fhss_struct = fhss_allocate_instance (& fhss_test_api , & fhss_test_timer );
44+ fhss_set_callbacks (fhss_struct );
4345 fhss_struct -> bs = malloc (sizeof (fhss_bs_t ));
4446}
4547
4648static void test_free_fhss_struct (void )
4749{
48- free (fhss_struct -> bs );
49- free (fhss_struct );
50+ fhss_disable (fhss_struct );
5051 fhss_struct = NULL ;
5152}
5253
@@ -81,34 +82,7 @@ bool test_fhss_enable()
8182 if (fhss_enable (fhss_api , & fhss_configuration , & fhss_timer , NULL ) != NULL ) {
8283 return false;
8384 }
84- // Test with proper configuration
85- nsdynmemlib_stub .returnCounter = 2 ;
86- if (fhss_enable (fhss_api , & fhss_configuration , & fhss_timer , NULL ) == NULL ) {
87- return false;
88- }
89- // Test that API is stored
90- if (fhss_struct != fhss_get_object_with_api (fhss_api )) {
91- return false;
92- }
93- // Test NULL API
94- if (fhss_struct == fhss_get_object_with_api (NULL )) {
95- return false;
96- }
97- // Test fake API
98- fhss_api_t fhss_fake_api ;
99- if (fhss_struct == fhss_get_object_with_api (& fhss_fake_api )) {
100- return false;
101- }
102- test_free_fhss_struct ();
103- fhss_struct = 0 ;
104- // Test tasklet creation failed
105- fhss_beacon_tasklet_stub .int8_value = -1 ;
106- nsdynmemlib_stub .returnCounter = 2 ;
107- if (fhss_enable (fhss_api , & fhss_configuration , & fhss_timer , NULL ) != NULL ) {
108- return false;
109- }
110- test_free_fhss_struct ();
111- fhss_struct = 0 ;
85+
11286 return true;
11387}
11488
@@ -182,7 +156,6 @@ bool test_fhss_set_synch_configuration()
182156 return false;
183157 }
184158 test_free_fhss_struct ();
185- fhss_struct = 0 ;
186159 return true;
187160}
188161
@@ -208,7 +181,6 @@ bool test_fhss_set_datarate()
208181 return false;
209182 }
210183 test_free_fhss_struct ();
211- fhss_struct = 0 ;
212184 return true;
213185}
214186
@@ -316,38 +288,6 @@ bool test_fhss_update_synch_parent_address()
316288 return true;
317289}
318290
319- bool test_fhss_event_timer_cb ()
320- {
321- fhss_api_t fhss_api ;
322- fhss_configuration_t fhss_configuration ;
323- fhss_timer_t fhss_timer ;
324- nsdynmemlib_stub .returnCounter = 2 ;
325- ns_timer_stub .cb_counter = 1 ;
326- fhss_timer .fhss_timer_stop = & fhss_timer_stop_stub ;
327-
328- // To register callback, execute fhss enable
329- fhss_enable (& fhss_api , & fhss_configuration , & fhss_timer , NULL );
330-
331- fhss_struct -> callbacks .tx_poll = mac_poll_tx_queue ;
332- fhss_struct -> fhss_event_timer = 0 ;
333-
334- if ( ns_timer_stub .cb ){
335- // Test with invalid timer id
336- ns_timer_stub .cb (-1 , 0 );
337- }
338- if ( ns_timer_stub .cb ){
339- // Test with wrong timer id
340- ns_timer_stub .cb (1 , 0 );
341- }
342- if ( ns_timer_stub .cb ){
343- // Test with proper timer id
344- ns_timer_stub .cb (0 , 0 );
345- }
346- test_free_fhss_struct ();
347- fhss_struct = 0 ;
348- return true;
349- }
350-
351291bool test_fhss_timeout_start ()
352292{
353293 uint32_t time = 1000 ;
0 commit comments