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 / authority / dispatch-fault-test.om

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