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 / node / transport-test.om

284 lines · 5408 bytes Raw Blame History
1note Concatenate after transport.om. CPU-only process and transport acceptance.
2text nok "PASS node transport\n"
3global nh long 1
4global nf int 6
5global np long 2
6global ns uchar 4
7
8fn node_check ok bool code int to void
9if not ok
10exit code
11end
12end
13
14fn node_refusals to void
15src = new uchar 4096 42
16dst = new uchar 4096 99
17h = node_new
18node_check gt h 0 10
19node_check eq node_next h 0 1 0 11
20node_check eq node_next h 1 1 neg long 5 12
21node_check eq node_read h 1 dst neg long 7 13
22node_check eq get dst 0 99 14
23node_check eq node_publish h 1 src 4097 neg long 3 15
24node_check eq node_publish h 0 src 1 neg long 4 16
25node_check eq mapget h 16 8 0 17
26node_check eq node_publish h 1 src 0 1 18
27node_check eq node_read h 1 dst 0 19
28node_check eq get dst 0 99 20
29node_check eq node_next h 0 2 0 21
30node_check eq node_next h 0 1 1 22
31node_check eq node_read h 0 dst neg long 7 23
32node_check eq node_read h 65 dst neg long 7 24
33node_check eq node_next h 65 1 neg long 7 25
34node_check eq node_next h 0 0 neg long 7 26
35node_check eq node_stop h 0 27
36node_check eq node_publish h 1 src 1 neg long 1 28
37node_check eq mapget h 16 8 1 29
38node_check eq mapdrop h 0 30
39end
40
41fn node_faults to void
42src = new uchar 4096 42
43dst = new uchar 4096 99
44h = node_new
45node_check gt h 0 31
46node_check eq node_publish h 1 src 1 1 32
47r = mapset h 4096 8 9
48node_check eq node_read h 1 dst neg long 5 33
49node_check eq node_next h 0 1 neg long 5 34
50node_check eq get dst 0 99 35
51r = mapset h 4096 8 1
52r = mapset h 4104 8 4097
53node_check eq node_read h 1 dst neg long 5 36
54r = mapset h 16 8 65
55node_check eq node_read h 1 dst neg long 5 37
56node_check eq node_next h 0 1 neg long 5 38
57r = mapset h 0 8 0
58node_check eq node_read h 1 dst neg long 5 39
59node_check eq node_publish h 1 src 1 neg long 5 40
60node_check eq node_stop h neg long 5 41
61node_check eq mapdrop h 0 42
62end
63
64fn node_wait_checks to void
65h = node_new
66node_check gt h 0 43
67w = eventfd uint 0
68s = eventfd uint 0
69node_check ge w 0 44
70node_check ge s 0 45
71node_check eq node_wait h int w int s 0 0 46
72node_check eq node_wait h int w int w 0 neg long 22 47
73node_check eq node_wait h neg int 1 int s 0 neg long 9 48
74node_check eq node_notify int w 0 49
75node_check eq node_notify int w 0 50
76node_check eq node_wait h int w int s 0 1 51
77node_check eq node_wait h int w int s 0 0 52
78node_check eq node_notify int s 0 53
79node_check eq node_notify int w 0 54
80node_check eq node_wait h int w int s 0 2 55
81node_check eq node_stop h 0 56
82node_check eq node_wait h int w int s 0 2 57
83node_check eq fclose int w 0 58
84node_check eq fclose int s 0 59
85node_check eq node_notify int w neg long 9 60
86node_check eq mapdrop h 0 61
87end
88
89fn node_worker idx ulong to int
90buf = new uchar 4096 0
91h = get nh 0
92if ne node_publish h 1 buf 1 neg long 6
93ret 70
94end
95if ne node_stop h neg long 6
96ret 71
97end
98cursor = ulong 0
99count = ulong 0
100topic = add idx 1
101r = node_wait h get nf idx get nf add idx 2 5000000000
102if ne r 1
103ret 72
104end
105note A single wake must let each worker discover every matching version.
106for k ulong 64
107v = node_next h cursor topic
108if eq v 0
109break
110end
111if lt v 0
112ret 73
113end
114cursor = ulong v
115if ne node_read h cursor buf 4096
116ret 74
117end
118for j ulong 4096
119if ne get buf j uchar cursor
120ret 75
121end
122end
123count = add count 1
124end
125if ne count 32
126ret 76
127end
128if ne node_notify get nf add idx 4 0
129ret 77
130end
131note Parent signals stop only after both independent acknowledgements.
132while true bound 64
133r = node_wait h get nf idx get nf add idx 2 5000000000
134if eq r 2
135ret 0
136end
137if ne r 1
138ret 78
139end
140end
141ret 79
142end
143
144fn node_publish_batch to bool
145buf = new uchar 4096 0
146h = get nh 0
147for k ulong 64
148v = add k 1
149for j ulong 4096
150put buf j uchar v
151end
152if ne node_publish h add rem v 2 1 buf 4096 long v
153ret false
154end
155end
156if ne node_publish h 1 buf 1 neg long 2
157ret false
158end
159if ne mapget h 16 8 64
160ret false
161end
162note The first version still has its original bytes after arena exhaustion.
163if ne node_read h 1 buf 4096
164ret false
165end
166for j ulong 4096
167if ne get buf j 1
168ret false
169end
170end
171ret true
172end
173
174fn node_processes to int
175put nh 0 node_new
176if le get nh 0 0
177ret 80
178end
179for i ulong 6
180put nf i neg int 1
181end
182result = int 0
183for i ulong 6
184fd = eventfd uint 0
185if lt fd 0
186result = 81
187break
188end
189put nf i int fd
190end
191if eq result 0
192for i ulong 2
193pid = fork
194if eq pid 0
195exit node_worker i
196end
197if lt pid 0
198result = 82
199break
200end
201put np i pid
202end
203end
204if eq result 0
205if not node_publish_batch
206result = 83
207end
208end
209if eq result 0
210for i ulong 2
211if ne node_notify get nf i 0
212result = 84
213end
214end
215end
216if eq result 0
217for i ulong 2
218r = waitio get nf add i 4 1 5000000000
219if ne r 1
220result = 85
221end
222end
223end
224if eq node_stop get nh 0 0
225for i ulong 2
226if ge get nf add i 2 0
227r = node_notify get nf add i 2
228end
229end
230else
231result = 86
232end
233for i ulong 2
234if gt get np i 0
235note Bounded nonblocking reap, then SIGKILL the exact child if still live.
236done = false
237for j ulong 100
238r = waitpid int get np i ns 0 4 1
239if eq r get np i
240done = true
241if or ne get ns 0 0 ne get ns 1 0
242result = 87
243end
244break
245end
246if ne r 0
247result = 88
248break
249end
250r = sleepns 10000000
251end
252if not done
253r = killpid int get np i 9
254r = waitpid int get np i ns 0 4 0
255result = 89
256end
257end
258end
259for i ulong 6
260if ge get nf i 0
261if ne fclose get nf i 0
262result = 90
263end
264end
265end
266if ne mapdrop get nh 0 0
267result = 91
268end
269ret result
270end
271
272fn main to int
273node_refusals
274node_faults
275node_wait_checks
276r = node_processes
277if ne r 0
278ret r
279end
280if ne write 1 nok 0 len nok long len nok
281ret 92
282end
283ret 0
284end