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 / seed / authority / store-cleanup-test.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Handwritten deterministic effect doubles, not a real fd/syscall/durability test. |
| 3 | note Committed gate derivation and manual correspondence checks are in README.md. |
| 4 | note Only the store's five write-side effects are doubled; no shipped shell composer. |
| 5 | note Modes: open error, write error, short write, sync error, close error, success, |
| 6 | note write plus close error, sync plus close error, rename error. Both writers run all modes. |
| 7 | global cmode ulong 1 |
| 8 | global ctrace ulong 1 |
| 9 | global cbad ulong 1 |
| 10 | global cfails ulong 1 |
| 11 | text cleanok "store cleanup cases=18 fails=0\n" |
| 12 | fn cstep step ulong to void |
| 13 | put ctrace 0 add mul get ctrace 0 10 step |
| 14 | end |
| 15 | fn cfd fd int to void |
| 16 | if ne fd 7 |
| 17 | put cbad 0 1 |
| 18 | end |
| 19 | end |
| 20 | fn cfopen off ulong count ulong flags ulong mode ulong to long |
| 21 | cstep 1 |
| 22 | if eq get cmode 0 0 |
| 23 | ret -1 |
| 24 | end |
| 25 | ret 7 |
| 26 | end |
| 27 | fn cwrite fd int off ulong count ulong to long |
| 28 | cfd fd |
| 29 | cstep 2 |
| 30 | if or eq get cmode 0 1 eq get cmode 0 6 |
| 31 | ret -1 |
| 32 | end |
| 33 | if eq get cmode 0 2 |
| 34 | ret long sub count 1 |
| 35 | end |
| 36 | ret long count |
| 37 | end |
| 38 | fn cfsync fd int to long |
| 39 | cfd fd |
| 40 | cstep 3 |
| 41 | if or eq get cmode 0 3 eq get cmode 0 7 |
| 42 | ret -1 |
| 43 | end |
| 44 | ret 0 |
| 45 | end |
| 46 | fn cfclose fd int to long |
| 47 | cfd fd |
| 48 | cstep 4 |
| 49 | if or eq get cmode 0 4 or eq get cmode 0 6 eq get cmode 0 7 |
| 50 | ret -1 |
| 51 | end |
| 52 | ret 0 |
| 53 | end |
| 54 | fn crenames off ulong count ulong flags ulong to long |
| 55 | cstep 5 |
| 56 | if eq get cmode 0 8 |
| 57 | ret -1 |
| 58 | end |
| 59 | ret 0 |
| 60 | end |
| 61 | fn cbadcase result ulong want ulong trace ulong to bool |
| 62 | ret or ne result want or ne get ctrace 0 trace ne get cbad 0 0 |
| 63 | end |
| 64 | fn main to int |
| 65 | r = new ulong 32 0 |
| 66 | for writer ulong 2 |
| 67 | for mode ulong 9 |
| 68 | put cmode 0 mode |
| 69 | put ctrace 0 0 |
| 70 | put cbad 0 0 |
| 71 | result = ulong 0 |
| 72 | base = ulong 10 |
| 73 | trace = ulong 12345 |
| 74 | if eq writer 0 |
| 75 | result = writerec r |
| 76 | else |
| 77 | base = 40 |
| 78 | trace = 1234 |
| 79 | result = writegen 1 |
| 80 | end |
| 81 | want = ulong 0 |
| 82 | if eq mode 0 |
| 83 | want = base |
| 84 | trace = 1 |
| 85 | end |
| 86 | if or eq mode 1 or eq mode 2 eq mode 6 |
| 87 | want = add base 1 |
| 88 | trace = 124 |
| 89 | end |
| 90 | if or eq mode 3 eq mode 7 |
| 91 | want = add base 2 |
| 92 | trace = 1234 |
| 93 | end |
| 94 | if eq mode 4 |
| 95 | want = add base 3 |
| 96 | trace = 1234 |
| 97 | end |
| 98 | if and eq mode 8 eq writer 0 |
| 99 | want = 14 |
| 100 | end |
| 101 | if cbadcase result want trace |
| 102 | put cfails 0 add get cfails 0 1 |
| 103 | end |
| 104 | end |
| 105 | end |
| 106 | if ne get cfails 0 0 |
| 107 | ret 1 |
| 108 | end |
| 109 | w = write 1 cleanok 0 len cleanok |
| 110 | if ne w long len cleanok |
| 111 | ret 2 |
| 112 | end |
| 113 | ret 0 |
| 114 | end |