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
omega-mv / apps / interplane-forge / salvage / tests / verify.om
| 1 | text tvhello "om2\ntext msg \"hello\\n\"\nfn main to int\nr = write 1 msg 0 len msg\nret 0\nend\n" |
| 2 | text tvexpect "hello\n" |
| 3 | text tvwrong "wrong\n" |
| 4 | text tvbad "not an Omega program" |
| 5 | text tvdeny "om2\ntext p \"/etc/passwd\"\nfn main to int\nfd = fopen p 0 len p 0 0\nif ge fd 0\nret 1\nend\nret 0\nend\n" |
| 6 | text tvloop "om2\nfn main to int\nx = ulong 0\nfor i ulong 1000000000000\nx = add x i\nend\nret int and x 255\nend\n" |
| 7 | text tvexit "om2\nfn main to int\nret 1\nend\n" |
| 8 | text tvpass "SALVAGE_SANDBOX PASS 7 (includes held-writer handoff control)\n" |
| 9 | fn tvpart code view uchar * expected view uchar * to void |
| 10 | slbegin 2 |
| 11 | for i ulong 5 |
| 12 | x = slput i tlempty |
| 13 | end |
| 14 | x = slput 5 code |
| 15 | x = slput 6 tlempty |
| 16 | x = slput 7 tlempty |
| 17 | x = slput 8 expected |
| 18 | for i ulong 3 |
| 19 | x = slput add i 9 tlempty |
| 20 | end |
| 21 | end |
| 22 | fn tvhandoff to bool |
| 23 | slpath tlwork tlbuilt |
| 24 | held = fopen glpath 0 get glpathn 0 557057 0 |
| 25 | if lt held 0 |
| 26 | ret false |
| 27 | end |
| 28 | r = fchmod int held 320 |
| 29 | slpknew |
| 30 | slpkpath tlbuilt |
| 31 | raw = slrun tlin tlout true |
| 32 | busy = eq get glstatus 1 26 |
| 33 | sealed = slseal |
| 34 | slpknew |
| 35 | slpkpath tlbin |
| 36 | safe = slrun tlin tlout true |
| 37 | r = fclose int held |
| 38 | ret and and not raw busy and sealed safe |
| 39 | end |
| 40 | |
| 41 | fn main to int |
| 42 | p = new uchar 512 0 |
| 43 | n = argread 1 p 0 512 |
| 44 | if le n 0 |
| 45 | ret 10 |
| 46 | end |
| 47 | if not slroot view part p 0 ulong n |
| 48 | ret 11 |
| 49 | end |
| 50 | if not slinit |
| 51 | ret 12 |
| 52 | end |
| 53 | tvpart tvhello tvexpect |
| 54 | if not slverify |
| 55 | ret 1 |
| 56 | end |
| 57 | if not tvhandoff |
| 58 | ret 7 |
| 59 | end |
| 60 | tvpart tvhello tvwrong |
| 61 | if slverify |
| 62 | ret 2 |
| 63 | end |
| 64 | tvpart tvbad tlempty |
| 65 | if slverify |
| 66 | ret 3 |
| 67 | end |
| 68 | tvpart tvdeny tlempty |
| 69 | if not slverify |
| 70 | ret 4 |
| 71 | end |
| 72 | tvpart tvloop tlempty |
| 73 | if slverify |
| 74 | ret 5 |
| 75 | end |
| 76 | tvpart tvexit tlempty |
| 77 | if slverify |
| 78 | ret 6 |
| 79 | end |
| 80 | r = write 1 tvpass 0 len tvpass |
| 81 | ret 0 |
| 82 | end |