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 / dispatch-fault-test.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Fault injection for the dispatch failure codes 76..79, not a qualification of the real pid lock. |
| 3 | note Link action.om, store.om, dispatch.om and this file, WITHOUT lock.om. In dispatch.om the lines |
| 4 | note "err = actlost r", "err = actrecon r s" and "err = writerec r" call factlost, factrecon and |
| 5 | note fwriterec instead (dispatch-fault-gate.om is generated that way, see seed/profile/check.om). |
| 6 | note Call 1 of writerec and lrel is the pre-fork commit and release; call 2 is the post-run one. |
| 7 | global wcall ulong 1 |
| 8 | global wfail ulong 1 |
| 9 | global rcall ulong 1 |
| 10 | global rfail ulong 1 |
| 11 | global lostbad ulong 1 |
| 12 | global reconbad ulong 1 |
| 13 | global fails ulong 1 |
| 14 | global fline uchar 32 |
| 15 | text faultdir "build/authority-store" |
| 16 | text faultbld "build" |
| 17 | text failmsg "FAIL dispatch fault case " |
| 18 | text okfault "dispatch fault checks=10 fails=0\n" |
| 19 | fn lacq p ulong tries ulong to ulong |
| 20 | ret 0 |
| 21 | end |
| 22 | fn lrel to ulong |
| 23 | put rcall 0 add get rcall 0 1 |
| 24 | if eq get rcall 0 get rfail 0 |
| 25 | ret 30 |
| 26 | end |
| 27 | ret 0 |
| 28 | end |
| 29 | fn fwriterec r view ulong 32 to ulong |
| 30 | put wcall 0 add get wcall 0 1 |
| 31 | if eq get wcall 0 get wfail 0 |
| 32 | ret 31 |
| 33 | end |
| 34 | ret writerec r |
| 35 | end |
| 36 | fn factlost r edit ulong 32 to ulong |
| 37 | if ne get lostbad 0 0 |
| 38 | ret 20 |
| 39 | end |
| 40 | ret actlost r |
| 41 | end |
| 42 | fn factrecon r edit ulong 32 s view ulong 32 to ulong |
| 43 | if ne get reconbad 0 0 |
| 44 | ret 20 |
| 45 | end |
| 46 | ret actrecon r s |
| 47 | end |
| 48 | fn fsetup r edit ulong 32 c edit ulong 32 to void |
| 49 | put r 0 1 |
| 50 | put r 1 1 |
| 51 | put r 3 3 |
| 52 | put r 4 1 |
| 53 | put r 5 9 |
| 54 | put r 6 100 |
| 55 | put c 0 1 |
| 56 | put c 1 1 |
| 57 | put c 2 50 |
| 58 | put c 4 1 |
| 59 | put c 5 9 |
| 60 | for i ulong 24 |
| 61 | put r add i 8 add i 100 |
| 62 | put c add i 8 add i 100 |
| 63 | end |
| 64 | end |
| 65 | fn fbad id ulong to void |
| 66 | put fails 0 add get fails 0 1 |
| 67 | for i ulong len failmsg |
| 68 | put fline i get failmsg i |
| 69 | end |
| 70 | n = len failmsg |
| 71 | put fline n uchar add 48 id |
| 72 | put fline add n 1 10 |
| 73 | w = write 1 fline 0 add n 2 |
| 74 | if ne w long add n 2 |
| 75 | exit 90 |
| 76 | end |
| 77 | end |
| 78 | fn farm wf ulong rf ulong lb ulong rb ulong to void |
| 79 | put wcall 0 0 |
| 80 | put wfail 0 wf |
| 81 | put rcall 0 0 |
| 82 | put rfail 0 rf |
| 83 | put lostbad 0 lb |
| 84 | put reconbad 0 rb |
| 85 | end |
| 86 | fn fcase id ulong mode uchar want ulong to void |
| 87 | r = new ulong 32 0 |
| 88 | c = new ulong 32 0 |
| 89 | fsetup r c |
| 90 | if ne writegen 1 0 |
| 91 | exit 93 |
| 92 | end |
| 93 | if ne writerec r 0 |
| 94 | exit 94 |
| 95 | end |
| 96 | got = dispatch r c mode |
| 97 | if or ne got want ne get rcall 0 2 |
| 98 | fbad id |
| 99 | end |
| 100 | end |
| 101 | fn main to int |
| 102 | mk = makedir faultbld 0 len faultbld 448 |
| 103 | if not or eq mk 0 eq mk -17 |
| 104 | ret 91 |
| 105 | end |
| 106 | mk = makedir faultdir 0 len faultdir 448 |
| 107 | if not or eq mk 0 eq mk -17 |
| 108 | ret 92 |
| 109 | end |
| 110 | put dpid 0 ulong getpid |
| 111 | note Controls: no fault, normal path (child exits 0) and lost path (child moves the generation). |
| 112 | farm 0 0 0 0 |
| 113 | fcase 0 48 0 |
| 114 | farm 0 0 0 0 |
| 115 | fcase 1 49 60 |
| 116 | note Lost path: actlost error 79, record write error 77, release error 78, earliest error wins. |
| 117 | farm 0 0 1 0 |
| 118 | fcase 2 49 79 |
| 119 | farm 2 0 0 0 |
| 120 | fcase 3 49 77 |
| 121 | farm 0 2 0 0 |
| 122 | fcase 4 49 78 |
| 123 | farm 0 2 1 0 |
| 124 | fcase 5 49 79 |
| 125 | note Reconcile path: actrecon error 76, its record write error 77; normal-path release error 78. |
| 126 | farm 0 0 0 1 |
| 127 | fcase 6 48 76 |
| 128 | farm 2 0 0 1 |
| 129 | fcase 7 48 77 |
| 130 | farm 0 2 0 0 |
| 131 | fcase 8 48 78 |
| 132 | farm 2 0 0 0 |
| 133 | fcase 9 48 77 |
| 134 | if ne get fails 0 0 |
| 135 | ret 1 |
| 136 | end |
| 137 | w = write 1 okfault 0 len okfault |
| 138 | if ne w long len okfault |
| 139 | ret 95 |
| 140 | end |
| 141 | ret 0 |
| 142 | end |