| 485 | #undef NPS |
| 486 | } |
| 487 | TEST_END |
| 488 | |
| 489 | TEST_BEGIN(test_decay_nonmonotonic) { |
| 490 | test_skip_if(check_background_thread_enabled()); |
| 491 | #define NPS (SMOOTHSTEP_NSTEPS + 1) |
| 492 | int flags = (MALLOCX_ARENA(0) | MALLOCX_TCACHE_NONE); |
| 493 | void *ps[NPS]; |
| 494 | uint64_t npurge0 = 0; |
| 495 | uint64_t npurge1 = 0; |
| 496 | size_t sz, large0; |
| 497 | unsigned i, nupdates0; |
| 498 | |
| 499 | sz = sizeof(size_t); |
| 500 | assert_d_eq(mallctl("arenas.lextent.0.size", (void *)&large0, &sz, NULL, |
| 501 | 0), 0, "Unexpected mallctl failure"); |
| 502 | |
| 503 | assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0, |
| 504 | "Unexpected mallctl failure"); |
| 505 | do_epoch(); |
| 506 | sz = sizeof(uint64_t); |
| 507 | npurge0 = get_arena_npurge(0); |
| 508 | |
| 509 | nupdates_mock = 0; |
| 510 | nstime_init(&time_mock, 0); |
| 511 | nstime_update(&time_mock); |
| 512 | monotonic_mock = false; |
| 513 | |
| 514 | nstime_monotonic_orig = nstime_monotonic; |
| 515 | nstime_update_orig = nstime_update; |
| 516 | nstime_monotonic = nstime_monotonic_mock; |
| 517 | nstime_update = nstime_update_mock; |
| 518 | |
| 519 | for (i = 0; i < NPS; i++) { |
| 520 | ps[i] = mallocx(large0, flags); |
| 521 | assert_ptr_not_null(ps[i], "Unexpected mallocx() failure"); |
| 522 | } |
| 523 | |
| 524 | for (i = 0; i < NPS; i++) { |
| 525 | dallocx(ps[i], flags); |
| 526 | nupdates0 = nupdates_mock; |
| 527 | assert_d_eq(mallctl("arena.0.decay", NULL, NULL, NULL, 0), 0, |
| 528 | "Unexpected arena.0.decay failure"); |
| 529 | assert_u_gt(nupdates_mock, nupdates0, |
| 530 | "Expected nstime_update() to be called"); |
| 531 | } |
| 532 | |
| 533 | do_epoch(); |
| 534 | sz = sizeof(uint64_t); |
| 535 | npurge1 = get_arena_npurge(0); |
| 536 | |
| 537 | if (config_stats) { |
| 538 | assert_u64_eq(npurge0, npurge1, "Unexpected purging occurred"); |
| 539 | } |
| 540 | |
| 541 | nstime_monotonic = nstime_monotonic_orig; |
| 542 | nstime_update = nstime_update_orig; |
| 543 | #undef NPS |
| 544 | } |
nothing calls this directly
no test coverage detected