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-test.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Dispatcher checks: valid performed, duplicate, in-flight, unknown, limit, revocation and stale. |
| 3 | global checks ulong 1 |
| 4 | global fails ulong 1 |
| 5 | global report uchar 64 |
| 6 | text title "dispatch checks=" |
| 7 | text bd "build" |
| 8 | text dir "build/authority-store" |
| 9 | fn check got ulong want ulong to void |
| 10 | put checks 0 add get checks 0 1 |
| 11 | if ne got want |
| 12 | put fails 0 add get fails 0 1 |
| 13 | end |
| 14 | end |
| 15 | fn plan r edit ulong 32 to void |
| 16 | for i ulong 32 |
| 17 | put r i 0 |
| 18 | end |
| 19 | put r 0 1 |
| 20 | put r 1 1 |
| 21 | put r 3 3 |
| 22 | put r 4 1 |
| 23 | put r 5 9 |
| 24 | put r 6 100 |
| 25 | for i ulong 24 |
| 26 | put r add i 8 add i 100 |
| 27 | end |
| 28 | end |
| 29 | fn context c edit ulong 32 to void |
| 30 | for i ulong 32 |
| 31 | put c i 0 |
| 32 | end |
| 33 | put c 0 1 |
| 34 | put c 1 1 |
| 35 | put c 2 50 |
| 36 | put c 4 1 |
| 37 | put c 5 9 |
| 38 | for i ulong 24 |
| 39 | put c add i 8 add i 100 |
| 40 | end |
| 41 | end |
| 42 | fn summary to int |
| 43 | for i ulong len title |
| 44 | put report i get title i |
| 45 | end |
| 46 | n = get checks 0 |
| 47 | at = len title |
| 48 | put report at uchar add 48 div n 100 |
| 49 | put report add at 1 uchar add 48 rem div n 10 10 |
| 50 | put report add at 2 uchar add 48 rem n 10 |
| 51 | put report add at 3 32 |
| 52 | put report add at 4 uchar add 48 div get fails 0 100 |
| 53 | put report add at 5 uchar add 48 rem div get fails 0 10 10 |
| 54 | put report add at 6 uchar add 48 rem get fails 0 10 |
| 55 | put report add at 7 10 |
| 56 | w = write 1 report 0 add at 8 |
| 57 | if ne w long add at 8 |
| 58 | ret 2 |
| 59 | end |
| 60 | if ne get fails 0 0 |
| 61 | ret 1 |
| 62 | end |
| 63 | ret 0 |
| 64 | end |
| 65 | fn main to int |
| 66 | put dpid 0 ulong getpid |
| 67 | lk = lrel |
| 68 | mk = makedir bd 0 len bd 448 |
| 69 | if or eq mk 0 eq mk -17 |
| 70 | else |
| 71 | ret 90 |
| 72 | end |
| 73 | if ne makedir dir 0 len dir 448 0 |
| 74 | put sb 0 0 |
| 75 | end |
| 76 | r = new ulong 32 0 |
| 77 | c = new ulong 32 0 |
| 78 | plan r |
| 79 | context c |
| 80 | check writegen 1 0 |
| 81 | check writerec r 0 |
| 82 | check dispatch r c 48 0 |
| 83 | check readrec r 0 |
| 84 | check get r 1 4 |
| 85 | check get r 2 1 |
| 86 | check dispatch r c 48 22 |
| 87 | plan r |
| 88 | check writegen 1 0 |
| 89 | check writerec r 0 |
| 90 | check dispatch r c 51 0 |
| 91 | check readrec r 0 |
| 92 | check get r 1 4 |
| 93 | plan r |
| 94 | check writegen 1 0 |
| 95 | check writerec r 0 |
| 96 | for i ulong len strictp |
| 97 | put dpath i get strictp i |
| 98 | end |
| 99 | put dplen 0 len strictp |
| 100 | check dispatch r c 52 0 |
| 101 | check readrec r 0 |
| 102 | check get r 1 4 |
| 103 | plan r |
| 104 | put r 1 2 |
| 105 | put r 2 1 |
| 106 | check writerec r 0 |
| 107 | check dispatch r c 48 20 |
| 108 | plan r |
| 109 | put r 1 3 |
| 110 | put r 2 1 |
| 111 | check writerec r 0 |
| 112 | check dispatch r c 48 21 |
| 113 | plan r |
| 114 | put r 3 1 |
| 115 | put r 2 1 |
| 116 | check writerec r 0 |
| 117 | check dispatch r c 48 23 |
| 118 | plan r |
| 119 | check writegen 1 0 |
| 120 | check writerec r 0 |
| 121 | check dispatch r c 49 60 |
| 122 | check readrec r 0 |
| 123 | check get r 1 3 |
| 124 | check readgen 2 |
| 125 | check writegen 2 0 |
| 126 | plan r |
| 127 | check writerec r 0 |
| 128 | check dispatch r c 48 52 |
| 129 | plan r |
| 130 | put r 1 2 |
| 131 | put r 2 1 |
| 132 | check writerec r 0 |
| 133 | err = actlost r |
| 134 | check err 0 |
| 135 | check writerec r 0 |
| 136 | check readrec r 0 |
| 137 | check get r 1 3 |
| 138 | ret summary |
| 139 | end |