omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
GitHub aien-dev/omega-mv#209 (code only)
Apply it
git checkout -b patch-3e05ddc999ddd2be e6298806f1c7ccd874d123350d639ad8bba6edc7 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/3e05ddc999ddd2be.patch | git am
Provenance
github-import 1
aien-dev/omega-mv
209
8765ff04b4fa1049c11888b2ae1cc4faddb9bb4f
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":209,"url":"https://github.com/aien-dev/omega-mv/pull/209","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:47Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/tests/test_c4_requal_mutants_conversion_equiv.sh b/tests/test_c4_requal_mutants_conversion_equiv.sh new file mode 100755 index 000000000..b3910b15a --- /dev/null +++ b/tests/test_c4_requal_mutants_conversion_equiv.sh @@ -0,0 +1,112 @@ +#!/bin/sh +# Conversion proof: tools/c4_requal_mutants.sh (now an adapter over +# tools/mutation_runner.sh) must behave exactly like the pinned old script +# (commit e6298806f1c7ccd874d123350d639ad8bba6edc7, omega#216, the newest main +# commit that still holds the unconverted script with M03 retired and the +# rewritten M13). Host only, CPU only. PREREQUISITE: build/aienos-authority +# must exist (run 'make test-c4-requal' first); both sweeps build 15 mutants +# (M01 to M16 minus the retired M03), so this is slow. Env ONLY="M01 M05" +# narrows both sweeps to the same ids. +# +# Compared: stdout, exit code, the JSON receipt (byte for byte), and the +# per-mutant verdict list (id + KILLED/SURVIVED*/ERROR from the stderr lines). +# Normalised (volatile only): the receipt path in the stdout summary line +# (each sweep writes to its own file) and /tmp/c4mut.* or /tmp/mutrun.* scratch +# directory names. +# +# ONE more field is masked, the failing-case COUNT: the N in a KILLED note +# "N failing case(s), first: ..." becomes <n> in BOTH old and new, in the stderr +# lines and the JSON receipt, and only when N is an integer >= 1. Evidence that +# the count is not stable even for the OLD script alone: the C4 harness has 24 +# SIGKILL cases (tests/runtime/rx_c4_requal.c:645 kill_sweep(24); the kill delay +# and nanosleep/kill are at :305-308) whose outcome depends on timing. Forge +# diagnostic log test-queue-logs/DEEP6-conv-c4-diag-light-072723.log lines +# 21-36: raw harness fail counts per run were 9 10 10 9 9 (old-style dir) and +# 10 10 9 12 12 (runner-style dir), old script M06 gave 10 and 10 while the +# converted one gave 11 and 8, and the sorted non-kill FAIL lines were identical +# in all 10 runs. The count is descriptive: KILLED is decided by the exit code +# and nf>0 (tools/mutation_runner.sh lines 150-155), never by the value of N. +# A 0 count, a missing count, a non-number and a changed first failing case stay +# visible differences; so does every other field (status, id, file, checks text, +# order, row count, exit code, summary line). The negatives below prove it. +set -u +root=$(cd "$(dirname "$0")/.." && pwd) +cd "$root" || exit 2 +old=tools/_c4_requal_mutants_old.$$.sh +tmp=$(mktemp -d "${TMPDIR:-/tmp}/c4equiv.XXXXXX") || exit 2 +trap 'rm -rf "$tmp" "$root/$old"' EXIT INT TERM +git show e6298806f1c7ccd874d123350d639ad8bba6edc7:tools/c4_requal_mutants.sh > "$old" || { echo "FAIL cannot extract pinned old script"; exit 2; } +chmod +x "$old" + +norm() { # file -> normalised on stdout + sed -e "s#$tmp/[A-Za-z0-9_.]*json#OUT.json#g" -e 's#/tmp/c4mut\.[A-Za-z0-9]*#TMP#g' \ + -e 's#/tmp/mutrun\.[A-Za-z0-9]*#TMP#g' "$1" +} +# stdin -> stdout: the one masked field. The count must follow ( or " or a space +# (stderr "(9 failing case(s), first: " and JSON "note": "9 failing case(s), first: "), +# start with 1-9 (so 0, an empty count and a non-number are not masked) and be +# followed by ", first: " (the KILLED-with-FAIL-lines note shape). +mask() { + sed -e 's/\([(" ]\)[1-9][0-9]* failing case(s), first: /\1<n> failing case(s), first: /' +} +verdicts() { # stderr file -> "id STATUS" per mutant + sed -n 's/^\(M[0-9][0-9]*\) \(KILLED\|SURVIVED_REDUNDANT\|SURVIVED_GAP\|SURVIVED\|ERROR\) .*/\1 \2/p' "$1" +} +# same <fileA> <fileB> <label>: succeeds only if identical +same() { if cmp -s "$1" "$2"; then return 0; else echo "DIFF $3"; diff "$1" "$2" | head -5; return 1; fi; } + +sh tools/c4_requal_mutants.sh "$tmp/new.json" > "$tmp/new.out" 2> "$tmp/new.err"; echo $? > "$tmp/new.rc" +sh "$old" "$tmp/old.json" > "$tmp/old.out" 2> "$tmp/old.err"; echo $? > "$tmp/old.rc" +norm "$tmp/old.out" > "$tmp/old.out.n"; norm "$tmp/new.out" > "$tmp/new.out.n" +verdicts "$tmp/old.err" > "$tmp/old.v"; verdicts "$tmp/new.err" > "$tmp/new.v" +norm "$tmp/old.err" | mask > "$tmp/old.err.n"; norm "$tmp/new.err" | mask > "$tmp/new.err.n" +mask < "$tmp/old.json" > "$tmp/old.json.m"; mask < "$tmp/new.json" > "$tmp/new.json.m" + +fails=0 +n=$(wc -l < "$tmp/old.v") +[ "$n" -gt 0 ] || { echo "FAIL old sweep produced no verdicts"; fails=$((fails + 1)); } +same "$tmp/old.out.n" "$tmp/new.out.n" "stdout" || fails=$((fails + 1)) +same "$tmp/old.rc" "$tmp/new.rc" "exit code" || fails=$((fails + 1)) +same "$tmp/old.json.m" "$tmp/new.json.m" "JSON receipt (failing-case count masked)" || fails=$((fails + 1)) +same "$tmp/old.v" "$tmp/new.v" "per-mutant verdict list" || fails=$((fails + 1)) +same "$tmp/old.err.n" "$tmp/new.err.n" "stderr lines (failing-case count masked)" || fails=$((fails + 1)) + +# Negative checks: the comparison must be able to fail. +neg=0 +{ cat "$tmp/old.v"; echo 'M00 KILLED'; } > "$tmp/neg.v" +same "$tmp/old.v" "$tmp/neg.v" "neg-verdict" >/dev/null 2>&1 && { echo "FAIL negative: altered verdict not detected"; neg=1; } +{ cat "$tmp/old.json"; echo x; } | mask > "$tmp/neg.json.m" +same "$tmp/old.json.m" "$tmp/neg.json.m" "neg-json" >/dev/null 2>&1 && { echo "FAIL negative: altered JSON not detected"; neg=1; } +echo 1 > "$tmp/neg.rc"; echo 0 > "$tmp/neg0.rc" +same "$tmp/neg.rc" "$tmp/neg0.rc" "neg-rc" >/dev/null 2>&1 && { echo "FAIL negative: altered exit code not detected"; neg=1; } + +# The mask is narrow. Synthetic lines in the real stderr and JSON shapes (the +# sweep may not contain a counted note when ONLY narrows it). se/js print one +# line from <status> <count> <first failing case>; mdiff succeeds when the two +# lines are identical AFTER the mask. +se() { printf 'M06 %s choose the NEWEST durable state record (%s failing case(s), first: %s)\n' "$1" "$2" "$3"; } +js() { printf ' {"id": "M06", "file": "src/runtime/rx_compose.c", "checks": "x", "status": "%s", "note": "%s failing case(s), first: %s"},\n' "$1" "$2" "$3"; } +mdiff() { printf '%s\n' "$1" | mask > "$tmp/ma"; printf '%s\n' "$2" | mask > "$tmp/mb"; cmp -s "$tmp/ma" "$tmp/mb"; } +# controls: a differing count of >= 1 IS masked (else the mask is dead), also across digit lengths +mdiff "$(se KILLED 9 A)" "$(se KILLED 8 A)" || { echo "FAIL control: stderr count 9 vs 8 not masked"; neg=1; } +mdiff "$(js KILLED 10 A)" "$(js KILLED 12 A)" || { echo "FAIL control: JSON count 10 vs 12 not masked"; neg=1; } +# (a) a changed first failing case is still different +mdiff "$(se KILLED 9 A)" "$(se KILLED 9 B)" && { echo "FAIL negative: changed first failing case (stderr) not detected"; neg=1; } +mdiff "$(js KILLED 9 A)" "$(js KILLED 8 B)" && { echo "FAIL negative: changed first failing case (JSON) not detected"; neg=1; } +# (b) 0 failing case(s), a missing count and a non-number are still different from 8 +mdiff "$(se KILLED 0 A)" "$(se KILLED 8 A)" && { echo "FAIL negative: 0 vs 8 failing case(s) (stderr) not detected"; neg=1; } +mdiff "$(js KILLED 0 A)" "$(js KILLED 8 A)" && { echo "FAIL negative: 0 vs 8 failing case(s) (JSON) not detected"; neg=1; } +mdiff "$(se KILLED '' A)" "$(se KILLED 8 A)" && { echo "FAIL negative: missing count not detected"; neg=1; } +mdiff "$(se KILLED x A)" "$(se KILLED 8 A)" && { echo "FAIL negative: non-number count not detected"; neg=1; } +# (c) a changed status is still different (the verdict list negative above covers the list; these cover the masked stderr and JSON compares) +mdiff "$(se KILLED 9 A)" "$(se SURVIVED 9 A)" && { echo "FAIL negative: changed status (stderr) not detected"; neg=1; } +mdiff "$(js KILLED 9 A)" "$(js SURVIVED 9 A)" && { echo "FAIL negative: changed status (JSON) not detected"; neg=1; } +[ $neg -eq 0 ] && echo "ok negative checks (altered verdict, JSON, exit code; mask controls; changed first case, 0 / missing / non-number count and changed status each reported different)" +fails=$((fails + neg)) + +if [ $fails -eq 0 ]; then + echo "c4 conversion equivalence: PASS ($n mutants compared; stdout, exit code, JSON, verdicts identical, failing-case counts masked)" + exit 0 +fi +echo "c4 conversion equivalence: FAIL ($fails difference(s), $n mutants compared)" +exit 1 diff --git a/tests/test_mutation_runner.sh b/tests/test_mutation_runner.sh index 4be5b81a1..9f8c04e0b 100755 --- a/tests/test_mutation_runner.sh +++ b/tests/test_mutation_runner.sh @@ -69,6 +69,13 @@ run 'N~missing.c~s/a/b/~no file' -k table -t "$TEST" -b "$BUILD" [ $rc -ne 0 ] && has "$tmp/err" '^N ERROR'; ok "4c missing file is ERROR" $? run 'B~add.c~s/int add/int add_/~breaks the build' -k table -t "$TEST" -b "$BUILD" [ $rc -ne 0 ] && has "$tmp/err" '^B ERROR' && has "$tmp/j.json" 'build failed'; ok "4d build failure is ERROR" $? +# -e TEXT: the note of a build that failed with an EMPTY log. Without -e it stays "build failed: ". +run 'E~add.c~s/a + b/a - b/~empty build log' -k table -t "$TEST" -b 'exit 1' -e 'empty make log (make killed or never started)' +[ $rc -ne 0 ] && has "$tmp/err" '^E ERROR' && has "$tmp/j.json" '"note": "build failed: empty make log (make killed or never started)"'; ok "4e empty build log with -e: note is build failed: TEXT" $? +run 'E~add.c~s/a + b/a - b/~empty build log' -k table -t "$TEST" -b 'exit 1' +[ $rc -ne 0 ] && has "$tmp/err" '^E ERROR' && has "$tmp/j.json" '"note": "build failed: "'; ok "4f empty build log without -e: note stays build failed: (unchanged)" $? +run 'E~add.c~s/a + b/a - b/~error in log' -k table -t "$TEST" -b 'echo "x error: boom"; exit 1' -e 'empty make log (make killed or never started)' +[ $rc -ne 0 ] && has "$tmp/err" '^E ERROR' && has "$tmp/j.json" '"note": "build failed: x error: boom"' && ! has "$tmp/j.json" 'empty make log'; ok "4g non-empty build log with -e keeps the first error line" $? # (5) replace edit: exactly once works, twice is ERROR, @NL@ is a newline run 'R1~add.c~R:return a + b;@>@return a - b;~replace once' -k table -t "$TEST" -b "$BUILD" diff --git a/tools/c4_requal_mutants.sh b/tools/c4_requal_mutants.sh index 0f616dc65..d17944b8b 100755 --- a/tools/c4_requal_mutants.sh +++ b/tools/c4_requal_mutants.sh @@ -6,83 +6,49 @@ # or the edit did not apply. Exit 0 only if every mutant is KILLED. # usage: tools/c4_requal_mutants.sh [out.json] # Extra make args via MAKE_ARGS (e.g. AIENOS_LOCK_REPO=...). +# Thin adapter over tools/mutation_runner.sh (one mutation runner). This file +# holds only the mutant rows (data) and the C4 build and test commands; the +# runner copies the tree, applies each edit, runs them and writes the receipt. set -u root=$(git rev-parse --show-toplevel) out=${1:-"$root/build/c4_mutants.json"} auth=$(ls -d "$root"/build/aienos-authority/*/ 2>/dev/null | head -n 1) [ -n "$auth" ] || { echo "run 'make test-c4-requal' first (builds the authority library)" >&2; exit 2; } phys=${PHYSICS_DIR:-$(cd "$root/../physics" && pwd)} -work=$(mktemp -d /tmp/c4mut.XXXXXX) -trap 'rm -rf "$work"' EXIT # M03 retired: cx_open is the single integrity seam; rx_compose no longer re-walks the chain. -# id~file~sed expression~what the original check does +# id~file~sed expression~what the original check does[~class~rationale] +# class is redundant or gap for a known-equivalent or untested-check mutant, with the +# rationale in the last column; rows with four columns have no justification. MUTANTS=' M01~src/runtime/rx_compose.c~s/ || !aien_mid_equal(&stored, self))/ || 0)/~machine identity must match the stored one M02~src/runtime/rx_compose.c~s/n_units > 1) return RX_ERR_REPLAY;/n_units > 100000) return RX_ERR_REPLAY;/~refuse durable history when the Cortex journal has no state record -M04~src/runtime/rx_compose.c~s/js_branch_info(&c->js, r, &bi) == JS_OK \&\& !bi.staged/js_branch_info(\&c->js, r, \&bi) == JS_OK/~recovered state branch must be sealed, not staged~redundant: no injection can leave a staged branch in the durable checkpoint (staged branches are never persisted, rx_compose.h recovery note), candidate equivalent mutant, UNVERIFIED +M04~src/runtime/rx_compose.c~s/js_branch_info(&c->js, r, &bi) == JS_OK \&\& !bi.staged/js_branch_info(\&c->js, r, \&bi) == JS_OK/~recovered state branch must be sealed, not staged~redundant~no injection can leave a staged branch in the durable checkpoint (staged branches are never persisted, rx_compose.h recovery note), candidate equivalent mutant, UNVERIFIED M05~src/runtime/rx_compose.c~s/if (!o || o->id <= chosen) continue;/continue;/~answer newer, non-durable state records with a rollback admission M06~src/runtime/rx_compose.c~s/for (uint32_t i = l->n; i-- > 0;) {/for (uint32_t i = 0; i < l->n; i++) {/~choose the NEWEST durable state record -M07~src/runtime/rx_compose.c~s/if (n < 0) return RX_ERR_REPLAY;/(void)n;/~an interrupted composition record that cannot be completed refuses~gap: no injection leaves a composition record that cannot be completed +M07~src/runtime/rx_compose.c~s/if (n < 0) return RX_ERR_REPLAY;/(void)n;/~an interrupted composition record that cannot be completed refuses~gap~no injection leaves a composition record that cannot be completed M08~src/runtime/rx_compose.c~s/int n = compose_records(c, S, V, NULL, 0, \&tmp);/int n = 0; (void)S; (void)V; (void)tmp;/~complete every interrupted composition record at open M09~src/runtime/rx_cortex.c~s/if (memcmp(s->obj\[id - 1\].digest, b + p + 8 \* (CX_R_FIXED + n), 32) != 0) {/if (0) {/~each journal record digest is checked at load -M10~src/runtime/rx_jspace.c~s/if (memcmp(d, f + 64, 32)) return JS_ERR_CORRUPT;/;/~J-Space checkpoint body digest~redundant: header digest, body digest and the restore-time content check overlap; each alone is covered by the others and by structural validation -M11~src/runtime/rx_jspace.c~s/if (memcmp(d, f + 96, 32)) return JS_ERR_CORRUPT;/;/~J-Space checkpoint header digest~redundant: header digest, body digest and the restore-time content check overlap; each alone is covered by the others and by structural validation +M10~src/runtime/rx_jspace.c~s/if (memcmp(d, f + 64, 32)) return JS_ERR_CORRUPT;/;/~J-Space checkpoint body digest~redundant~header digest, body digest and the restore-time content check overlap; each alone is covered by the others and by structural validation +M11~src/runtime/rx_jspace.c~s/if (memcmp(d, f + 96, 32)) return JS_ERR_CORRUPT;/;/~J-Space checkpoint header digest~redundant~header digest, body digest and the restore-time content check overlap; each alone is covered by the others and by structural validation M12~src/runtime/rx_compose.c~s/if (js_space_commit(&c->js) != JS_OK) return RX_ERR_REPLAY;/;/~recovered state is made durable before the World starts M13~src/runtime/rx_cortex.c,src/runtime/rx_cortex.c~s/if (memcmp(s->obj\[id - 1\].digest, b + p + 8 \* (CX_R_FIXED + n), 32) != 0) {/if (0) {/@@s/return memcmp(chain, s->chain, 32) == 0 ? CX_OK : CX_ERR_DIGEST;/return CX_OK;/~Cortex integrity (open-time record digest and the audit chain compare both removed) -M14~src/runtime/rx_jspace.c,src/runtime/rx_jspace.c~s/if (memcmp(d, f + 64, 32)) return JS_ERR_CORRUPT;/;/@@s/if (memcmp(d, f + 96, 32)) return JS_ERR_CORRUPT;/;/~J-Space checkpoint integrity (header and body digests both removed)~gap: with every J-Space integrity digest removed all 820 single-byte flips of the task checkpoint are still refused structurally or benign, so the digests are not shown to bite -M15~src/runtime/rx_jspace.c,src/runtime/rx_jspace.c,src/runtime/rx_jspace.c~s/if (memcmp(d, f + 64, 32)) return JS_ERR_CORRUPT;/;/@@s/if (memcmp(d, f + 96, 32)) return JS_ERR_CORRUPT;/;/@@s/if (memcmp(chk, r->content, 32)) { s->stats.corrupt_restores++; return JS_ERR_CORRUPT; }/;/~J-Space integrity, all three layers (header digest, body digest, restore-time content check) removed~gap: with every J-Space integrity digest removed all 820 single-byte flips of the task checkpoint are still refused structurally or benign, so the digests are not shown to bite +M14~src/runtime/rx_jspace.c,src/runtime/rx_jspace.c~s/if (memcmp(d, f + 64, 32)) return JS_ERR_CORRUPT;/;/@@s/if (memcmp(d, f + 96, 32)) return JS_ERR_CORRUPT;/;/~J-Space checkpoint integrity (header and body digests both removed)~gap~with every J-Space integrity digest removed all 820 single-byte flips of the task checkpoint are still refused structurally or benign, so the digests are not shown to bite +M15~src/runtime/rx_jspace.c,src/runtime/rx_jspace.c,src/runtime/rx_jspace.c~s/if (memcmp(d, f + 64, 32)) return JS_ERR_CORRUPT;/;/@@s/if (memcmp(d, f + 96, 32)) return JS_ERR_CORRUPT;/;/@@s/if (memcmp(chk, r->content, 32)) { s->stats.corrupt_restores++; return JS_ERR_CORRUPT; }/;/~J-Space integrity, all three layers (header digest, body digest, restore-time content check) removed~gap~with every J-Space integrity digest removed all 820 single-byte flips of the task checkpoint are still refused structurally or benign, so the digests are not shown to bite M16~src/runtime/rx_compose.c~s/if (pp \&\& state_ref_promoted(s, pp\[CX_WREC_FIELD0 + RXC_S_REF\])) return RX_ERR_REPLAY;/(void)pp; (void)state_ref_promoted;/~refuse a J-Space checkpoint that lost a state Cortex already promoted ' -n=0; killed=0; survived=0; err=0 -printf '{\n "mutants": [\n' > "$out" -first=1 -echo "$MUTANTS" | while IFS="~" read -r id file expr what redund; do - [ -n "$id" ] || continue - if [ -n "${ONLY:-}" ]; then case " $ONLY " in *" $id "*) ;; *) continue;; esac; fi - dir="$work/$id" - mkdir -p "$dir/build" - (cd "$root" && cp -r src tests tools Makefile mk aienos.lock physics.lock "$dir/" 2>/dev/null) - mkdir -p "$dir/build/aienos-authority" - cp -r "$auth" "$dir/build/aienos-authority/$(basename "$auth")" - files=$(echo "$file" | tr ',' ' ') - before=$(for f in $files; do sha256sum "$dir/$f"; done | sha256sum) - i=1 - for f in $files; do - e=$(echo "$expr" | awk -F'@@' -v n=$i '{print $n}') - sed -i "$e" "$dir/$f"; i=$((i+1)) - done - after=$(for f in $files; do sha256sum "$dir/$f"; done | sha256sum) - if [ "$before" = "$after" ]; then status=ERROR; note="edit did not apply" - else - log="$work/$id.log" - if ! (cd "$dir" && nice -n 10 make PHYSICS_DIR="$phys" ${MAKE_ARGS:-} c4-requal-bin >"$log" 2>&1); then - status=ERROR; note="build failed: $(grep -m1 -E "error:|Error " "$log" | cut -c1-120)" - [ -s "$log" ] || note="build failed: empty make log (make killed or never started)" - else - (cd "$dir" && ./build/rx_c4_requal "$dir/r.json") >"$log.run" 2>&1 - rc=$? - nf=$(grep -c '^FAIL' "$log.run") - if [ $rc -ne 0 ] && [ "$nf" -gt 0 ]; then status=KILLED; note="$nf failing case(s), first: $(grep -m1 '^FAIL' "$log.run" | cut -c6-70)" - elif [ $rc -ne 0 ]; then status=KILLED; note="harness exit $rc (crash or abort)" - else - case "$redund" in - redundant:*) status=SURVIVED_REDUNDANT; note="$redund" ;; - gap:*) status=SURVIVED_GAP; note="$redund" ;; - *) status=SURVIVED; note="harness still PASS, no justification recorded" ;; - esac - fi - fi - fi - echo "$id $status $what ($note)" >&2 - [ $first -eq 1 ] || printf ',\n' >> "$out" - first=0 - printf ' {"id": "%s", "file": "%s", "checks": "%s", "status": "%s", "note": "%s"}' "$id" "$file" "$what" "$status" "$(echo "$note" | tr -d '"\\')" >> "$out" - rm -rf "$dir" -done -printf '\n ]\n}\n' >> "$out" -k=$(grep -c '"status": "KILLED"' "$out"); t=$(grep -c '"status"' "$out") -r=$(grep -c '"status": "SURVIVED_REDUNDANT"' "$out"); g=$(grep -c '"status": "SURVIVED_GAP"' "$out") -echo "mutants: $t total, $k killed, $r survived as redundant, $g survived as test gaps (receipt $out)" -# Fail on any unjustified survivor or build/edit error. -[ $((k + r + g)) -eq "$t" ] +# Same copy list as before: the source dirs plus the one authority library. +copy="src tests tools Makefile mk aienos.lock physics.lock build/aienos-authority/$(basename "$auth")" +build="nice -n 10 make PHYSICS_DIR=\"$phys\" ${MAKE_ARGS:-} c4-requal-bin" +test_cmd='./build/rx_c4_requal "$PWD/r.json"' + +# The runner prints the per-mutant lines on stderr as before. -e keeps the old +# note for a build that failed with an empty make log. It FAILS an empty +# sweep (ONLY matching nothing); the legacy script exited 0 then, so map it back. +res=$(printf '%s\n' "$MUTANTS" | "$root/tools/mutation_runner.sh" -k table -m - -t "$test_cmd" \ + -d "$root" -b "$build" -e "empty make log (make killed or never started)" \ + -c "$copy" -o "$out" -f FAIL) +rc=$? +printf '%s\n' "$res" +case $res in "mutants: 0 total,"*) rc=0;; esac +exit $rc diff --git a/tools/mutation_runner.sh b/tools/mutation_runner.sh index b7fb5ca0d..8377a941b 100755 --- a/tools/mutation_runner.sh +++ b/tools/mutation_runner.sh @@ -34,10 +34,13 @@ # # USAGE # tools/mutation_runner.sh -k table|marker -m ROWS|- -t TESTCMD -# [-d SRCDIR] [-b BUILDCMD] [-c "PATH ..."] [-o out.json] [-f PREFIX] [-B] +# [-d SRCDIR] [-b BUILDCMD] [-e TEXT] [-c "PATH ..."] [-o out.json] [-f PREFIX] [-B] # -k reader kind. -m rows file, or - for stdin. -t test command (sh -c, run # in the scratch tree). -d source tree (default .). -b build command run in -# the scratch tree before the test. -c paths (relative to SRCDIR) to copy +# the scratch tree before the test. -e TEXT optional: when the build step +# fails and its log is empty (make killed or never started) the row note +# is "build failed: TEXT" instead of "build failed: <first error line>"; +# without -e nothing changes. -c paths (relative to SRCDIR) to copy # (default: whole tree). -o JSON receipt path. -f line prefix that marks a # failing case in test output, used only for the KILLED note. -B run build # and test on the unmutated tree first; if that fails the sweep FAILS. @@ -54,17 +57,17 @@ # justified-survived; 2 on bad usage. set -u -kind=; rows=; test_cmd=; src=.; build_cmd=; copy=.; out=; fprefix=; baseline=0 -while getopts k:m:t:d:b:c:o:f:B opt; do +kind=; rows=; test_cmd=; src=.; build_cmd=; copy=.; out=; fprefix=; baseline=0; empty_note= +while getopts k:m:t:d:b:e:c:o:f:B opt; do case $opt in k) kind=$OPTARG;; m) rows=$OPTARG;; t) test_cmd=$OPTARG;; d) src=$OPTARG;; - b) build_cmd=$OPTARG;; c) copy=$OPTARG;; o) out=$OPTARG;; f) fprefix=$OPTARG;; + b) build_cmd=$OPTARG;; e) empty_note=$OPTARG;; c) copy=$OPTARG;; o) out=$OPTARG;; f) fprefix=$OPTARG;; B) baseline=1;; *) kind=;; esac done case $kind in table|marker) ;; *) kind=;; esac if [ -z "$kind" ] || [ -z "$rows" ] || [ -z "$test_cmd" ]; then - echo "usage: mutation_runner.sh -k table|marker -m ROWS|- -t TESTCMD [-d SRCDIR] [-b BUILDCMD] [-c PATHS] [-o out.json] [-f PREFIX] [-B]" >&2 + echo "usage: mutation_runner.sh -k table|marker -m ROWS|- -t TESTCMD [-d SRCDIR] [-b BUILDCMD] [-e TEXT] [-c PATHS] [-o out.json] [-f PREFIX] [-B]" >&2 exit 2 fi src=$(cd "$src" 2>/dev/null && pwd) || { echo "mutation_runner: no such source dir" >&2; exit 2; } @@ -140,6 +143,7 @@ run_one() { log=$work/$id.log if [ -n "$build_cmd" ] && ! (cd "$dir" && sh -c "$build_cmd") </dev/null >"$log" 2>&1; then status=ERROR; note="build failed: $(grep -m1 -E "error:|Error " "$log" | cut -c1-120)" + [ -z "$empty_note" ] || [ -s "$log" ] || note="build failed: $empty_note" else (cd "$dir" && sh -c "$test_cmd") </dev/null >"$log.run" 2>&1 rc=$?