Skip to content

tests: regression coverage for priority queue and ringbuf fixes - #97

Merged
gg582 merged 1 commit into
mainfrom
test/regression-coverage
Oct 4, 2026
Merged

gg582 merged 1 commit into
mainfrom
test/regression-coverage

Conversation

@gg582

@gg582 gg582 commented Oct 4, 2026

Copy link
Copy Markdown
Member

Summary

Adds regression tests for three recently fixed bugs. No library code changes.

1. Priority-0 task starvation/deadlock (fixed in 95854ca)

tests/test_sharded_sched.c — new test_pool_priority_zero_no_starvation:
submits 64 tasks all at priority 0 through the thread pool and asserts every
one completes via futures. The fixed bug encoded (priority 0, slot 0) to NULL,
silently dropping the task and deadlocking the submitter in ttak_future_get.
Also asserts the burst completes in under 10 seconds.

2. Ring buffer concurrent query data race (fixed in 439a7ff)

tests/test_ringbuf.c — new test_ringbuf_concurrent_query_race:
a producer and a consumer hammer push/pop while two querier threads
continuously call ttak_ringbuf_count/is_empty/is_full. Asserts the
per-snapshot capacity bound (count <= capacity) and sum sanity
(count == pushed - popped) after join, plus no crash. (Cross-function
agreements like count==0 == is_empty are intentionally not asserted: each
query takes its own lock, so they are separate snapshots of a concurrently
mutating buffer.)

3. Heap-backed priority queue restructure (cb804a9 / 95854ca)

tests/test_priority.c:

  • test_priority_queue_zero_priority_slot0 — reproduces the slot-0 NULL
    encoding directly at queue level: a lone priority-0 task, and a priority-0
    task buried under 32 higher-priority pushes, must both survive push/pop.
  • test_priority_queue_heap_stress — pushes 5000 items with a deterministic
    LCG (half priority 0, heavy duplication, occasional 42), pops all, and
    verifies pop order is monotonically non-increasing against a
    max-extraction model, with pop count exactly matching push count.

Test plan

  • make test — full suite passes

- test_sharded_sched: test_pool_priority_zero_no_starvation submits 64
  tasks all at priority 0 through the thread pool and asserts every one
  completes via futures, covering the slot-0 NULL-element drop fixed in
  95854ca that deadlocked submitters in ttak_future_get.
- test_ringbuf: test_ringbuf_concurrent_query_race hammers push/pop from
  producer/consumer threads while two querier threads call
  ttak_ringbuf_count/is_empty/is_full, covering the data race fixed in
  439a7ff. Asserts the capacity bound and pushed-minus-popped sum sanity.
- test_priority: test_priority_queue_zero_priority_slot0 reproduces the
  heap slot-0 NULL encoding directly at queue level, and
  test_priority_queue_heap_stress pushes 5000 items with mixed priorities
  (half of them 0, many duplicates) and verifies pop order is
  monotonically non-increasing against a max-extraction model, covering
  the heap restructure in cb804a9/95854ca8.
@gg582
gg582 force-pushed the test/regression-coverage branch from a3494f0 to d6cf42a Compare October 4, 2026 12:33
@gg582
gg582 merged commit e0c5b9d into main Oct 4, 2026
3 checks passed
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.

1 participant