* Multi-threaded timer test. Create several threads that each create * several intervals using the TEST2 timer. The test script can verify * that an individual Trace2 "th_timer" events for each thread and an * aggregate "timer" event are generated. */
| 295 | * aggregate "timer" event are generated. |
| 296 | */ |
| 297 | static int ut_101timer(int argc, const char **argv) |
| 298 | { |
| 299 | const char *usage_error = |
| 300 | "expect <count> <ms_delay> <threads>"; |
| 301 | |
| 302 | struct ut_101_data data = { 0, 0 }; |
| 303 | int nr_threads = 0; |
| 304 | int k; |
| 305 | pthread_t *pids = NULL; |
| 306 | |
| 307 | if (argc != 3) |
| 308 | die("%s", usage_error); |
| 309 | if (get_i(&data.count, argv[0])) |
| 310 | die("%s", usage_error); |
| 311 | if (get_i(&data.delay, argv[1])) |
| 312 | die("%s", usage_error); |
| 313 | if (get_i(&nr_threads, argv[2])) |
| 314 | die("%s", usage_error); |
| 315 | |
| 316 | CALLOC_ARRAY(pids, nr_threads); |
| 317 | |
| 318 | for (k = 0; k < nr_threads; k++) { |
| 319 | if (pthread_create(&pids[k], NULL, ut_101timer_thread_proc, &data)) |
| 320 | die("failed to create thread[%d]", k); |
| 321 | } |
| 322 | |
| 323 | for (k = 0; k < nr_threads; k++) { |
| 324 | if (pthread_join(pids[k], NULL)) |
| 325 | die("failed to join thread[%d]", k); |
| 326 | } |
| 327 | |
| 328 | free(pids); |
| 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | /* |
| 334 | * Single-threaded counter test. Add several values to the TEST1 counter. |
nothing calls this directly
no test coverage detected