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 / seed / omc / contracts / bridge-check.py

27 lines · 1160 bytes Raw Blame History
1#!/usr/bin/env python3
2"""Verification-only ctypes caller; it does not implement Omega contracts."""
3import ctypes
4import sys
5
6library = ctypes.CDLL(sys.argv[1])
7check = library.omega2_check
8check.argtypes = [ctypes.POINTER(ctypes.c_uint64), ctypes.c_int64]
9check.restype = ctypes.c_uint32
10cases = [(-1, 9, 42), (0, 0, 0), (1, 0, 1), (9, 0, 9),
11 (10, 0, 10), (11, 10, 42), (20, 10, 42), (1, 0, 1)]
12if len(sys.argv) == 3 and sys.argv[2] == "--wrong-expectation":
13 cases[0] = (-1, 0, 42)
14elif len(sys.argv) != 2:
15 raise SystemExit("usage: bridge-check.py LIB [--wrong-expectation]")
16failed = 0
17for argument, expected_status, expected_value in cases:
18 result = ctypes.c_uint64(42)
19 status = check(ctypes.byref(result), argument)
20 matched = (status, result.value) == (expected_status, expected_value)
21 if not matched:
22 failed += 1
23 print("PASS" if matched else "FAIL", "argument", argument,
24 "status", status, "result", result.value,
25 "expected", expected_status, expected_value)
26print("BRIDGE", "PASS" if failed == 0 else "FAIL", "cases", len(cases), "fail", failed)
27raise SystemExit(0 if failed == 0 else 1)