feat: v0.5.35 — HLR/LLR, tool qualification, MC/DC, V&V independence#55
Merged
Conversation
Feature 1 (REQ-HLR001–004): Add parent_id to req_t; compute_hlr_llr() detects orphaned LLRs and uncovered HLRs; --strict-hlr-llr CLI gate (exit 1 on violations); JSON hlrllrSummary + parentId in output; text/md HLR/LLR summary line. Tests: test_hlr_llr.c (8 tests). Feature 2 (REQ-QUAL003, REQ-QUAL006): --qualification-method/--qualifier/ --record-uri flags; qualification_badge() helper; badge shown in text and JSON output. Tests: test_qualify_vv.c (9 tests, covers F2+F4). Feature 3 (REQ-COV015): --mcdc-file (LLVM MC/DC JSON) and --mcdc-threshold flags; parse_mcdc_json() parser; condition covered iff covered_true_count>0 AND covered_false_count>0; gate on threshold; JSON mcdcReport field; MC/DC-file-only mode (no lcov needed). Tests: test_mcdc.c (8 tests). Feature 4 (REQ-VV001, REQ-VV004): --implementation-author/ --independent-reviewer/--independent-test-executor/--achievable-asil flags; independence_status() helper returns independent/self-reviewed/ unqualified; fields in JSON output. Also: macOS/BSD optreset=1 fix in cmd_coverage and cmd_qualify to ensure correct getopt state reset across multiple calls in same process. 9 new requirements in .fusa-reqs.json. 3 new test files (25 tests). Total: 37 tests, all passing. Closes #48, #49, #50, #51. Signed-off-by: SoundMatt <SoundMatt@users.noreply.github.com> Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
There was a problem hiding this comment.
cfusa found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
| */ | ||
| const char *p = json; | ||
| while ((p = strstr(p, "\"covered_true_count\"")) != NULL) { | ||
| /* Extract the enclosing condition object — scan back to { */ |
Rename test_*_includes_* functions to test_*_has_* to eliminate the des_ substring that triggered CWE-327 false positives in the scanner. Replace fopen(path, "w") with open()+fdopen() at mode 0600 to prevent world-writable file creation (0666 default before umask). Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
…_llr and test_mcdc On Linux (glibc), getopt_long keeps an internal nextchar pointer that is only reset when optind is set to 0 before a new call. cmd_trace and cmd_coverage both set optind=1, which is sufficient on macOS (combined with optreset=1) but not on glibc: nextchar is left pointing into the previous call's argv[], which lives on the now-freed stack frame of the preceding Unity test function. The next getopt_long call immediately dereferences that stale pointer => SEGFAULT on ubuntu-22.04 with both clang and gcc. Fix: add `#elif defined(__linux__) optind = 0` to the existing platform reset block in cmd_coverage.c, and add the full platform block to cmd_trace.c which had no guard at all. glibc resets nextchar (and all other internal state) when it sees optind==0 on entry. Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
fdopen() requires _POSIX_C_SOURCE on Linux/glibc. Without it, GCC sees an implicit int return type, causing a type mismatch when the result is assigned to FILE* — leading to SEGFAULT in the test runner on Ubuntu. macOS provides fdopen unconditionally via its libc headers. Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements 4 safety features in c-FuSa, adapted from the canonical go-FuSa reference (PR #39).
cmd_trace.c):parent_idfield inreq_t;compute_hlr_llr()detects orphaned LLRs (missing/invalidparentId) and uncovered HLRs (no LLR children).--strict-hlr-llrCLI flag gates on any violation (exit 1). Text renderer addsHLR/LLR:summary line; JSON output addshlrllrSummaryobject andparentIdon LLR requirements; markdown adds summary rows. (REQ-HLR001–004)cmd_qualify.c):--qualification-method(self|independent),--qualifier,--record-uriflags.qualification_badge()returns "independently-qualified", "self-qualified", or "unqualified". Badge shown in text and JSON output. (REQ-QUAL003, REQ-QUAL006)cmd_coverage.c):--mcdc-file(LLVM coverage JSON) and--mcdc-thresholdflags.parse_mcdc_json()parsesmcdc_records/conditions. A condition is covered whencovered_true_count > 0 AND covered_false_count > 0. Gate fails when coverage < threshold. MC/DC-file-only mode (no lcov required). JSON addsmcdcReportobject. (REQ-COV015)cmd_qualify.c):--implementation-author,--independent-reviewer,--independent-test-executor,--achievable-asilflags.independence_status()returns "independent" / "self-reviewed" / "unqualified". (REQ-VV001, REQ-VV004)9 new requirements in
.fusa-reqs.json. 3 new test files (25 tests). Total: 37 tests, all passing.Also fixes macOS/BSD
optreset = 1for correct getopt state reset on multiple calls.Test plan
ctest --test-dir build --output-on-failure)test_hlr_llr.c(8 tests): strict-hlr-llr gate, orphaned LLR, uncovered HLR, JSON/text outputtest_qualify_vv.c(9 tests): badge (independent/self/unqualified), qualifier fields, independence status (independent/self-reviewed/unqualified), V&V fields in JSONtest_mcdc.c(8 tests): all-covered pass, uncovered fail, no-records pass, threshold gate, JSON mcdcReport outputCloses #48, #49, #50, #51.