| 111 | } |
| 112 | |
| 113 | static int |
| 114 | test_timer_racecond(void) |
| 115 | { |
| 116 | int ret; |
| 117 | uint64_t hz; |
| 118 | uint64_t cur_time; |
| 119 | uint64_t end_time; |
| 120 | int64_t diff = 0; |
| 121 | unsigned lcore_id; |
| 122 | unsigned i; |
| 123 | |
| 124 | main_lcore = lcore_id = rte_lcore_id(); |
| 125 | hz = rte_get_timer_hz(); |
| 126 | |
| 127 | /* init and start timers */ |
| 128 | for (i = 0; i < N_TIMERS; i++) { |
| 129 | rte_timer_init(&timer[i]); |
| 130 | ret = reload_timer(&timer[i]); |
| 131 | TEST_ASSERT(ret == 0, "reload_timer failed"); |
| 132 | |
| 133 | /* Distribute timers to workers. |
| 134 | * Note that we assign timer[0] to the main. |
| 135 | */ |
| 136 | timer_lcore_id[i] = lcore_id; |
| 137 | lcore_id = rte_get_next_lcore(lcore_id, 1, 1); |
| 138 | } |
| 139 | |
| 140 | /* calculate the "end of test" time */ |
| 141 | cur_time = rte_get_timer_cycles(); |
| 142 | end_time = cur_time + (hz * TEST_DURATION_S); |
| 143 | |
| 144 | /* start worker cores */ |
| 145 | stop_workers = 0; |
| 146 | printf("Start timer manage race condition test (%u seconds)\n", |
| 147 | TEST_DURATION_S); |
| 148 | rte_eal_mp_remote_launch(worker_main_loop, NULL, SKIP_MAIN); |
| 149 | |
| 150 | while (diff >= 0) { |
| 151 | /* run the timers */ |
| 152 | rte_timer_manage(); |
| 153 | |
| 154 | /* wait 100 ms */ |
| 155 | usec_delay(100*1000); |
| 156 | |
| 157 | cur_time = rte_get_timer_cycles(); |
| 158 | diff = end_time - cur_time; |
| 159 | } |
| 160 | |
| 161 | /* stop worker cores */ |
| 162 | printf("Stopping timer manage race condition test\n"); |
| 163 | stop_workers = 1; |
| 164 | rte_eal_mp_wait_lcore(); |
| 165 | |
| 166 | /* stop timers */ |
| 167 | for (i = 0; i < N_TIMERS; i++) { |
| 168 | ret = rte_timer_stop(&timer[i]); |
| 169 | TEST_ASSERT(ret == 0, "rte_timer_stop failed"); |
| 170 | } |
nothing calls this directly
no test coverage detected