| 69 | } |
| 70 | } |
| 71 | TEST_END |
| 72 | |
| 73 | TEST_BEGIN(test_background_thread_running) { |
| 74 | test_skip_if(!have_background_thread); |
| 75 | test_skip_if(!config_stats); |
| 76 | |
| 77 | #if defined(JEMALLOC_BACKGROUND_THREAD) |
| 78 | tsd_t *tsd = tsd_fetch(); |
| 79 | background_thread_info_t *info = &background_thread_info[0]; |
| 80 | |
| 81 | test_repeat_background_thread_ctl(false); |
| 82 | test_switch_background_thread_ctl(true); |
| 83 | assert_b_eq(info->state, background_thread_started, |
| 84 | "Background_thread did not start.\n"); |
| 85 | |
| 86 | nstime_t start, now; |
| 87 | nstime_init(&start, 0); |
| 88 | nstime_update(&start); |
| 89 | |
| 90 | bool ran = false; |
| 91 | while (true) { |
| 92 | malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx); |
| 93 | if (info->tot_n_runs > 0) { |
| 94 | ran = true; |
| 95 | } |
| 96 | malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx); |
| 97 | if (ran) { |
| 98 | break; |
| 99 | } |
| 100 | |
| 101 | nstime_init(&now, 0); |
| 102 | nstime_update(&now); |
| 103 | nstime_subtract(&now, &start); |
| 104 | assert_u64_lt(nstime_sec(&now), 1000, |
| 105 | "Background threads did not run for 1000 seconds."); |
| 106 | sleep(1); |
| 107 | } |
| 108 | test_switch_background_thread_ctl(false); |
| 109 | #endif |
| 110 | } |
| 111 | TEST_END |
| 112 | |
| 113 | int |
nothing calls this directly
no test coverage detected