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 / bridge / omega-bridge / tests / native / x86 / check_receipt_test.om

964 lines · 18024 bytes Raw Blame History
1om2
2note check_receipt_test.om: the gate for tests/native/x86/check_physical_receipt.om (DRA-104).
3note usage: check_receipt_test OMC WORKDIR, run from the repository root. OMC must be the seeded omc
4note (omega-mv e5b32567, sha256 2c824805...); WORKDIR is an empty scratch directory this program fills.
5note It compiles the checker with OMC, then runs it on every committed fixture and compares the whole
6note output with tests/native/x86/receipt-fixtures/expected/NAME.out, which the replaced Python checker
7note (git 6d5c0ddb, ORACLE, not shipped) produced; then runs the cases that need a scratch copy (one log
8note byte appended, renamed receipt, missing receipt, argument counts) by exit status and one line.
9note Negative controls: two mutants of the checker (the log sha256 comparison always passing, the
10note EMULATED scan switched off) are compiled and must each fail at least one case.
11note Output: CHECK-RECEIPT-TEST PASS (exit 0) or FAIL lines and CHECK-RECEIPT-TEST FAIL (exit 1);
12note a wrong compiler hash exits 65, a usage or setup error exits 2.
13global fbuf uchar 4194304
14global hexo uchar 64
15global eb uchar 1048576
16global ob uchar 1048576
17global pk uchar 4096
18global wd uchar 4096
19global omc uchar 4096
20global pa uchar 4096
21global pb uchar 4096
22global cb uchar 4096
23global gv ulong 16
24const WDN ulong 0
25const OMN ulong 1
26const PKN ulong 2
27const PAN ulong 3
28const PBN ulong 4
29const BAD ulong 5
30const CAUGHT ulong 6
31const CASES ulong 7
32const FCAP ulong 4194304
33const CBN ulong 8
34const MUT ulong 9
35const ON ulong 10
36note SHA-256 (FIPS 180-4) of fbuf[0..n), digest as 64 lowercase hex bytes in hexo[0..64).
37note The schedule, round and padding code is copied from omega-mv e5b32567 om/sha256/sha256-om2.om
38note (Apache-2.0), changed only to read the message from the global fbuf instead of an unsized view.
39fn kinit k edit uint 64 to void
40put k 0 0x428a2f98
41put k 1 0x71374491
42put k 2 0xb5c0fbcf
43put k 3 0xe9b5dba5
44put k 4 0x3956c25b
45put k 5 0x59f111f1
46put k 6 0x923f82a4
47put k 7 0xab1c5ed5
48put k 8 0xd807aa98
49put k 9 0x12835b01
50put k 10 0x243185be
51put k 11 0x550c7dc3
52put k 12 0x72be5d74
53put k 13 0x80deb1fe
54put k 14 0x9bdc06a7
55put k 15 0xc19bf174
56put k 16 0xe49b69c1
57put k 17 0xefbe4786
58put k 18 0x0fc19dc6
59put k 19 0x240ca1cc
60put k 20 0x2de92c6f
61put k 21 0x4a7484aa
62put k 22 0x5cb0a9dc
63put k 23 0x76f988da
64put k 24 0x983e5152
65put k 25 0xa831c66d
66put k 26 0xb00327c8
67put k 27 0xbf597fc7
68put k 28 0xc6e00bf3
69put k 29 0xd5a79147
70put k 30 0x06ca6351
71put k 31 0x14292967
72put k 32 0x27b70a85
73put k 33 0x2e1b2138
74put k 34 0x4d2c6dfc
75put k 35 0x53380d13
76put k 36 0x650a7354
77put k 37 0x766a0abb
78put k 38 0x81c2c92e
79put k 39 0x92722c85
80put k 40 0xa2bfe8a1
81put k 41 0xa81a664b
82put k 42 0xc24b8b70
83put k 43 0xc76c51a3
84put k 44 0xd192e819
85put k 45 0xd6990624
86put k 46 0xf40e3585
87put k 47 0x106aa070
88put k 48 0x19a4c116
89put k 49 0x1e376c08
90put k 50 0x2748774c
91put k 51 0x34b0bcb5
92put k 52 0x391c0cb3
93put k 53 0x4ed8aa4a
94put k 54 0x5b9cca4f
95put k 55 0x682e6ff3
96put k 56 0x748f82ee
97put k 57 0x78a5636f
98put k 58 0x84c87814
99put k 59 0x8cc70208
100put k 60 0x90befffa
101put k 61 0xa4506ceb
102put k 62 0xbef9a3f7
103put k 63 0xc67178f2
104end
105fn iv s edit uint 8 to void
106put s 0 0x6a09e667
107put s 1 0xbb67ae85
108put s 2 0x3c6ef372
109put s 3 0xa54ff53a
110put s 4 0x510e527f
111put s 5 0x9b05688c
112put s 6 0x1f83d9ab
113put s 7 0x5be0cd19
114end
115fn sched w edit uint 64 o ulong to void
116q = ulong 0
117x = uint 0
118y = uint 0
119for i ulong 16 unroll
120q = add o mul i 4
121x = uint get fbuf q
122x = or shl x 8 uint get fbuf add q 1
123x = or shl x 8 uint get fbuf add q 2
124put w i or shl x 8 uint get fbuf add q 3
125end
126for i ulong 48 unroll
127x = get w add i 1
128y = get w add i 14
129x = add add get w i get w add i 9 xor xor rotr x 7 rotr x 18 shr x 3
130put w add i 16 add x xor xor rotr y 17 rotr y 19 shr y 10
131end
132end
133fn schedp w edit uint 64 p view uchar 128 o ulong to void
134q = ulong 0
135x = uint 0
136y = uint 0
137for i ulong 16 unroll
138q = add o mul i 4
139x = uint get p q
140x = or shl x 8 uint get p add q 1
141x = or shl x 8 uint get p add q 2
142put w i or shl x 8 uint get p add q 3
143end
144for i ulong 48 unroll
145x = get w add i 1
146y = get w add i 14
147x = add add get w i get w add i 9 xor xor rotr x 7 rotr x 18 shr x 3
148put w add i 16 add x xor xor rotr y 17 rotr y 19 shr y 10
149end
150end
151fn rounds s edit uint 8 w view uint 64 kt view uint 64 to void
152a = get s 0
153b = get s 1
154c = get s 2
155d = get s 3
156e = get s 4
157f = get s 5
158g = get s 6
159h = get s 7
160t = uint 0
161for i ulong 64 unroll
162h = add h get kt i
163h = add h get w i
164t = xor rotr e 6 rotr e 11
165t = xor t rotr e 25
166h = add h t
167h = add h xor g and e xor f g
168d = add d h
169t = xor rotr a 2 rotr a 13
170t = xor t rotr a 22
171h = add h t
172t = and c or a b
173h = add h or and a b t
174t = h
175h = g
176g = f
177f = e
178e = d
179d = c
180c = b
181b = a
182a = t
183end
184put s 0 add get s 0 a
185put s 1 add get s 1 b
186put s 2 add get s 2 c
187put s 3 add get s 3 d
188put s 4 add get s 4 e
189put s 5 add get s 5 f
190put s 6 add get s 6 g
191put s 7 add get s 7 h
192end
193text hexd "0123456789abcdef"
194fn hexout s view uint 8 to void
195for i ulong 8
196v = get s i
197for j2 ulong 8
198sh = sub uint 28 mul uint j2 4
199d = ulong and shr v sh 15
200q = add mul i 8 j2
201put hexo q get hexd d
202end
203end
204end
205fn tailblk s edit uint 8 w edit uint 64 kt view uint 64 n ulong to void
206p = new uchar 128 0
207off = shl shr n 6 6
208k = sub n off
209for i ulong k
210put p i get fbuf add off i
211end
212put p k 0x80
213e = ulong 64
214if ge k 56
215e = 128
216end
217bits = shl n 3
218for i ulong 8 unroll
219put p sub e add i 1 uchar and shr bits mul i 8 0xff
220end
221schedp w view p 0
222rounds s view w kt
223if eq e 128
224schedp w view p 64
225rounds s view w kt
226end
227end
228fn shafbuf n ulong to void
229s = new uint 8 0
230w = new uint 64 0
231kt = new uint 64 0
232kinit kt
233iv s
234nbl = shr n 6
235j = ulong 0
236while lt j nbl bound 999999
237sched w shl j 6
238rounds s view w view kt
239j = add j 1
240end
241tailblk s w view kt n
242hexout view s
243end
244
245text tline "\n"
246fn say t view uchar * to void
247w = write 1 t 0 len t
248end
249fn sayln t view uchar * to void
250say t
251say tline
252end
253note ---- path builder: pa = WORKDIR "/" name ----
254fn pab b uchar to void
255k = get gv PAN
256put pa k b
257put gv PAN add k 1
258end
259fn pat t view uchar * to void
260for i ulong len t
261pab get t i
262end
263end
264fn wpath t view uchar * to void
265put gv PAN 0
266k = get gv WDN
267for i ulong k
268pab get wd i
269end
270pab 47
271pat t
272end
273fn pbcopy to void
274k = get gv PAN
275for i ulong k
276put pb i get pa i
277end
278put gv PBN k
279end
280note ---- packed argument list in pk: u16 count, then u16 length and bytes per argument ----
281fn pkstart to void
282put pk 0 0
283put pk 1 0
284put gv PKN 2
285end
286fn pkb b uchar to void
287k = get gv PKN
288put pk k b
289put gv PKN add k 1
290end
291fn pkcnt to void
292c = add ulong get pk 0 shl ulong get pk 1 8
293c = add c 1
294put pk 0 uchar and c 255
295put pk 1 uchar shr c 8
296end
297fn pkt t view uchar * to void
298pkcnt
299n = len t
300pkb uchar and n 255
301pkb uchar shr n 8
302for i ulong n
303pkb get t i
304end
305end
306fn pkpa to void
307pkcnt
308n = get gv PAN
309pkb uchar and n 255
310pkb uchar shr n 8
311for i ulong n
312pkb get pa i
313end
314end
315note ---- files ----
316fn rdinto t view uchar * to long
317fd = fopen t 0 len t 0 0
318if lt fd 0
319ret fd
320end
321n = ulong 0
322go = true
323while go bound 999999
324r = read int fd fbuf n sub FCAP n
325if le r 0
326go = false
327else
328n = add n ulong r
329end
330if eq n FCAP
331go = false
332end
333end
334c = fclose int fd
335ret long n
336end
337fn rdpa to long
338fd = fopen pa 0 get gv PAN 0 0
339if lt fd 0
340ret fd
341end
342n = ulong 0
343go = true
344while go bound 999999
345r = read int fd fbuf n sub FCAP n
346if le r 0
347go = false
348else
349n = add n ulong r
350end
351if eq n FCAP
352go = false
353end
354end
355c = fclose int fd
356ret long n
357end
358fn wrpa n ulong to bool
359fd = fopen pa 0 get gv PAN 577 420
360if lt fd 0
361ret false
362end
363o = ulong 0
364while lt o n bound 999999
365w = write int fd fbuf o sub n o
366if le w 0
367c = fclose int fd
368ret false
369end
370o = add o ulong w
371end
372c2 = fclose int fd
373ret true
374end
375note copy file t (relative to the repository root) to pa
376fn cpto t view uchar * to bool
377n = rdinto t
378if lt n 0
379ret false
380end
381ret wrpa ulong n
382end
383note ---- child processes: stdin, stdout and stderr redirected, exit status returned ----
384fn waitst pid long to long
385st = new uchar 8 0
386r = waitpid int pid st 0 8 0
387if lt r 0
388ret -1
389end
390s = ulong get st 0
391if ne and s 127 0
392ret long add 1000 and s 127
393end
394ret long get st 1
395end
396note run pk with stdin from pb (or /dev/null when PBN is 0) and stdout to pa; stderr to WORKDIR/err
397text tnull "/dev/null"
398text terr "err"
399fn spawn to long
400pid = fork
401if lt pid 0
402ret -1
403end
404if eq pid 0
405i = int 0
406if eq get gv PBN 0
407i = int fopen tnull 0 len tnull 0 0
408else
409i = int fopen pb 0 get gv PBN 0 0
410end
411o = int fopen pa 0 get gv PAN 577 493
412if or lt i 0 lt o 0
413exit 120
414end
415d0 = dupfd i 0 0
416d1 = dupfd o 1 0
417wpath terr
418e = int fopen pa 0 get gv PAN 577 420
419d2 = dupfd e 2 0
420x = execprog pk 0 get gv PKN
421exit 121
422end
423ret waitst pid
424end
425
426fn pkbuf which ulong to void
427pkcnt
428n = get gv OMN
429if eq which 1
430n = get gv CBN
431end
432pkb uchar and n 255
433pkb uchar shr n 8
434for i ulong n
435if eq which 1
436pkb get cb i
437else
438pkb get omc i
439end
440end
441end
442note compile the source at pb into pa with the seeded compiler
443fn compile to bool
444pkstart
445pkbuf 0
446rc = spawn
447ret eq rc 0
448end
449fn setcb to void
450k = get gv PAN
451for i ulong k
452put cb i get pa i
453end
454put gv CBN k
455end
456note ---- one case: the checker's stdout is read into ob (ON bytes) ----
457text tout "out"
458fn runchk to long
459put gv PBN 0
460wpath tout
461rc = spawn
462n = rdpa
463put gv ON 0
464if ge n 0
465for i ulong ulong n
466put ob i get fbuf i
467end
468put gv ON ulong n
469end
470ret rc
471end
472text tfcase "FAIL case "
473text tgotrc " exit "
474fn bad name view uchar * rc long to void
475put gv BAD add get gv BAD 1
476if eq get gv MUT 0
477say tfcase
478say name
479say tgotrc
480v = ulong rc
481if lt rc 0
482v = 999
483end
484sayn v
485say tline
486end
487end
488fn sayn v ulong to void
489d = new uchar 24 0
490x = v
491k = ulong 0
492go = true
493while go bound 30
494put d k uchar add 48 rem x 10
495k = add k 1
496x = div x 10
497go = gt x 0
498end
499while gt k 0 bound 30
500k = sub k 1
501w = write 1 d k 1
502end
503end
504fn hasob t view uchar * to bool
505n = get gv ON
506m = len t
507if lt n m
508ret false
509end
510s = ulong 0
511while le s sub n m bound 999999
512ok = true
513for i ulong m
514if ok
515if ne get ob add s i get t i
516ok = false
517end
518end
519end
520if ok
521ret true
522end
523s = add s 1
524end
525ret false
526end
527text tacc "PHYSICAL-RECEIPT ACCEPTED"
528text texp "tests/native/x86/receipt-fixtures/expected/"
529text tdotout ".out"
530note compare the output with the golden file; its verdict line sets the expected exit status
531fn golden name view uchar * to void
532rc = runchk
533put gv PAN 0
534pat texp
535pat name
536pat tdotout
537n = rdpa
538if lt n 0
539bad name -2
540ret
541end
542k = ulong n
543ok = eq k get gv ON
544for i ulong k
545put eb i get fbuf i
546end
547if ok
548for i ulong k
549if ne get eb i get ob i
550ok = false
551end
552end
553end
554want = long 1
555put gv ON k
556for i ulong k
557put ob i get eb i
558end
559if hasob tacc
560want = 0
561end
562if or not ok ne rc want
563bad name rc
564end
565end
566fn pkchk to void
567pkstart
568pkbuf 1
569end
570text tfx "tests/native/x86/receipt-fixtures/"
571text tev "evidence/"
572text taccl "tests/native/x86/receipt-fixtures/accept/native-x86-physical-be8c5130"
573fn g1 name view uchar * r view uchar * to void
574pkchk
575pkt r
576golden name
577end
578text tedge "tests/native/x86/receipt-fixtures/edge/"
579text tpj "/native-x86-physical-be8c5130.json"
580text tedp "edge-"
581fn gedge e view uchar * to void
582pkchk
583put gv PAN 0
584pat tedge
585pat e
586pat tpj
587pkpa
588pkt taccl
589put gv PAN 0
590pat tedp
591pat e
592k = get gv PAN
593for i ulong k
594put pb i get pa i
595end
596put gv PBN k
597gedge2 k
598end
599fn gedge2 k ulong to void
600nm = new uchar 4096 0
601for i ulong k
602put nm i get pb i
603end
604golden part nm 0 k
605end
606
607note ---- scratch cases ----
608text tapp "app"
609text tappd "app/native-x86-physical-be8c5130"
610text tappj "app/native-x86-physical-be8c5130.json"
611text tappr "app/receipt.json"
612text tnone "none.json"
613text taccj "tests/native/x86/receipt-fixtures/accept/native-x86-physical-be8c5130.json"
614text tl0 "x86-native.log"
615text tl1 "x86-native-controls.log"
616text tl2 "x86-native-wrongpin.log"
617text tl3 "x86-native-mut.log"
618text tsl "/"
619text tcopy "scratch-copy-accepted"
620text tren "renamed-receipt"
621text tappc "appended-log-byte"
622text tmiss "missing-receipt"
623text tinv "invalid-json"
624text tu0 "usage-no-argument"
625text tu3 "usage-three-arguments"
626text tvren "PHYSICAL-RECEIPT REJECTED (1 failed: file name carries the x86 pin prefix)\n"
627text tvapp "PHYSICAL-RECEIPT REJECTED (1 failed: log x86-native-mut.log sha256 matches receipt)\n"
628text tvmiss "FAIL receipt is readable JSON (open or read failed: errno 2)\n"
629text tvinv "FAIL receipt is readable JSON (invalid JSON near byte 13)\n"
630text tinvp "tests/native/x86/receipt-fixtures/edge/invalid-json/native-x86-physical-be8c5130.json"
631fn cplog t view uchar * to bool
632put gv PAN 0
633pat taccl
634pat tsl
635pat t
636n = rdpa
637if lt n 0
638ret false
639end
640wpath tappd
641pat tsl
642pat t
643ret wrpa ulong n
644end
645fn expect name view uchar * want long line view uchar * to void
646rc = runchk
647if or ne rc want not hasob line
648bad name rc
649end
650end
651fn setup to bool
652wpath tapp
653m = makedir pa 0 get gv PAN 493
654wpath tappd
655m2 = makedir pa 0 get gv PAN 493
656wpath tappj
657if not cpto taccj
658ret false
659end
660wpath tappr
661if not cpto taccj
662ret false
663end
664ok = and and cplog tl0 cplog tl1 and cplog tl2 cplog tl3
665ret ok
666end
667fn pkw t view uchar * to void
668wpath t
669pkpa
670end
671fn appendbyte to bool
672wpath tappd
673pat tsl
674pat tl3
675n = rdpa
676if lt n 0
677ret false
678end
679put fbuf ulong n 120
680ret wrpa add ulong n 1
681end
682fn scratch to void
683pkchk
684pkw tappj
685expect tcopy 0 tacc
686pkchk
687pkw tappr
688pkw tappd
689expect tren 1 tvren
690pkchk
691pkw tnone
692expect tmiss 1 tvmiss
693pkchk
694pkt tinvp
695expect tinv 1 tvinv
696pkchk
697rc = runchk
698if or ne rc 2 ne get gv ON 0
699bad tu0 rc
700end
701pkchk
702pkt tinvp
703pkt tinvp
704pkt tinvp
705rc2 = runchk
706if or ne rc2 2 ne get gv ON 0
707bad tu3 rc2
708end
709end
710fn scratch2 to void
711pkchk
712pkw tappj
713expect tappc 1 tvapp
714end
715text tg1 "committed-be8c5130"
716text tr1 "evidence/native-x86-be8c5130.json"
717text tg2 "emulated-receipt"
718text tr2 "evidence/native-x86-physical-checker/emulated-receipt.json"
719text tg3 "forged-receipt-evidence"
720text tr3 "evidence/native-x86-physical-checker/forged-receipt.json"
721text tg4 "accept"
722text tg5 "forged"
723text tr5 "tests/native/x86/receipt-fixtures/forged/native-x86-physical-be8c5130.json"
724text te1 "dup-key-last-wins"
725text te2 "dup-key-dead-emulated"
726text te3 "escaped-label"
727text te4 "repr-strings"
728text te5 "repr-nested"
729text te6 "exit-forms"
730text te7 "exit-wrong-types"
731text te8 "schema-true"
732text te9 "three-commands"
733text te10 "host-not-object"
734text te11 "blank-fields"
735text te12 "emulated-in-key"
736text te13 "not-object"
737note every case; the scratch copy must be fresh (setup) and the byte is appended last
738fn allcases to bool
739if not setup
740ret false
741end
742g1 tg1 tr1
743g1 tg2 tr2
744g1 tg3 tr3
745g1 tg4 taccj
746g1 tg5 tr5
747gedge te1
748gedge te2
749gedge te3
750gedge te4
751gedge te5
752gedge te6
753gedge te7
754gedge te8
755gedge te9
756gedge te10
757gedge te11
758gedge te12
759gedge te13
760scratch
761if not appendbyte
762ret false
763end
764scratch2
765ret true
766end
767note ---- checker mutants (negative controls) ----
768text tsrc "tests/native/x86/check_physical_receipt.om"
769text tm1a "if ne get pool add o i get hexo i\nok = false"
770text tm1b "if ne get pool add o i get hexo i\nok = true"
771text tm2a "chk tnoemu not sayemu"
772text tm2b "chk tnoemu true"
773text tm1 "m1.om"
774text tm1x "m1"
775text tm2 "m2.om"
776text tm2x "m2"
777fn atf p ulong t view uchar * n ulong to bool
778if gt add p len t n
779ret false
780end
781for i ulong len t
782if ne get fbuf add p i get t i
783ret false
784end
785end
786ret true
787end
788fn putb o ulong b view uchar * to ulong
789for i ulong len b
790put eb add o i get b i
791end
792ret add o len b
793end
794note write the checker source with the one occurrence of a replaced by b to pa; false unless exactly one
795fn subst a view uchar * b view uchar * n ulong to ulong
796hits = ulong 0
797o = ulong 0
798p = ulong 0
799while lt p n bound 999999
800if atf p a n
801hits = add hits 1
802o = putb o b
803p = add p len a
804else
805put eb o get fbuf p
806o = add o 1
807p = add p 1
808end
809end
810if ne hits 1
811ret 0
812end
813ret o
814end
815fn mutate a view uchar * b view uchar * to bool
816pan = get gv PAN
817put gv PBN pan
818for i ulong pan
819put pb i get pa i
820end
821r = rdinto tsrc
822if lt r 0
823ret false
824end
825o = subst a b ulong r
826if eq o 0
827ret false
828end
829for i ulong o
830put fbuf i get eb i
831end
832pbn = get gv PBN
833for i ulong pbn
834put pa i get pb i
835end
836put gv PAN pbn
837ret wrpa o
838end
839
840text tusage "usage: check_receipt_test OMC WORKDIR (run from the repository root)\n"
841text tpin "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f"
842text twrong "CHECK-RECEIPT-TEST FAIL omc sha256 is not the seeded omega-mv e5b32567 compiler 2c824805\n"
843text tsetup "CHECK-RECEIPT-TEST FAIL setup: "
844text tcpr "cpr"
845text tccomp "compiling the checker"
846text tmcomp "building a mutant"
847text tscr "copying the scratch fixtures"
848text tnc "FAIL mutant not caught: "
849text tmc "MUTANT "
850text tmby " caught by "
851text tmcases " failing cases"
852text tpass "CHECK-RECEIPT-TEST PASS (18 golden outputs, 7 scratch cases, 2 of 2 checker mutants caught)\n"
853text tfail "CHECK-RECEIPT-TEST FAIL\n"
854fn setupfail t view uchar * to int
855say tsetup
856sayln t
857ret 2
858end
859fn rdarg i ulong which ulong to bool
860if eq which 0
861r = argread i omc 0 4096
862put gv OMN ulong r
863ret gt r 0
864end
865r2 = argread i wd 0 4096
866put gv WDN ulong r2
867ret gt r2 0
868end
869fn omcok to bool
870put gv PAN 0
871k = get gv OMN
872for i ulong k
873pab get omc i
874end
875n = rdpa
876if lt n 0
877ret false
878end
879shafbuf ulong n
880for i ulong 64
881if ne get hexo i get tpin i
882ret false
883end
884end
885ret true
886end
887note compile pb into WORKDIR/bin and make it the checker under test
888fn build bin view uchar * to bool
889wpath bin
890if not compile
891ret false
892end
893setcb
894ret true
895end
896fn mutant src view uchar * bin view uchar * which ulong to int
897wpath src
898ok = false
899if eq which 1
900ok = mutate tm1a tm1b
901else
902ok = mutate tm2a tm2b
903end
904if not ok
905ret 2
906end
907pbcopy
908if not build bin
909ret 2
910end
911put gv MUT 1
912put gv BAD 0
913if not allcases
914ret 2
915end
916put gv MUT 0
917if gt get gv BAD 0
918say tmc
919say src
920say tmby
921sayn get gv BAD
922sayln tmcases
923ret 1
924end
925say tnc
926sayln src
927ret 0
928end
929fn main to int
930if ne argcnt 3
931w = write 2 tusage 0 len tusage
932ret 2
933end
934if not and rdarg 1 0 rdarg 2 1
935w2 = write 2 tusage 0 len tusage
936ret 2
937end
938if not omcok
939say twrong
940ret 65
941end
942put gv PAN 0
943pat tsrc
944pbcopy
945if not build tcpr
946ret setupfail tccomp
947end
948put gv BAD 0
949if not allcases
950ret setupfail tscr
951end
952cb1 = get gv BAD
953m1 = mutant tm1 tm1x 1
954m2 = mutant tm2 tm2x 2
955if or eq m1 2 eq m2 2
956ret setupfail tmcomp
957end
958if and eq cb1 0 and eq m1 1 eq m2 1
959say tpass
960ret 0
961end
962say tfail
963ret 1
964end