interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tests / path / mutate.sh

72 lines · 4284 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# TEST HARNESS: PATH-1 mutation oracle. Each mutant edits a scratch copy of
18# src/path/rx_path.om, never the source. A mutant counts as killed only when it
19# compiles with seed/out/omc and the test program reports at least one FAIL line.
20set -eu
21root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
22omc=${OMC:-"$root/seed/out/omc"}
23scratch=$(mktemp -d "${TMPDIR:-/tmp}/omega-path-mutants.XXXXXX")
24trap 'rm -rf "$scratch"' EXIT HUP INT TERM
25killed=0
26total=0
27run() {
28 name=$1
29 expression=$2
30 total=$((total+1))
31 cp "$root/src/path/rx_path.om" "$scratch/orig.om"
32 sed "$expression" "$scratch/orig.om" > "$scratch/mutant.om"
33 if cmp -s "$scratch/orig.om" "$scratch/mutant.om"; then
34 echo "MUTANT $name: mutation did not apply" >&2; exit 1
35 fi
36 # A compiler error does not count as an invariant caught by tests.
37 cat "$scratch/mutant.om" "$root/tests/path/test_path_identity.om" | "$omc" > "$scratch/test"
38 chmod +x "$scratch/test"
39 if "$scratch/test" > "$scratch/log" 2>&1; then
40 echo "MUTANT $name: SURVIVED" >&2; cat "$scratch/log" >&2; exit 1
41 fi
42 if ! grep -q '^FAIL ' "$scratch/log"; then
43 echo "MUTANT $name: crashed without assertion evidence" >&2; cat "$scratch/log" >&2; exit 1
44 fi
45 killed=$((killed+1))
46 echo "MUTANT $name: killed"
47}
48run semantic-tag 's/text t_rxp_sem_tag "omega.path.v1"/text t_rxp_sem_tag "omega.path.v2"/'
49run tag-terminator '/^fn rxp_raw_semantic_id/,/^end/{/rxp_emit_byte 0/d;}'
50run little-endian '/^fn rxp_emit_u16/,/^end/{s/rxp_emit_byte b0/rxp_emit_byte X/;s/rxp_emit_byte b1/rxp_emit_byte b0/;s/rxp_emit_byte X/rxp_emit_byte b1/;};s/or shl b0 8 b1/or shl b1 8 b0/'
51run step-limit 's/if ge rx_path_step_count pid RX_PATH_MAX_STEPS/if gt rx_path_step_count pid RX_PATH_MAX_STEPS/'
52run input-limit 's/if gt nin RX_PATH_MAX_INPUTS_PER_STEP/if gt nin add RX_PATH_MAX_INPUTS_PER_STEP 1/'
53run size-limit 's/if gt add ulong sz ssz RX_PATH_MAX_TOTAL_SERIALIZATION/if false/'
54run attr-sort '/^fn rx_path_add_attribute/,/^end/{s/if ge rxp_key_cmp_slot_tmp add abase pos klen 0/if false/;}'
55run constraint-sort '/^fn rx_path_add_constraint/,/^end/{s/if gt rxp_cons_cmp_slot_tmp add cbase pos kind plen 0/if false/;}'
56run step-index-check 's/if ne ulong sidx idx/if false/'
57run steps-payload-len 's/if ne ulong slen sub get g_rd 0 get g_rd 1/if false/'
58run trailing-bytes 's/if ne get g_rd 1 get g_rd 0/if false/'
59run magic 's/if or ne get g_dec_in p 79 ne get g_dec_in add p 1 77/if false/'
60run family-role 's/if ne shr role 8 family/if false/'
61run expected-id 's/rc = RX_PATH_ERR_ID_MISMATCH/rc = RX_PATH_OK/'
62run parent-frozen 's/put g_p_frozen parent 1/put g_p_frozen parent 0/'
63run lineage-check '/^fn rxp_check_lineage/,/^end/{s/ret RX_PATH_ERR_ID_MISMATCH/ret RX_PATH_OK/;}'
64run divergence-bound 's/if gt div_idx rx_path_step_count parent/if gt div_idx add 1 rx_path_step_count parent/'
65run prefix-resolve 's/if and ge par 0 lt i divi/if and ge par 0 le i divi/'
66run realization-machine '/^fn rx_path_realization_id/,/^end/{/while lt i 32/,/end/{s/rxp_emit_byte get g_real_ids i/rxp_emit_byte 0/;};}'
67run realization-evidence '/^fn rx_path_realization_id/,/^end/{/while lt i 128/,/end/{s/rxp_emit_byte get g_real_ids i/rxp_emit_byte 0/;};}'
68run shape-check 's/ret rxp_check_step_fields.*/ret RX_PATH_OK/'
69run ancestor-fork 's/if eq ulong q child/if false/'
70run encode-lineage '/^fn rx_path_encode/,/^end/{s/rc = rxp_check_lineage pid/rc = RX_PATH_OK/;}'
71run equal-constraints 's/if gt rxp_cons_cmp_slots sub sl 1 sl 0/if ge rxp_cons_cmp_slots sub sl 1 sl 0/'
72echo "PATH mutations: $killed killed, $((total-killed)) survived ($total total)"