Commit bef9174
unit-test-impl-leader
test(coverage): F-Stack lib/ unit-test Stage-3 coverage integration
Stage-3 of the F-Stack unit-test framework: gcov + lcov 2.0 integration with
automatic per-file coverage threshold enforcement (FU-U-6 / G8 from spec 06
§6.1). Builds on Stage-2 (commit 8a3f0e8) without changing any lib/*.c.
G8 result (final, BOUNCE 1/4 — first run uncovered host_interface.c at 27%
and ff_config.c at 47.6%; addressed in this same commit by adding 5 TC and
1 fixture, then re-ran G8 to PASS):
File Line% Branch% Threshold (line/branch)
--------------------- ----------- ------------ -----------------------
ff_log.c (P0) 100.0% 100.0% 80% / 70% (+20 / +30)
ff_ini_parser.c (P0) 94.5% 80.3% 80% / 70% (+14 / +10)
ff_host_interface.c 92.8% 88.7% 60% / 50% (+33 / +39)
ff_epoll.c (P1) 75.4% 54.3% 60% / 50% (+15 / +4)
ff_config.c (P1) 59.5% 60.3% 50% / 40% ( +9 / +20)
Project total: 68.9% lines (720/1045) / 65.8% branches (502/763)
Test count grew from Stage-2's 59 to 64 (63 PASS + 1 SKIP, ~1.5s):
test_hello : 2 TC
test_ff_ini_parser : 18 TC (1 SKIP, FU-S2-NULLFILE unchanged)
test_ff_log : 13 TC
test_ff_host_interface : 12 TC (8 -> 12, +4 incl. 60+ errno table sweep)
test_ff_epoll : 7 TC
test_ff_config : 12 TC (11 -> 12, +1 valid_all_sections fixture)
Build pipeline additions (tests/unit/Makefile):
- `make coverage` gcov-instrument all lib/ + test sources, capture
via `lcov --capture --rc branch_coverage=1`,
strip /usr/* + cmocka.h + tests/unit/test_*.c +
tests/unit/common/* paths, generate HTML report,
and run `bash coverage_threshold.sh coverage.info`
which exits non-zero on any spec-06 G8 violation.
- `make coverage_clean` removes .gcda + .gcno + coverage.info +
coverage_report/ exclusively via the workspace
rm_tmp_file.sh wrapper (NFR-U-7 zero-tolerance).
- `make help` updated with new targets.
coverage_threshold.sh (110 LoC awk):
- Parses coverage.info SF/LF/LH/BRF/BRH records directly (independent of
`lcov --list` output format which differs between lcov 1.x and 2.x).
- Per-file threshold table mirrors spec 06 §6.1 line-by-line.
- "no branch data" treated as trivially satisfied (avoids false-FAIL on
files with zero conditional branches, e.g. ff_log.c original output).
- Activated +x via /data/workspace/chmod_modify.sh (workspace mandate).
New fixture: tests/unit/fixtures/valid_all_sections.ini
Comprehensive .ini exercising every supported section:
[dpdk] [port0] [vlan0] [vdev0] [freebsd.boot] [freebsd.sysctl]
[kni] [pcap]
Adopted by TC-U-P1-CFG-12 (test_ff_load_config_all_sections).
5 new test cases (Stage-3 coverage extension):
TC-U-P1-HIF-08 (replaced) 60+ errno mapping table sweep
TC-U-P1-HIF-09 (new) ff_clock_gettime_ns_advances
TC-U-P1-HIF-10 (new) ff_arc4random_distribution
TC-U-P1-HIF-12 (new) ff_setenv_getenv_roundtrip
TC-U-P1-HIF-13 (new) ff_mmap_munmap_roundtrip
TC-U-P1-CFG-12 (new) all-sections fixture coverage
Note: TC-U-P1-HIF-11 was originally planned for ff_get_tsc_ns but the impl
lives in ff_dpdk_if.c (out of host scope); deferred as FU-S3-TSC.
.gitignore additions:
- docs/unit_test_spec/zh_cn/plan-*.md path-scoped to keep stage-N plans
local-only (mirrors the existing
plan.md rule on line 47).
- tests/unit/{*.gcda,*.gcno,coverage.info,coverage_report/}
gcov / lcov build artifacts.
- tests/unit/{common,lib_objs}/{*.gcda,*.gcno}
Local-only plan and HTML report produced by this stage:
docs/unit_test_spec/zh_cn/plan-stage3-coverage.md (140 lines, gitignored)
tests/unit/coverage_report/index.html (gitignored)
tests/unit/coverage.info (gitignored)
Spec-driven sub-agent flow (Stage-3, 5 phases):
Phase 1 Leader writes plan-stage3-coverage.md (140 lines, local-only)
Phase 2 skeleton + Makefile coverage target + threshold script
-> G6c PASS (build+run+collect 13 .gcda)
Phase 3 first `make coverage` -> G8 FAIL (HIF 27%, CFG 47.6%) -> BOUNCE+1
Phase 4 BOUNCE recovery: 5 TC + 1 fixture
-> second `make coverage` -> G8 PASS 5/5
Phase 5 reviewer + gate-keeper
-> 12/12 cross-checks; 4-axis all A; 99-stage3-coverage-review.md
Stage-3 review report at:
docs/unit_test_spec/zh_cn/99-stage3-coverage-review.md
Workspace mandate honored:
- 0 direct rm/kill/chmod throughout Stage-3
- chmod for coverage_threshold.sh +x via /data/workspace/chmod_modify.sh
(snapshot kept at .trash/<utc>-chmod for audit)
- make clean / make coverage_clean route .gcda/.gcno/.info/HTML through
/data/workspace/rm_tmp_file.sh
Files NOT staged (intentional):
- plan-stage3-coverage.md : local-only via new path-scoped rule
- coverage_report/, coverage.info, .gcda, .gcno : build artifacts
- .spec-backup/ : backup mirrors
- config.ini local mods, dpdk.bak-23.11.5/, config.test-dpdk24-multi.ini
: orthogonal pre-existing artifacts
Follow-up IDs (per Stage-3 plan §7 + 99-stage3-coverage-review.md §8):
FU-S3-TSC ff_get_tsc_ns coverage (impl in ff_dpdk_if.c, awaits FU-U-4)
FU-S3-EPOLL-BR ff_epoll branch coverage 54% -> P0-tier 70% if escalated
FU-S3-CFG-BR ff_config end-to-end limit at ~60% line; dpdk_args_setup
internals need tighter fixtures or whitebox surgery
FU-S2-NULLFILE (carryover) lib/ff_ini_parser.c NULL-guard would unskip TC
FU-U-4 P2 follow-up tests (5 files: ff_dpdk_*, ff_init, ff_thread)
FU-U-5 CI integration (reuse `make coverage` target)
FU-S2-1 valgrind into `make check`
FU-S2-2 FreeBSD 13/15 build compatibility
FU-U-7 English translation of all spec docs (post audit)1 parent 32b834e commit bef9174
7 files changed
Lines changed: 623 additions & 19 deletions
File tree
- docs/unit_test_spec/zh_cn
- tests/unit
- fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| 145 | + | |
144 | 146 | | |
145 | 147 | | |
146 | | - | |
147 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
148 | 153 | | |
149 | 154 | | |
150 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
0 commit comments