mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 19:54:01 +01:00
Three units along the file's own concerns: atop_agg.c (204) ingest -- tokenising atop output, folding lines, main atop_agg_state.c (113) the per-PID hash tables, slot lookup, epochs, alloc atop_agg_emit.c (178) the ranked, name-aggregated report Table geometry and the four table functions that now cross a unit boundary go in a private atop_agg_internal.h. Those four lose `static` -- the one visibility change here. The Makefile edit is the load-bearing part: SRC had to grow or the build would have linked the old single unit and the suite would have passed with the new files unused. Checked by reading the compile line, not the exit status. I had written this file off as unverifiable earlier. Wrong: the Makefile has had test and coverage targets all along. Coverage is 92.9% lines / 100% functions on the same 211 source lines, before and after -- the best verifier of anything left over the cap. Production binary builds at -O2 and runs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
53 lines
4.7 KiB
JSON
53 lines
4.7 KiB
JSON
{
|
|
"intent": "Bring linux_configuration/C/atop_agg/atop_agg.c (478 lines) under the repo-wide 250-line cap with no change to the TSV summary the Python report consumes.",
|
|
"scope": [
|
|
"linux_configuration/C/atop_agg/atop_agg.c — reduced to ingest: tokenising atop output, folding lines into the tables, and main",
|
|
"linux_configuration/C/atop_agg/atop_agg_state.c — new: the per-PID hash tables, slot lookup, epoch recording, state_new/state_free",
|
|
"linux_configuration/C/atop_agg/atop_agg_emit.c — new: the ranked, name-aggregated report",
|
|
"linux_configuration/C/atop_agg/atop_agg_internal.h — new: table geometry and the now-cross-unit table declarations",
|
|
"linux_configuration/C/atop_agg/Makefile — SRC/HDR extended so every target compiles the new units",
|
|
"Non-goal: any change to the output format, the hash geometry, or the aggregation arithmetic"
|
|
],
|
|
"changes": [
|
|
"Split the single translation unit three ways along its existing concerns: ingest, table management, and reporting. The three .c files share the State type via the existing public atop_agg.h and the table geometry via a new private atop_agg_internal.h.",
|
|
"hash_pid, cpu_slot, ram_slot and add_epoch lost their `static` qualifier: they are defined in atop_agg_state.c but called from process_line in atop_agg.c, so they now cross a translation-unit boundary and are declared in the internal header. This is the one visibility change in the commit and is noted in the header comment.",
|
|
"Extended the Makefile's SRC and HDR variables and pointed the test target at $(SRC), so the binary, the test binary and the coverage target all compile the three units. Without this the new files would have been silently absent from every build — the test binary would still have linked and passed, since the old atop_agg.c alone was self-contained before the split."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "make clean && make test",
|
|
"result": "pass",
|
|
"evidence": "Compiles all three units under -Wall -Wextra with no warnings, and ./test_atop_agg prints 'atop_agg tests: OK'. The compile line in the output confirms atop_agg_state.c and atop_agg_emit.c are actually being built rather than skipped."
|
|
},
|
|
{
|
|
"command": "make coverage",
|
|
"result": "pass",
|
|
"evidence": "92.9% lines (196 of 211) and 100% functions (13 of 13) after lcov strips the test file — identical to the pre-split baseline measured on the single file. Unchanged totals on unchanged source lines is what shows no code fell out of test reach; the higher 95.1%/344-line figure in the same output is the pre-strip pass that includes test_atop_agg.c itself."
|
|
},
|
|
{
|
|
"command": "make clean && make && printf 'PRC\\tfoo\\t1\\t100\\ny\\n' | ./atop_agg",
|
|
"result": "pass",
|
|
"evidence": "The production binary (built with -O2 and without -DATOP_AGG_NO_MAIN, unlike the test binary) links and runs, emitting a well-formed W record. This checks the real main path, which the test binary compiles out."
|
|
},
|
|
{
|
|
"command": "bash ~/utils/scripts/check_file_length.sh --all",
|
|
"result": "pass",
|
|
"evidence": "atop_agg.c 204, atop_agg_state.c 113, atop_agg_emit.c 178, atop_agg_internal.h 22 — no atop_agg file appears in the over-cap listing, down from a single 478-line file."
|
|
},
|
|
{
|
|
"command": "Coverage measurement, run before choosing this target",
|
|
"result": "pass",
|
|
"evidence": "make coverage at HEAD reported 92.9% lines and 100% functions. That is the strongest verifier among everything still over the cap, and it corrected an earlier assumption of mine that the C file had no usable test gate — the Makefile has had both a test and a coverage target all along."
|
|
}
|
|
],
|
|
"risks": [
|
|
"Four functions changed from static to external linkage. They keep their names and are declared only in a private header not shipped to callers, but the symbols are now visible to the linker and could collide with same-named symbols in a future translation unit added to this binary.",
|
|
"The Makefile change is load-bearing in a way the tests cannot catch: had SRC not been extended, the build would have linked the old single unit and the suite would still have passed while the new files sat unused. Verified by reading the compile line in the make output rather than by trusting the exit status.",
|
|
"atop_agg has no CI workflow; the shell-tests workflow lists linux_configuration/tests/*.sh only. make test is hand-run, so this coverage gate protects future edits only if someone runs it."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit — two edited files and three added files, with no data, config or schema migration.",
|
|
"After rollback, run make clean && make test in linux_configuration/C/atop_agg; expect 'atop_agg tests: OK' from the single-file build."
|
|
]
|
|
}
|