interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / omega / allen / tests / application.om

346 lines · 6940 bytes Raw Blame History
1note End-to-end application core over real Omega protocol bytes; no socket simulation claim.
2text Smallask "hello"
3text Codeaskt "Please make me a calculator"
4text Finaltxt " 1/1 Model answer."
5text Codetxt " 1/1 9 3ce11e06 python print(1)\\n"
6text Prefixes "SAY WAIT CODE "
7text Againexp "AGAIN 2"
8global SavedOut uchar 8192
9global Heldwire uchar 8192
10global Heldlen ulong 2
11fn holdwire to void
12put Heldlen 0 get Outlen 0
13put Heldlen 1 get Err 0
14for i ulong get Outlen 0
15put Heldwire i get Outb i
16end
17end
18fn unhold to void
19for i ulong get Heldlen 0
20put Outb i get Heldwire i
21end
22put Outlen 0 get Heldlen 0
23put Err 0 get Heldlen 1
24end
25fn samewire to bool
26if ne get Outlen 0 get Heldlen 0
27ret false
28end
29for i ulong get Heldlen 0
30if ne get Outb i get Heldwire i
31ret false
32end
33end
34ret eq get Err 0 get Heldlen 1
35end
36fn test ok bool to void
37n = get Outlen 0
38e = get Err 0
39for i ulong n
40put SavedOut i get Outb i
41end
42check ok add get Checks 0 1
43for i ulong n
44put Outb i get SavedOut i
45end
46put Outlen 0 n
47put Err 0 e
48end
49fn copyout to void
50put Inlen 0 get Outlen 0
51for i ulong get Outlen 0
52put In i get Outb i
53end
54end
55fn prompt code bool to void
56if code
57put Inlen 0 len Codeaskt
58for i ulong len Codeaskt
59put In i get Codeaskt i
60end
61else
62put Inlen 0 len Smallask
63for i ulong len Smallask
64put In i get Smallask i
65end
66end
67end
68fn incoming part ulong seq ulong kind ulong to void
69outreset
70off = ulong 0
71size = ulong 4
72if eq kind 1
73off = ulong 4
74size = ulong 5
75end
76if eq kind 2
77off = ulong 9
78size = ulong 5
79end
80for i ulong size
81emitb get Prefixes add off i
82end
83emitn seq
84if eq kind 0
85for i ulong len Finaltxt
86emitb get Finaltxt i
87end
88end
89if eq kind 2
90for i ulong len Codetxt
91emitb get Codetxt i
92end
93end
94copyout
95b = packet 2 get Q 1 part 0 0
96copyout
97end
98fn main to int
99test not appinit 0 100
100test appinit 42 100
101test not appinit 43 100
102test eq get Q 0 42
103prompt false
104test appask 100
105test eq get R 0 1
106test eq get Q 1 1
107test eq get R 9 1
108test eq get R 1 1
109test eq get A 2 0
110prompt false
111test not appask 101
112test eq get R 9 1
113test apppoll 100 true
114test eq get T 10 5
115test appsent 100 true
116test apppoll 100 true
117test eq get T 10 1
118copyout
119test pkparse
120test eq get N 1 1
121test eq get In get N 5 74
122test appsent 100 true
123incoming 1 1 0
124test appreceive 101
125test eq get A 2 1
126test eq get R 1 0
127test eq get R 8 13
128test eq get R 9 2
129test eq get Answer 0 77
130prompt true
131test not appask 102
132test eq get R 0 1
133test apppoll 102 true
134test eq get T 10 3
135test appsent 102 true
136note Code acknowledgement is visible immediately, but missing code requests AGAIN.
137prompt true
138test appask 103
139test eq get R 0 2
140test eq get Q 1 2
141test eq get R 2 2
142test eq get A 2 1
143test eq get R 8 len Ack
144test apppoll 103 true
145test appsent 103 false
146test apppoll 104 true
147test eq get T 10 1
148test appsent 104 true
149incoming 1 2 0
150test appreceive 105
151test eq get A 2 2
152test eq get A 1 len Againexp
153test eq get R 1 1
154test eq get R 13 1
155test apppoll 105 true
156test eq get T 10 3
157test eq get Q 1 2
158test appsent 105 true
159test apppoll 106 true
160test eq get T 10 1
161test eq get Q 1 3
162test eq get R 0 2
163copyout
164test pkparse
165test eq get N 6 len Againexp
166bad = ulong 0
167for i ulong len Againexp
168if ne get In add get N 5 i get Againexp i
169bad = add bad 1
170end
171end
172test eq bad 0
173test appsent 106 true
174incoming 1 2 0
175test appreceive 107
176test eq get A 2 3
177test eq get R 1 0
178test eq get A 1 0
179note Reset cancels pending delivery without reusing either counter.
180appreset
181test eq get R 0 2
182test eq get Q 1 3
183test eq get R 9 0
184prompt false
185test appask 108
186test eq get R 0 3
187test eq get Q 1 4
188test apppoll 108 true
189test appsent 108 true
190note Old CODE must not mutate the code buffer during a newer chat job.
191incoming 1 2 2
192test appreceive 109
193test eq get A 2 4
194test eq get C 1 0
195test eq get C 2 0
196test eq get Code 0 0
197test apppoll 109 true
198test appsent 109 true
199incoming 2 2 0
200test appreceive 109
201test eq get A 2 4
202test eq get R 1 1
203test eq get R 8 0
204test apppoll 109 true
205test appsent 109 true
206incoming 3 3 0
207test appreceive 110
208test eq get A 2 1
209test eq get R 1 0
210test eq get R 9 2
211test apppoll 110 true
212test appsent 110 true
213note Cancellation drops an outstanding send and stale response safely.
214prompt false
215test appask 111
216test apppoll 111 true
217appcancel
218test eq get R 1 0
219test eq get T 5 0
220test not appsent 111 true
221incoming 1 4 0
222test not appreceive 112
223note Complete CODE bytes must arrive before a code response becomes visible.
224prompt true
225test appask 113
226test eq get R 0 5
227test eq get Q 1 6
228test apppoll 113 true
229test appsent 113 true
230incoming 1 5 2
231test appreceive 114
232test eq get A 2 0
233test eq codestat 2
234test eq get R 6 0
235test apppoll 114 true
236test appsent 114 true
237incoming 2 5 0
238test appreceive 115
239test eq get A 2 1
240test eq get R 6 1
241test eq get R 1 0
242test eq get Code 6 49
243test apppoll 115 true
244test appsent 115 true
245note WAIT updates silence deadline, no answer; slow and timeout cancel both layers.
246prompt false
247test appask 116
248test eq get R 0 6
249test apppoll 116 true
250test appsent 116 true
251incoming 1 6 1
252test appreceive 117
253test eq get A 2 0
254test eq get R 4 117
255test apppoll 117 true
256test appsent 117 true
257v = apppoll 20116 true
258test eq get A 2 5
259test eq get R 1 1
260if v
261test appsent 20116 true
262end
263v = apppoll 30116 true
264test eq get R 1 1
265if v
266test appsent 30116 true
267end
268v = apppoll 30117 true
269test eq get A 2 6
270test eq get R 1 0
271test eq get T 5 0
272test eq get A 1 0
273if v
274test appsent 30117 true
275end
276n = get R 9
277prompt false
278test not appask 30116
279test eq get R 9 n
280test not apppoll 30116 true
281note Invalid prompt never becomes a pending job or transcript line.
282put Inlen 0 160
283test not appask 30118
284test eq get R 9 n
285test eq get R 0 6
286test eq get Q 1 7
287note Receiving a code completion before send-result reporting cannot replace
288note the pending datagram with the newly generated AGAIN text.
289prompt true
290test appask 30118
291test apppoll 30118 true
292test eq get T 10 1
293holdwire
294incoming 1 7 0
295unhold
296test appreceive 30119
297test eq get A 2 2
298test samewire
299test eq get T 10 1
300test appsent 30119 true
301test apppoll 30120 true
302test eq get T 10 3
303test appsent 30120 true
304test apppoll 30121 true
305test eq get Q 1 9
306test eq get R 0 7
307test appsent 30121 true
308appcancel
309note Idle runtime still refuses a new prompt while a HELLO send is outstanding.
310test apppoll 32122 true
311test eq get T 10 5
312holdwire
313n = get R 9
314prompt false
315test not appask 32122
316test samewire
317test eq get R 9 n
318test appsent 32122 true
319note Late CODE may complete the original job before queued AGAIN is sent.
320prompt true
321test appask 32123
322test eq get R 0 8
323test eq get Q 1 10
324test apppoll 32123 true
325test appsent 32123 true
326incoming 1 8 0
327test appreceive 32124
328test gt get A 1 0
329test apppoll 32124 true
330test appsent 32124 true
331incoming 2 8 2
332test appreceive 32125
333test eq codestat 2
334test apppoll 32125 true
335test appsent 32125 true
336incoming 3 8 0
337test appreceive 32126
338test eq get A 2 1
339test eq get R 1 0
340test eq get A 1 0
341test apppoll 32126 true
342test appsent 32126 true
343test not apppoll 32127 true
344test eq get Q 1 10
345ret int get Fails 0
346end