interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / tools / zero-legacy / fixtures / elf-mutants.sh

34 lines · 1815 bytes Raw Blame History
1#!/bin/sh
2# elf-mutants.sh ZLDIR OMC WORK (sh tools/zero-legacy/fixtures/elf-mutants.sh "$PWD/tools/zero-legacy" OMC DIR): each mutant is one sed edit of elfclose.om in a fresh copy of
3# tools/zero-legacy; the gate must exit 1 for every one (a surviving mutant is a FAIL here).
4zl=$1; omc=$2; work=$3
5mkdir -p "$work"
6killed=0 survived=0
7mut() {
8 name=$1; expr=$2
9 d=$work/$name
10 mkdir -p "$d"
11 (cd "$zl" && tar --exclude=./build -cf - .) | (cd "$d" && tar -xf -)
12 sed -i "$expr" "$d/elfclose.om"
13 if cmp -s "$zl/elfclose.om" "$d/elfclose.om"; then echo "MUTANT $name INVALID (edit did not apply)"; survived=$((survived+1)); return; fi
14 (cd "$d" && AIEN_OMC=$omc sh ./gate.sh > gate.out 2>&1); rc=$?
15 if [ "$rc" -eq 1 ]; then killed=$((killed+1)); echo "MUTANT $name killed (gate rc=1): $(grep -E '_exit [1-9]|refused 0' "$d/gate.out" | tr '\n' ' ')"
16 else survived=$((survived+1)); echo "MUTANT $name SURVIVED (gate rc=$rc)"; fi
17}
18mut no-needed 's/^put ndn 0 add m n$/put ndn 0 0/'
19mut dyn-not-foreign '/^fx = true$/d'
20mut no-class-check 's/^if ne get hb 4 2$/if eq get hb 4 9/'
21mut no-map-dedupe 's/^if same$/if false/'
22mut perms-byte 's/^ret eq get mp add i 3 120$/ret eq get mp add i 2 120/'
23mut vaddr-as-offset 's/^ret add p64 add b 8 sub v va$/ret v/'
24mut no-gnu-phdr 's/^if ge t 1685382480$/if ge t 1685382484/'
25mut no-comment-scan 's/^r = comment b$/r = ulong 0/'
26mut no-path-escape 's/^if esc$/if false/'
27mut needed-ctl-ok 's/^if ctlb c$/if false/'
28mut needed-comma-ok 's/^if eq c 44$/if false/'
29mut interp-ctl-ok 's/^if ctlb get ib i$/if false/'
30mut del-not-ctl 's/^ret eq c 127$/ret false/'
31mut load-unchecked 's/^if not inrange p64 add b 8 p64 add b 32$/if false/'
32mut nonregular-ok 's/^if ne and m 61440 32768$/if false/'
33echo "MUTANTS killed=$killed survived=$survived"
34[ "$survived" -eq 0 ]