Skip to content

test: cover pop_lru valueless-entry scan; make impossible table miss fail fast - #46

Merged
SF-Zhou merged 1 commit into
mainfrom
coverage
Jul 16, 2026
Merged

test: cover pop_lru valueless-entry scan; make impossible table miss fail fast#46
SF-Zhou merged 1 commit into
mainfrom
coverage

Conversation

@SF-Zhou

@SF-Zhou SF-Zhou commented Jul 16, 2026

Copy link
Copy Markdown
Owner
  • Add a white-box test for pop_lru encountering an unheld entry in the defensive valueless state (removed during the scan and skipped), and extract the shared make_valueless() test helper.
  • Replace pop_lru's silent 'if let Ok' on find_entry with .ok().expect(): every node in the LRU list is owned by the table, so a miss is a broken invariant and should panic instead of being ignored. This also removes the untestable Err region from coverage.

…fail fast

- Add a white-box test for pop_lru encountering an unheld entry in the
  defensive valueless state (removed during the scan and skipped), and
  extract the shared make_valueless() test helper.
- Replace pop_lru's silent 'if let Ok' on find_entry with .ok().expect():
  every node in the LRU list is owned by the table, so a miss is a broken
  invariant and should panic instead of being ignored. This also removes
  the untestable Err region from coverage.
Copilot AI review requested due to automatic review settings July 16, 2026 05:31
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ee93045) to head (0cd9f31).

Additional details and impacted files
@@             Coverage Diff             @@
##             main       #46      +/-   ##
===========================================
+ Coverage   99.91%   100.00%   +0.08%     
===========================================
  Files           3         3              
  Lines        2422      2441      +19     
===========================================
+ Hits         2420      2441      +21     
+ Misses          2         0       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens LruLockMap’s internal invariants and expands test coverage around defensive “valueless entry” states during LRU eviction.

Changes:

  • Add a white-box test to cover pop_lru skipping an unheld entry in a defensive valueless state.
  • Extract a shared make_valueless() test helper to reduce duplication.
  • Make pop_lru fail fast if an LRU-list node cannot be found in the backing table (invariant violation).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lru_lockmap.rs
Comment on lines +1379 to +1394
/// White-box helper: puts the unheld entry for `key` into the defensive
/// valueless state (refcnt == 0, no value) that iteration code must
/// tolerate but that cannot be produced through the public API.
fn make_valueless(cache: &LruLockMap<u32, u32>, key: u32) {
for shard in &cache.shards {
let inner = shard.inner.lock();
for s in inner.table.iter() {
if s.key == key {
// SAFETY: the shard lock is held and refcnt == 0, so no
// guard exists and none can be created concurrently.
unsafe { (*s.value.get()).take() };
s.set_value_state(false);
}
}
}
}
Comment thread src/lru_lockmap.rs
Comment on lines +183 to +185
// Every node in the LRU list is owned by the table, so the
// lookup cannot fail.
let entry = self
@SF-Zhou
SF-Zhou merged commit 168a61d into main Jul 16, 2026
16 checks passed
@SF-Zhou
SF-Zhou deleted the coverage branch July 16, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants