Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/rtl8127-omega/blob/main/om/rtl8127/test/run.sh # rtl8127-omega aien-dev/rtl8127-omega Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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. 5 set -eu 6 omc=${1:?usage: run.sh OMC} 7 here=$(cd "$(dirname "$0")" && pwd) 8 unit=$(dirname "$here") 9 root=$(cd "$unit/../.." && pwd) 10 out="$root/build/test/rtl8127" 11 mkdir -p "$out" 12 fail=0 13 14 build() { # 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 19 build "$unit/rtl8127.om" "$out/clean" 20 if "$out/clean" > "$out/clean.out"; then 21 cat "$out/clean.out" 22 else 23 cat "$out/clean.out"; echo "rtl8127: clean run FAIL"; fail=1 24 fi 25 26 # mutant NAME 'perl -0pi expression' 27 mutant() { 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 } 41 mutant no-noclose 's/rtlw8 TXNOCLO or v 4/rtlw8 TXNOCLO or v 0/' 42 mutant tx-no-eor 's/dst32 mul i 32 f\n/dst32 mul i 32 0\n/' 43 mutant mac-locked 's/rtlw8 CFG9346 or v UNLOCK/rtlw8 CFG9346 or v 0/' 44 mutant link-inverted 's/if eq and s PHYSLNK 0/if ne and s PHYSLNK 0/' 45 mutant fcs-kept 's/rxcopy i sub n 4/rxcopy i sub n 0/' 46 mutant clo-unchecked 's/if gt done rtltxpend/if gt done 100000/' 47 mutant absent-missed 's/if eq tcr `4294967295`/if eq tcr `4294967294`/' 48 mutant chip-id-ignored 's/if ne and tcr TCRIDM TCRID/if ne and tcr TCRIDM TCRIDM/' 49 mutant rcr-no-myphys 's/or or RCRCHIP RCRBCST RCRMYPH/or RCRCHIP RCRBCST/' 50 mutant rx-no-eor 's/if eq i sub RXN 1\n/if eq i 99\n/' 51 mutant tail-not-written 's/rtlw32 SWTAIL0 and add get rs S_CLOB cur CLOMASK/rtlw32 SWTAIL0 0/' 52 mutant rx-len-unchecked 's/if gt n RXBUF/if gt n 5000/' trap-ok 53 exit $fail