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 / host / aien-ioctl.om

705 lines · 12361 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note CPU-only qualification: compiler, qemu-x86_64 oracle, fresh scratch directory.
3note All ioctl executions use fd -1; no device is opened. Compiler/runtime are seeded Omega.
4note Process packets, bounded child waits and exclusive artifacts follow qualification/om2/gate.om.
5text matrix "seed/host/aien-ioctl.cases"
6text omcsrc "seed/omc/omc.om"
7text nullpath "/dev/null"
8text pieces "target x86linux\n|global b uchar 4096\nfn main to int\nr = devctl neg int 1 uint | b 0 |\nif ne r neg long 9\nret 1\nend\nret 0\nend\n|om2\nexport fn ctl fd long to long\nb = new uchar 4096 0\nret devctl int fd uint |\nend\n|global b uchar 4096\nfn call request uint to long\nret devctl neg int 1 request b 0 112\nend\nfn main to int\nret int call uint 2154840336\nend\n|om2\nexport fn ctl fd long request uint to long\nb = new uchar 4096 0\nret devctl int fd request b 0 112\nend\n|/|case-|.src|.elf|.cerr|.out|.err|.compiler|.mutant|error 9\n|AIEN-IOCTL FAIL |AIEN-IOCTL PASS native, x86-QEMU, function admissions, encoded/runtime refusals; four mutants killed; chip NOT_RUN\n|AIEN-IOCTL mutant killed |AIEN-IOCTL mutant survived |AIEN-IOCTL baseline\n|\nif ne r neg long 25\nret 1\nend\nret 0\nend\n|AIEN-IOCTL unexpected mutant failure |arch/span/phase/observed:\n|"
9text mfrom "ok = or ok eq q 3222815012\nif not ok|eq q 2154840336|put a_ar add get a_rb 77 add x 23 xhreq 166 x\ne = harray x 1\nt = alloc\nmatconst t get a_ar add get a_rb 77 add x 23\ne3 3942645760 31 get a_ar add get a_rb 77 add x 22 t\ntrapc 1 3|xhs 2 get a_ar add get a_rb 77 add x 22\nxhcmp 2 get a_ar add get a_rb 77 add x 23\nxtrap 1 3\nxha x 4 7|"
10text mto "ok = or ok eq q 3222815012\nif false|eq q 2154840337|put a_ar add get a_rb 77 add x 23 xhreq 166 x\ne = harray x 1\nt = alloc\nmatconst t get a_ar add get a_rb 77 add x 23\ne3 3942645760 31 get a_ar add get a_rb 77 add x 22 t|xhs 2 get a_ar add get a_rb 77 add x 22\nxhcmp 2 get a_ar add get a_rb 77 add x 23\nxha x 4 7|"
11global cc uchar 4096
12global cn ulong 1
13global pinned uchar 4096
14global pinlen ulong 1
15global qemu uchar 4096
16global qn ulong 1
17global scratch uchar 4096
18global sn ulong 1
19global path uchar 8192
20global pn ulong 1
21global packet uchar 16384
22global packetn ulong 2
23global status uchar 4
24global data uchar 65536
25global dn ulong 1
26global fields ulong 14
27global fieldn ulong 1
28global row ulong 2
29global src uchar 16777216
30global srcn ulong 1
31global compiler uchar 16777216
32global omclen ulong 1
33global tmp uchar 65536
34global nums uchar 24
35global number ulong 1
36global cut ulong 2
37global serial ulong 1
38global current ulong 1
39global curarch ulong 1
40global curspan ulong 1
41global why ulong 1
42global actual long 1
43global mutating ulong 1
44text loud "AIEN-IOCTL INVALID mutant anchor must occur exactly once in seed/omc/omc.om (mutant not applied; not a compiler verdict); respell mfrom/mto with the compiler change. mutant/count:\n|AIEN-IOCTL INVALID cannot create fresh scratch directory (it must not exist): |\n|AIEN-IOCTL expected mutant failure |AIEN-IOCTL INVALID mutated compiler did not build; mutant/status:\n|"
45fn shout id ulong to void
46s = ulong 0
47k = ulong 1
48for i ulong len loud
49if eq get loud i 124
50if eq k id
51r = write 1 loud s sub i s
52ret
53end
54s = add i 1
55k = add k 1
56end
57end
58exit 91
59end
60fn part id ulong to void
61s = ulong 0
62k = ulong 1
63for i ulong len pieces
64if eq get pieces i 124
65if eq k id
66put cut 0 s
67put cut 1 sub i s
68ret
69end
70s = add i 1
71k = add k 1
72end
73end
74exit 91
75end
76fn say id ulong to void
77part id
78r = write 1 pieces get cut 0 get cut 1
79end
80fn digits v ulong to void
81n = ulong 0
82while ge v 10
83put nums n uchar add 48 rem v 10
84n = add n 1
85v = div v 10
86end
87put nums n uchar add 48 v
88put number 0 add n 1
89end
90fn show v ulong to void
91digits v
92for i ulong get number 0
93r = write 1 nums sub sub get number 0 i 1 1
94end
95put nums 0 10
96r = write 1 nums 0 1
97end
98fn pathpart id ulong to void
99part id
100s = get cut 0
101n = get cut 1
102p = get pn 0
103for i ulong n
104put path add p i get pieces add s i
105end
106put pn 0 add p n
107end
108fn casepath suffix ulong to void
109put pn 0 get sn 0
110for i ulong get sn 0
111put path i get scratch i
112end
113pathpart 9
114pathpart 10
115digits get current 0
116n = get number 0
117p = get pn 0
118for i ulong n
119put path add p i get nums sub sub n i 1
120end
121put pn 0 add p n
122pathpart suffix
123end
124fn openpath flags int to int
125ret int fopen path 0 get pn 0 flags 448
126end
127fn writeall fd int n ulong to bool
128p = ulong 0
129while lt p n
130r = write fd src p sub n p
131if le r 0
132ret false
133end
134p = add p ulong r
135end
136ret true
137end
138fn packetclear to void
139put packetn 0 2
140put packetn 1 0
141end
142fn packetpath to void
143n = get pn 0
144p = get packetn 0
145if gt add add p 2 n len packet
146exit 91
147end
148put packet p uchar n
149put packet add p 1 uchar shr n 8
150for i ulong n
151put packet add add p 2 i get path i
152end
153put packetn 0 add add p 2 n
154put packetn 1 add get packetn 1 1
155end
156fn redir fd int target int to void
157if ne dupfd fd target 0 long target
158exit 127
159end
160end
161fn spawn fi int fo int fe int to long
162put packet 0 uchar get packetn 1
163put packet 1 uchar shr get packetn 1 8
164pid = fork
165if lt pid 0
166exit 91
167end
168if eq pid 0
169redir fi 0
170redir fo 1
171redir fe 2
172r = execprog packet 0 get packetn 0
173exit 127
174end
175r = fclose fi
176r = fclose fo
177r = fclose fe
178start = monons
179while true
180r = waitpid int pid status 0 4 1
181if eq r pid
182if ne get status 0 0
183ret -1
184end
185ret long get status 1
186end
187if lt r 0
188exit 91
189end
190if gt sub monons start 30000000000
191r = killpid int pid 9
192r = waitpid int pid status 0 4 0
193exit 91
194end
195r = sleepns 1000000
196end
197ret -1
198end
199fn compile to long
200packetclear
201put pn 0 get cn 0
202for i ulong get cn 0
203put path i get cc i
204end
205packetpath
206casepath 11
207fi = openpath 524288
208casepath 12
209fo = openpath 524481
210casepath 13
211fe = openpath 524481
212if or or lt fi 0 lt fo 0 lt fe 0
213exit 91
214end
215r = spawn fi fo fe
216put actual 0 r
217ret r
218end
219fn readartifact suffix ulong to long
220casepath suffix
221fd = openpath 524288
222if lt fd 0
223exit 91
224end
225n = read fd tmp 0 len tmp
226r = fclose fd
227ret n
228end
229fn refuse to bool
230put why 0 4
231if ne compile 9
232ret false
233end
234if ne readartifact 12 0
235ret false
236end
237n = readartifact 13
238if lt n 8
239ret false
240end
241part 18
242s = get cut 0
243m = get cut 1
244for i ulong add sub ulong n m 1
245ok = true
246for j ulong m
247a = get tmp add i j
248b = get pieces add s j
249if ne a b
250ok = false
251end
252end
253if ok
254ret true
255end
256end
257ret false
258end
259fn run arch ulong expected long to bool
260put why 0 1
261if ne compile 0
262ret false
263end
264put why 0 3
265n = readartifact 12
266if lt n 4
267ret false
268end
269if or ne get tmp 0 127 ne get tmp 1 69
270ret false
271end
272if or ne get tmp 2 76 ne get tmp 3 70
273ret false
274end
275casepath 12
276fd = openpath 524288
277if ne fchmod fd 448 0
278exit 91
279end
280r = fclose fd
281packetclear
282if eq arch 1
283put pn 0 get qn 0
284for i ulong get qn 0
285put path i get qemu i
286end
287packetpath
288end
289casepath 12
290packetpath
291fi = int fopen nullpath 0 len nullpath 524288 0
292casepath 14
293fo = openpath 524481
294casepath 15
295fe = openpath 524481
296put why 0 2
297r = spawn fi fo fe
298put actual 0 r
299if ne r expected
300ret false
301end
302put why 0 3
303if ne readartifact 14 0
304ret false
305end
306ret eq readartifact 15 0
307end
308fn addpart id ulong to void
309part id
310s = get cut 0
311n = get cut 1
312p = get srcn 0
313for i ulong n
314put src add p i get pieces add s i
315end
316put srcn 0 add p n
317end
318fn addfield id ulong to void
319s = get fields mul id 2
320n = get fields add mul id 2 1
321p = get srcn 0
322for i ulong n
323put src add p i get data add s i
324end
325put srcn 0 add p n
326end
327fn savecase to void
328put serial 0 add get serial 0 1
329put current 0 get serial 0
330casepath 11
331fd = openpath 524481
332if lt fd 0
333exit 91
334end
335ok = writeall fd get srcn 0
336r = fclose fd
337if not ok
338exit 91
339end
340end
341fn fixture arch ulong span ulong dynamic bool to void
342put srcn 0 0
343put curarch 0 arch
344put curspan 0 span
345if eq arch 1
346addpart 1
347end
348if dynamic
349if eq arch 2
350addpart 8
351else
352addpart 7
353end
354else
355if eq arch 2
356addpart 5
357else
358addpart 2
359end
360addfield 2
361addpart 3
362addfield span
363if eq arch 2
364addpart 6
365else
366if eq arch 1
367addpart 24
368else
369addpart 4
370end
371end
372end
373savecase
374end
375fn nextrow to bool
376p = get row 0
377while lt p get dn 0
378s = p
379while and lt p get dn 0 ne get data p 10
380p = add p 1
381end
382put row 1 s
383put row 0 add p 1
384if and lt s p ne get data s 35
385k = ulong 0
386while lt s p
387while and lt s p eq get data s 32
388s = add s 1
389end
390if lt s p
391e = s
392while and lt e p ne get data e 32
393e = add e 1
394end
395if ge k 7
396exit 91
397end
398put fields mul k 2 s
399put fields add mul k 2 1 sub e s
400k = add k 1
401s = e
402end
403end
404put fieldn 0 k
405ret true
406end
407p = add p 1
408end
409ret false
410end
411fn failcase to bool
412if ne get mutating 0 0
413shout 4
414else
415say 19
416end
417show get current 0
418say 26
419show get curarch 0
420show get curspan 0
421show get why 0
422if ge get actual 0 0
423show ulong get actual 0
424else
425show 999
426end
427ret false
428end
429fn qualify to bool
430put row 0 0
431while nextrow
432allow = eq get data get fields 0 97
433for arch ulong 3
434fixture arch 3 false
435if allow
436if eq arch 2
437put why 0 1
438if ne compile 0
439ret failcase
440end
441if le readartifact 12 0
442ret failcase
443end
444else
445if not run arch 0
446ret failcase
447end
448for mode ulong 2
449fixture arch add mode 4 false
450if not run arch 103
451ret failcase
452end
453end
454end
455else
456if not refuse
457ret failcase
458end
459end
460end
461end
462for arch ulong 3
463fixture arch 3 true
464if not refuse
465ret failcase
466end
467end
468ret true
469end
470fn matchmut at ulong o ulong n ulong to bool
471for j ulong n
472a = get compiler add at j
473b = get mfrom add o j
474if ne a b
475ret false
476end
477end
478ret true
479end
480fn selectold which ulong to void
481s = ulong 0
482k = ulong 0
483for i ulong len mfrom
484if eq get mfrom i 124
485if eq k which
486put cut 0 s
487put cut 1 sub i s
488end
489s = add i 1
490k = add k 1
491end
492end
493end
494fn anchors to ulong
495count = ulong 0
496o = get cut 0
497n = get cut 1
498for i ulong add sub get omclen 0 n 1
499if matchmut i o n
500count = add count 1
501end
502end
503ret count
504end
505fn locate which ulong to ulong
506at = ulong 0
507count = ulong 0
508o = get cut 0
509n = get cut 1
510for i ulong add sub get omclen 0 n 1
511if matchmut i o n
512at = i
513count = add count 1
514end
515end
516if ne count 1
517shout 1
518show which
519show count
520exit 92
521end
522ret at
523end
524fn copycc start ulong n ulong to void
525p = get srcn 0
526for i ulong n
527put src add p i get compiler add start i
528end
529put srcn 0 add p n
530end
531fn appendnew which ulong to void
532s = ulong 0
533k = ulong 0
534for i ulong len mto
535if eq get mto i 124
536if eq k which
537p = get srcn 0
538for j ulong sub i s
539put src add p j get mto add s j
540end
541put srcn 0 add p sub i s
542end
543s = add i 1
544k = add k 1
545end
546end
547end
548fn mutate which ulong to void
549selectold which
550at = locate which
551oldend = add at get cut 1
552put srcn 0 0
553copycc 0 at
554appendnew which
555copycc oldend sub get omclen 0 oldend
556savecase
557if ne compile 0
558shout 5
559show which
560if ge get actual 0 0
561show ulong get actual 0
562else
563show 999
564end
565exit 91
566end
567casepath 12
568fd = openpath 524288
569if ne fchmod fd 448 0
570exit 91
571end
572r = fclose fd
573put cn 0 get pn 0
574for i ulong get pn 0
575put cc i get path i
576end
577end
578note A failed child/compile is never a generic mutant kill. Attribute each intended assertion.
579fn killed m ulong to bool
580if eq m 0
581if ne get why 0 4
582ret false
583end
584if ne get actual 0 0
585ret false
586end
587if ne get curarch 0 0
588ret false
589end
590n = readartifact 12
591if lt n 4
592ret false
593end
594if or ne get tmp 0 127 ne get tmp 1 69
595ret false
596end
597ret and eq get tmp 2 76 eq get tmp 3 70
598end
599if eq m 1
600if ne get why 0 1
601ret false
602end
603ret eq get actual 0 9
604end
605if ne get why 0 2
606ret false
607end
608if ne get actual 0 0
609ret false
610end
611if ne get curspan 0 4
612ret false
613end
614ret eq get curarch 0 sub m 2
615end
616fn main to int
617if ne argcnt 4
618ret 90
619end
620n = argread 1 pinned 0 4095
621if lt n 1
622ret 90
623end
624put pinlen 0 ulong n
625n = argread 2 qemu 0 4095
626if lt n 1
627ret 90
628end
629put qn 0 ulong n
630n = argread 3 scratch 0 4095
631if lt n 1
632ret 90
633end
634put sn 0 ulong n
635if ne makedir scratch 0 ulong n 448 0
636shout 2
637w = write 1 scratch 0 ulong n
638shout 3
639ret 91
640end
641fd = int fopen matrix 0 len matrix 524288 0
642if lt fd 0
643ret 91
644end
645n = read fd data 0 len data
646r = fclose fd
647if or lt n 1 ge ulong n len data
648ret 91
649end
650put dn 0 ulong n
651fd = int fopen omcsrc 0 len omcsrc 524288 0
652if lt fd 0
653ret 91
654end
655n = read fd compiler 0 len compiler
656r = fclose fd
657if or lt n 1 ge ulong n len compiler
658ret 91
659end
660put omclen 0 ulong n
661put cn 0 get pinlen 0
662for i ulong get pinlen 0
663put cc i get pinned i
664end
665bad = false
666for m ulong 4
667selectold m
668c = anchors
669if ne c 1
670shout 1
671show m
672show c
673bad = true
674end
675end
676if bad
677ret 92
678end
679say 23
680if not qualify
681ret 1
682end
683for m ulong 4
684put cn 0 get pinlen 0
685for i ulong get pinlen 0
686put cc i get pinned i
687end
688put mutating 0 1
689mutate m
690if qualify
691say 22
692show m
693ret 1
694end
695if not killed m
696say 25
697show m
698ret 1
699end
700say 21
701show m
702end
703say 20
704ret 0
705end