Skip to content
Skills Library
Programming · Testing

c-testing

/c-testing

C testing workflow for unit and integration tests: deterministic harnesses, CMake/CTest execution strategy, sanitizer-first debugging, and fuzzing escalation. Use when writing or fixing tests for C (C11+) modules, stabilizing flaky suites, or reproducing memory/UB bugs.

Repository
malskill ↗
Licence
MIT
Last repository change
13.11.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
5
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

C testing workflow for unit and integration tests: deterministic harnesses, CMake/CTest execution strategy, sanitizer-first debugging, and fuzzing escalation. Use when writing or fixing tests for C (C11+) modules, stabilizing flaky suites, or reproducing memory/UB bugs.

Original author description

C testing workflow for unit and integration tests: deterministic harnesses, CMake/CTest execution strategy, sanitizer-first debugging, and fuzzing escalation. Use when writing or fixing tests for C (C11+) modules, stabilizing flaky suites, or reproducing memory/UB bugs.

How it works

  1. When to activate
  2. Core rules
  3. Recommended workflow
  4. Fast triage checklist
  5. Resources
Original SKILL.md headings · 79 lines, 398 words
SKILL.md preview
---
name: c-testing
description: "C testing workflow for unit and integration tests: deterministic harnesses, CMake/CTest execution strategy, sanitizer-first debugging, and fuzzing escalation. Use when writing or fixing tests for C (C11+) modules, stabilizing flaky suites, or reproducing memory/UB bugs."
license: MIT
compatibility: "C11 baseline. Tools: CMake/CTest or Make. Debugging: gdb/lldb (Linux/macOS), MinGW gdb + objdump (Windows), MSVC dumpbin + WinDbg (Windows). Optional: sanitizers (Clang/GCC), fuzzing (libFuzzer/AFL where supported)."
metadata:
  author: AeonDave
  version: "1.1"
---

# C Testing

Pragmatic workflow for reliable C tests and bug-finding.

## When to activate

- Adding unit tests for C functions
- Building a small test harness around a module
- Debugging failing tests or memory corruption
- Enabling sanitizers or fuzzing to reproduce crashes

---

## Core rules

- Keep unit tests deterministic and isolated.
- Avoid real network/time in unit tests.
- Run ASan/UBSan in CI for memory and UB signal.
- Reproduce failures in the smallest possible command first.
- Do not hide memory/UB bugs behind test-only flags, retries, or inflated timeouts.
- Pair with `test-driven-development` when implementing persistent code or bug fixes test-first.
- Pair with `testing-reliability` for fixture/timing anti-patterns and `systematic-debugging` when the root cause is unclear.

---

## Recommended workflow

### Phase 1 — Reproduce with smallest scope

- Run the single failing test first (`ctest -R ...` or direct binary invocation).
- Capture exact command, seed/input, and environment variables.
- Eliminate unrelated test noise before debugging.

### Phase 2 — Strengthen harness determinism

- Keep each test independent (no shared mutable global state).
- Use explicit fixtures/setup-teardown for temp files and state reset.
- Prefer table-driven tests for parsers and boundary-heavy functions.

### Phase 3 — Sanitizer-first diagnosis

- Run AddressSanitizer for memory corruption/UAF/OOB.
- Run UndefinedBehaviorSanitizer for integer/shift/null/alignment UB.
- Use stack-symbolized reports before stepping into debugger.

### Phase 4 — CTest execution strategy

- Label tests (`unit`, `integration`, `slow`, `flaky`) and run by label.
- Use `--output-on-failure` and `--rerun-failed` in local loops.
- Add per-test `TIMEOUT` to avoid hanging pipelines.

### Phase 5 — Fuzzing escalation

- Add libFuzzer target for parser/decoder/validator style APIs.
- Seed corpus with valid and invalid minimal inputs.
- Keep fuzz target stateless, deterministic, and side-effect free.

---

## Fast triage checklist

- [ ] Single failing test reproduced in isolation.
- [ ] Failure reproduced under sanitizer build (if memory/UB suspected).
- [ ] Backtrace/symbolization points to root cause function.
- [ ] Regression test added for the fixed bug.
- [ ] Full suite rerun (or label-targeted suite if justified) with no new failures.

---

## Resources

Load on demand:

- `references/harness.md` — harness structure, assertions, Unity/cmocka options
- `references/cmake-ctest.md` — CMake/CTest patterns, labels, sanitizer presets, MinGW cross-compile
- `references/sanitizers-fuzzing.md` — ASan/UBSan usage and a minimal fuzz target outline
- `references/debugging.md` — gdb/lldb, Valgrind, MinGW objdump/nm, MSVC dumpbin/WinDbg, ASan env vars
Files in this package (5)
  • SKILL.md 3 KB
  • references/cmake-ctest.md 3 KB
  • references/debugging.md 3 KB
  • references/harness.md 3 KB
  • references/sanitizers-fuzzing.md 2 KB

Versions

The database has no other skills named c-testing.

Database snapshot: 13.11.2026 · package version 53003b22cdf8 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90cpp-testing
    C++ testing workflow for unit and integration tests: GoogleTest/GoogleMock, CMake/CTest integration, diagnosing flaky tests, and running sanitizers and coverage for correctness signal. Use when writing or fixing C++ tests and test infrastructure.
  • 100testing-strategy
    Comprehensive testing methodology, test pyramid, deterministic unit tests, and integration testing. Use when designing test suites or debugging flaky tests.
  • 90cmake-guide
    Use when editing CMake build files for C/C++ projects on CMake 3.20+. Triggers on `CMakeLists.txt`, `*.cmake` files and on prompts about adding targets, linking libraries, dependency fetching, test setup, install rules, or PUBLIC/PRIVATE/INTERFACE visibility, even when the user…
  • 96cpp-testing
    仅在编写/更新/修复 C++ 测试、配置 GoogleTest/CTest、诊断失败或不稳定的测试、或添加覆盖率/ sanitizer 时使用。
  • 100testing
    Apply comprehensive testing best practices including unit, integration, and e2e tests. Use when writing tests, reviewing test coverage, designing testable code, or setting up test infrastructure.
  • 95testing-builder
    Automatically generates comprehensive test suites (unit, integration, E2E) based on code and past testing patterns. Use when user says "write tests", "test this", "add coverage", or after fixing bugs to create regression tests. Eliminates testing friction for ADHD users.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.