interplane.Get Omega
Read in your language

rtl8127-omega

aien-dev/rtl8127-omega

Brought by drakestapleton

branch main Branches Tags History

rtl8127-omega / om / rtl8127 / test / run.sh

53 lines · 2466 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0
3# RTL8127 driver-core test: the Omega core against the software chip, then mutants that must be caught.
4# Usage: sh om/rtl8127/test/run.sh OMC (OMC from tools/omc.sh). Exit 0 only if the clean run passes and every mutant is detected.
5set -eu
6omc=${1:?usage: run.sh OMC}
7here=$(cd "$(dirname "$0")" && pwd)
8unit=$(dirname "$here")
9root=$(cd "$unit/../.." && pwd)
10out="$root/build/test/rtl8127"
11mkdir -p "$out"
12fail=0
13
14build() { # build CORE OUTPUT
15 cat "$1" "$unit/model.om" "$here/driver.om" | "$omc" > "$2" 2> "$2.err" || { echo "rtl8127: omc failed: $(cat "$2.err")"; return 1; }
16 chmod +x "$2"
17}
18
19build "$unit/rtl8127.om" "$out/clean"
20if "$out/clean" > "$out/clean.out"; then
21 cat "$out/clean.out"
22else
23 cat "$out/clean.out"; echo "rtl8127: clean run FAIL"; fail=1
24fi
25
26# mutant NAME 'perl -0pi expression'
27mutant() {
28 cp "$unit/rtl8127.om" "$out/m.om"
29 perl -0pi -e "$2" "$out/m.om"
30 if cmp -s "$unit/rtl8127.om" "$out/m.om"; then echo "rtl8127: mutant $1 did not change the source: FAIL"; fail=1; return; fi
31 if ! build "$out/m.om" "$out/m"; then echo "rtl8127: mutant $1 does not compile: FAIL"; fail=1; return; fi
32 rc=0; "$out/m" > "$out/m.out" 2>&1 || rc=$?
33 if [ "$rc" = 1 ] && grep -q "^RTL8127_OMEGA_MODEL: FAIL" "$out/m.out"; then
34 echo "rtl8127: mutant $1 caught ($(grep -c '^FAIL ' "$out/m.out") checks failed)"
35 elif [ "${3:-}" = trap-ok ] && [ "$rc" = 103 ]; then
36 echo "rtl8127: mutant $1 stopped by Omega's bounds check (trap 3, exit 103), not by a test check"
37 else
38 echo "rtl8127: mutant $1 NOT CAUGHT (exit $rc)"; fail=1
39 fi
40}
41mutant no-noclose 's/rtlw8 TXNOCLO or v 4/rtlw8 TXNOCLO or v 0/'
42mutant tx-no-eor 's/dst32 mul i 32 f\n/dst32 mul i 32 0\n/'
43mutant mac-locked 's/rtlw8 CFG9346 or v UNLOCK/rtlw8 CFG9346 or v 0/'
44mutant link-inverted 's/if eq and s PHYSLNK 0/if ne and s PHYSLNK 0/'
45mutant fcs-kept 's/rxcopy i sub n 4/rxcopy i sub n 0/'
46mutant clo-unchecked 's/if gt done rtltxpend/if gt done 100000/'
47mutant absent-missed 's/if eq tcr 4294967295/if eq tcr 4294967294/'
48mutant chip-id-ignored 's/if ne and tcr TCRIDM TCRID/if ne and tcr TCRIDM TCRIDM/'
49mutant rcr-no-myphys 's/or or RCRCHIP RCRBCST RCRMYPH/or RCRCHIP RCRBCST/'
50mutant rx-no-eor 's/if eq i sub RXN 1\n/if eq i 99\n/'
51mutant tail-not-written 's/rtlw32 SWTAIL0 and add get rs S_CLOB cur CLOMASK/rtlw32 SWTAIL0 0/'
52mutant rx-len-unchecked 's/if gt n RXBUF/if gt n 5000/' trap-ok
53exit $fail