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
| 1 | # Proof layer, hardening lane LG: World lifecycle model, differential harness |
| 2 | # against rx_world, and a ThreadSanitizer run of rx_world. Host only (no |
| 3 | # graphics chip, no physics headers). Owned files: tests/model/, this file. |
| 4 | # |
| 5 | # make test-model exhaustive model check + mutants |
| 6 | # make test-model-diff model vs real rx_world (+ concurrent stress) |
| 7 | # make test-model-tsan the same harness built with -fsanitize=thread |
| 8 | # (NOT_RUN when the toolchain has no tsan) |
| 9 | # make test-proof all three, then build/proof/LG-receipt.json |
| 10 | # |
| 11 | # Every target refuses to start while ~/workspace/.spark-quiet exists and |
| 12 | # says NOT_RUN instead. Knobs: PROOF_DEPTH (default 6), PROOF_TSAN_DEPTH (3). |
| 13 | |
| 14 | PROOF_OUT ?= $(OUT_DIR)/proof |
| 15 | PROOF_DEPTH ?= 6 |
| 16 | PROOF_TSAN_DEPTH ?= 3 |
| 17 | PROOF_QUIET ?= $(HOME)/workspace/.spark-quiet |
| 18 | PROOF_CFLAGS ?= -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc -Itests/model -pthread |
| 19 | PROOF_MODEL_SRCS = tests/model/world_model.c tests/model/world_explore.c |
| 20 | PROOF_MODEL_HDRS = tests/model/world_model.h tests/model/world_explore.h |
| 21 | PROOF_RX_SRCS = src/runtime/rx_caproot.c src/runtime/rx_world.c src/runtime/rx_coherent.c src/omega_om_units.c |
| 22 | PROOF_RX_HDRS = src/runtime/rx_world.h src/runtime/rx_caproot.h src/runtime/rx_caller.h \ |
| 23 | src/runtime/omega_shared_world_abi.h |
| 24 | |
| 25 | PROOF_MODEL_BIN = $(PROOF_OUT)/model_check |
| 26 | PROOF_DIFF_BIN = $(PROOF_OUT)/world_diff |
| 27 | PROOF_TSAN_BIN = $(PROOF_OUT)/world_diff_tsan |
| 28 | |
| 29 | define proof_quiet_guard |
| 30 | @if [ -e "$(PROOF_QUIET)" ]; then echo "$(1): NOT_RUN (quiet flag $(PROOF_QUIET) is set)"; exit 1; fi |
| 31 | endef |
| 32 | |
| 33 | $(PROOF_OUT): |
| 34 | mkdir -p $@ |
| 35 | |
| 36 | $(PROOF_MODEL_BIN): tests/model/model_check.om seed/out/omc | $(PROOF_OUT) |
| 37 | ./seed/out/omc < tests/model/model_check.om > $@ && chmod +x $@ |
| 38 | |
| 39 | $(PROOF_DIFF_BIN): tests/model/world_diff.c $(PROOF_MODEL_SRCS) $(PROOF_MODEL_HDRS) \ |
| 40 | $(PROOF_RX_SRCS) $(PROOF_RX_HDRS) | $(PROOF_OUT) |
| 41 | $(CC) $(PROOF_CFLAGS) -O2 -o $@ tests/model/world_diff.c $(PROOF_MODEL_SRCS) $(PROOF_RX_SRCS) |
| 42 | |
| 43 | $(PROOF_TSAN_BIN): tests/model/world_diff.c $(PROOF_MODEL_SRCS) $(PROOF_MODEL_HDRS) \ |
| 44 | $(PROOF_RX_SRCS) $(PROOF_RX_HDRS) | $(PROOF_OUT) |
| 45 | $(CC) $(PROOF_CFLAGS) -O1 -g -fsanitize=thread -o $@ tests/model/world_diff.c \ |
| 46 | $(PROOF_MODEL_SRCS) $(PROOF_RX_SRCS) |
| 47 | |
| 48 | .PHONY: test-model test-model-diff test-model-tsan test-proof |
| 49 | |
| 50 | test-model: |
| 51 | $(call proof_quiet_guard,test-model) |
| 52 | @$(MAKE) --no-print-directory $(PROOF_MODEL_BIN) |
| 53 | ./$(PROOF_MODEL_BIN) > $(PROOF_OUT)/model.log 2>&1; rc=$$?; cat $(PROOF_OUT)/model.log; exit $$rc |
| 54 | |
| 55 | test-model-diff: |
| 56 | $(call proof_quiet_guard,test-model-diff) |
| 57 | @$(MAKE) --no-print-directory $(PROOF_DIFF_BIN) |
| 58 | ./$(PROOF_DIFF_BIN) --depth $(PROOF_DEPTH) --stress > $(PROOF_OUT)/diff.log 2>&1; rc=$$?; \ |
| 59 | cat $(PROOF_OUT)/diff.log; exit $$rc |
| 60 | |
| 61 | # The tsan probe builds and runs a one-line program; a toolchain without |
| 62 | # libtsan (or a memory layout tsan rejects) is recorded as NOT_RUN. |
| 63 | test-model-tsan: |
| 64 | $(call proof_quiet_guard,test-model-tsan) |
| 65 | @mkdir -p $(PROOF_OUT) |
| 66 | @printf 'int main(void){return 0;}\n' > $(PROOF_OUT)/tsan_probe.c |
| 67 | @if ! $(CC) -fsanitize=thread -o $(PROOF_OUT)/tsan_probe $(PROOF_OUT)/tsan_probe.c 2>/dev/null || \ |
| 68 | ! $(PROOF_OUT)/tsan_probe >/dev/null 2>&1; then \ |
| 69 | echo "RESULT tsan=NOT_RUN (toolchain has no working -fsanitize=thread)" | tee $(PROOF_OUT)/tsan.log; \ |
| 70 | exit 0; \ |
| 71 | fi; \ |
| 72 | $(MAKE) --no-print-directory $(PROOF_TSAN_BIN) || exit 1; \ |
| 73 | TSAN_OPTIONS="halt_on_error=0 exitcode=66 second_deadlock_stack=1" \ |
| 74 | ./$(PROOF_TSAN_BIN) --depth $(PROOF_TSAN_DEPTH) --stress --stress-iters 400 \ |
| 75 | > $(PROOF_OUT)/tsan.log 2>&1; rc=$$?; \ |
| 76 | races=$$(grep -c 'WARNING: ThreadSanitizer' $(PROOF_OUT)/tsan.log); \ |
| 77 | echo "RESULT tsan.exit=$$rc" >> $(PROOF_OUT)/tsan.log; \ |
| 78 | echo "RESULT tsan.reports=$$races" >> $(PROOF_OUT)/tsan.log; \ |
| 79 | if [ "$$rc" = 0 ] && [ "$$races" = 0 ]; then v=PASS; else v=FAIL; fi; \ |
| 80 | echo "RESULT tsan=$$v" >> $(PROOF_OUT)/tsan.log; \ |
| 81 | grep '^RESULT tsan\|^WORLD DIFF' $(PROOF_OUT)/tsan.log; \ |
| 82 | grep -A12 'WARNING: ThreadSanitizer' $(PROOF_OUT)/tsan.log | head -60; \ |
| 83 | [ "$$v" = PASS ] |
| 84 | |
| 85 | test-proof: |
| 86 | @mkdir -p $(PROOF_OUT) |
| 87 | @rm -f $(PROOF_OUT)/model.log $(PROOF_OUT)/diff.log $(PROOF_OUT)/tsan.log |
| 88 | @if [ -e "$(PROOF_QUIET)" ]; then \ |
| 89 | echo "test-proof: NOT_RUN (quiet flag $(PROOF_QUIET) is set)"; \ |
| 90 | sh tests/model/receipt.sh $(PROOF_OUT) quiet; exit 1; fi |
| 91 | -@$(MAKE) --no-print-directory test-model |
| 92 | -@$(MAKE) --no-print-directory test-model-diff |
| 93 | -@$(MAKE) --no-print-directory test-model-tsan |
| 94 | sh tests/model/receipt.sh $(PROOF_OUT) |