Skip to content

Commit fd48582

Browse files
committed
Fix decay tests for --disable-stats case.
1 parent 69acd25 commit fd48582

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

test/unit/decay.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ TEST_BEGIN(test_decay_ticker)
201201
#define NPS 1024
202202
int flags = (MALLOCX_ARENA(0) | MALLOCX_TCACHE_NONE);
203203
void *ps[NPS];
204-
uint64_t epoch, npurge0, npurge1;
204+
uint64_t epoch;
205+
uint64_t npurge0 = 0;
206+
uint64_t npurge1 = 0;
205207
size_t sz, tcache_max, large;
206208
unsigned i, nupdates0;
207209
nstime_t time, decay_time, deadline;
@@ -224,8 +226,8 @@ TEST_BEGIN(test_decay_ticker)
224226
assert_d_eq(mallctl("epoch", NULL, NULL, &epoch, sizeof(uint64_t)), 0,
225227
"Unexpected mallctl failure");
226228
sz = sizeof(uint64_t);
227-
assert_d_eq(mallctl("stats.arenas.0.npurge", &npurge0, &sz, NULL, 0), 0,
228-
"Unexpected mallctl failure");
229+
assert_d_eq(mallctl("stats.arenas.0.npurge", &npurge0, &sz, NULL, 0),
230+
config_stats ? 0 : ENOENT, "Unexpected mallctl result");
229231

230232
for (i = 0; i < NPS; i++) {
231233
ps[i] = mallocx(large, flags);
@@ -266,12 +268,14 @@ TEST_BEGIN(test_decay_ticker)
266268
sizeof(uint64_t)), 0, "Unexpected mallctl failure");
267269
sz = sizeof(uint64_t);
268270
assert_d_eq(mallctl("stats.arenas.0.npurge", &npurge1, &sz,
269-
NULL, 0), 0, "Unexpected mallctl failure");
271+
NULL, 0), config_stats ? 0 : ENOENT,
272+
"Unexpected mallctl result");
270273

271274
nstime_update(&time);
272275
} while (nstime_compare(&time, &deadline) <= 0 && npurge1 == npurge0);
273276

274-
assert_u64_gt(npurge1, npurge0, "Expected purging to occur");
277+
if (config_stats)
278+
assert_u64_gt(npurge1, npurge0, "Expected purging to occur");
275279
#undef NPS
276280
}
277281
TEST_END
@@ -281,7 +285,9 @@ TEST_BEGIN(test_decay_nonmonotonic)
281285
#define NPS (SMOOTHSTEP_NSTEPS + 1)
282286
int flags = (MALLOCX_ARENA(0) | MALLOCX_TCACHE_NONE);
283287
void *ps[NPS];
284-
uint64_t epoch, npurge0, npurge1;
288+
uint64_t epoch;
289+
uint64_t npurge0 = 0;
290+
uint64_t npurge1 = 0;
285291
size_t sz, large0;
286292
unsigned i, nupdates0;
287293

@@ -296,8 +302,8 @@ TEST_BEGIN(test_decay_nonmonotonic)
296302
assert_d_eq(mallctl("epoch", NULL, NULL, &epoch, sizeof(uint64_t)), 0,
297303
"Unexpected mallctl failure");
298304
sz = sizeof(uint64_t);
299-
assert_d_eq(mallctl("stats.arenas.0.npurge", &npurge0, &sz, NULL, 0), 0,
300-
"Unexpected mallctl failure");
305+
assert_d_eq(mallctl("stats.arenas.0.npurge", &npurge0, &sz, NULL, 0),
306+
config_stats ? 0 : ENOENT, "Unexpected mallctl result");
301307

302308
nupdates_mock = 0;
303309
nstime_init(&time_mock, 0);
@@ -324,10 +330,11 @@ TEST_BEGIN(test_decay_nonmonotonic)
324330
assert_d_eq(mallctl("epoch", NULL, NULL, &epoch, sizeof(uint64_t)), 0,
325331
"Unexpected mallctl failure");
326332
sz = sizeof(uint64_t);
327-
assert_d_eq(mallctl("stats.arenas.0.npurge", &npurge1, &sz, NULL, 0), 0,
328-
"Unexpected mallctl failure");
333+
assert_d_eq(mallctl("stats.arenas.0.npurge", &npurge1, &sz, NULL, 0),
334+
config_stats ? 0 : ENOENT, "Unexpected mallctl result");
329335

330-
assert_u64_gt(npurge1, npurge0, "Expected purging to occur");
336+
if (config_stats)
337+
assert_u64_gt(npurge1, npurge0, "Expected purging to occur");
331338

332339
nstime_update = nstime_update_orig;
333340
#undef NPS

0 commit comments

Comments
 (0)