33
33
34
34
static fhss_api_t fhss_test_api ;
35
35
static fhss_timer_t fhss_test_timer ;
36
- static fhss_structure_t * fhss_struct ;
36
+ static fhss_structure_t * fhss_struct = NULL ;
37
37
38
38
39
39
static void test_alloc_fhss_struct (void )
40
40
{
41
41
nsdynmemlib_stub .returnCounter += 1 ;
42
+ fhss_test_timer .fhss_timer_stop = & fhss_timer_stop_stub ;
42
43
fhss_struct = fhss_allocate_instance (& fhss_test_api , & fhss_test_timer );
44
+ fhss_set_callbacks (fhss_struct );
43
45
fhss_struct -> bs = malloc (sizeof (fhss_bs_t ));
44
46
}
45
47
46
48
static void test_free_fhss_struct (void )
47
49
{
48
- free (fhss_struct -> bs );
49
- free (fhss_struct );
50
+ fhss_disable (fhss_struct );
50
51
fhss_struct = NULL ;
51
52
}
52
53
@@ -81,34 +82,7 @@ bool test_fhss_enable()
81
82
if (fhss_enable (fhss_api , & fhss_configuration , & fhss_timer , NULL ) != NULL ) {
82
83
return false;
83
84
}
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
+
112
86
return true;
113
87
}
114
88
@@ -182,7 +156,6 @@ bool test_fhss_set_synch_configuration()
182
156
return false;
183
157
}
184
158
test_free_fhss_struct ();
185
- fhss_struct = 0 ;
186
159
return true;
187
160
}
188
161
@@ -208,7 +181,6 @@ bool test_fhss_set_datarate()
208
181
return false;
209
182
}
210
183
test_free_fhss_struct ();
211
- fhss_struct = 0 ;
212
184
return true;
213
185
}
214
186
@@ -316,38 +288,6 @@ bool test_fhss_update_synch_parent_address()
316
288
return true;
317
289
}
318
290
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
-
351
291
bool test_fhss_timeout_start ()
352
292
{
353
293
uint32_t time = 1000 ;
0 commit comments