| 231 | } |
| 232 | |
| 233 | static void test_static_timer_control(void) |
| 234 | { |
| 235 | rt_err_t result; |
| 236 | rt_tick_t set_data; |
| 237 | rt_tick_t get_data; |
| 238 | |
| 239 | timer.callbacks = 0; |
| 240 | timer.is_static = RT_TRUE; |
| 241 | |
| 242 | rt_timer_init(&timer.static_timer, |
| 243 | "static_timer", |
| 244 | timer_control, |
| 245 | &timer, |
| 246 | 5, |
| 247 | RT_TIMER_FLAG_PERIODIC); |
| 248 | |
| 249 | /* test set data */ |
| 250 | set_data = 10; |
| 251 | result = rt_timer_control(&timer.static_timer, RT_TIMER_CTRL_SET_TIME, &set_data); |
| 252 | |
| 253 | uassert_true(result == RT_EOK); |
| 254 | |
| 255 | /* test get data */ |
| 256 | result = rt_timer_control(&timer.static_timer, RT_TIMER_CTRL_GET_TIME, &get_data); |
| 257 | |
| 258 | uassert_true(result == RT_EOK); |
| 259 | uassert_true(set_data == get_data); |
| 260 | |
| 261 | /* calc expect tick */ |
| 262 | timer.expect_tick = rt_tick_get() + set_data; |
| 263 | |
| 264 | /* start timer */ |
| 265 | result = rt_timer_start(&timer.static_timer); |
| 266 | uassert_true(result == RT_EOK); |
| 267 | |
| 268 | rt_thread_delay(3 * set_data + 1); |
| 269 | |
| 270 | /* detach timer */ |
| 271 | result = rt_timer_detach(&timer.static_timer); |
| 272 | uassert_true(result == RT_EOK); |
| 273 | uassert_true(timer.callbacks == 1); |
| 274 | } |
| 275 | |
| 276 | static void timer_start_in_callback(void *param) |
| 277 | { |
nothing calls this directly
no test coverage detected