interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / cabi / gate.om

946 lines · 23542 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note omega-bridge cabi-1 gate, a seeded Omega driver (fork, pipefds, execprog and waitpid through tests/cabi/proc.om).
3note Build: cat tests/cabi/proc.om tests/cabi/gate.om | "$OMEGA_SEEDED_OMC" > build/cabi-gate
4note Run from the checkout root after tools/build.sh, with OMEGA_SEEDED_OMC set to the e5b32567 omc.
5note ORACLE tools, test-only and never shipped: /usr/bin/cc, /usr/bin/nm, /usr/bin/readelf, /usr/bin/sha256sum, tests/cabi/caller.c.
6global CbOm uchar 1024
7global CbOn ulong 1
8note CbExp is the exit status the next cb_bridge run must return; unsized views take two of the six parameter slots.
9global CbExp ulong 1
10text CbSeedK "OMEGA_SEEDED_OMC="
11text CbNo "NOT_RUN: set OMEGA_SEEDED_OMC (omega-mv e5b32567 omc), run tools/build.sh, and start from the omega-bridge checkout root\n"
12text CbFailP "CABI GATE FAIL: "
13text CbNl "\n"
14text CbPass "OMEGA-BRIDGE CABI GATE PASS\n"
15text CbToc "src/toc.om"
16text CbBr "build/bridge"
17text CbDir "build/cabi"
18text CbDa "build/cabi/ma"
19text CbDb "build/cabi/mb"
20text CbDc "build/cabi/mc"
21text CbFix "tests/cabi/fixture.om"
22text CbExtS "tests/cabi/ext.om"
23text CbCall "tests/cabi/caller.c"
24text CbGc "tests/cabi/golden/libombrfx.c"
25text CbGh "tests/cabi/golden/ombrfx.h"
26text CbGm "tests/cabi/golden/libombrfx.map"
27text CbG1 "tests/cabi/golden/nvmlDeviceGetCount_v2.c"
28text CbG2 "tests/cabi/golden/nvmlDeviceGetName.c"
29text CbG3 "tests/cabi/golden/nvmlErrorString.c"
30text CbOutC "build/cabi/libombrfx.c"
31text CbOutH "build/cabi/ombrfx.h"
32text CbOutM "build/cabi/libombrfx.map"
33text CbAgain "build/cabi/again.c"
34text CbExtC "build/cabi/ext.c"
35text CbExtH "build/cabi/ext.h"
36text CbSo "build/cabi/libombrfx.so.1"
37text CbNm "build/cabi/nm.txt"
38text CbRe "build/cabi/readelf.txt"
39text CbHash "build/cabi/hash"
40text CbRef "build/cabi/refuse.om"
41text CbRefO "build/cabi/refuse.out"
42text CbDin "build/cabi/direct.in"
43text CbDout "build/cabi/direct.out"
44text CbDsrc "build/cabi/direct.om"
45text CbImp "build/cabi/imp.om"
46text CbImpC "build/cabi/imp.c"
47text CbImpO "build/cabi/imp.o"
48text CbImpL "build/cabi/imp.log"
49text CbSoN "/libombrfx.so.1"
50text CbCN "/libombrfx.c"
51text CbLogN "/cc.out"
52text CbExN "/caller"
53text CbOutN "/caller.out"
54text CbLc "lib-c"
55text CbLh "lib-h"
56text CbLm "lib-map"
57text CbC "c"
58text CbH "h"
59text CbEnv "/usr/bin/env"
60text CbPath "PATH=/usr/bin:/bin"
61text CbSh "/bin/sh"
62text CbWrap "tools/bridge-seeded"
63text CbSha "/usr/bin/sha256sum"
64text CbCc "/usr/bin/cc"
65text CbNmT "/usr/bin/nm"
66text CbRel "/usr/bin/readelf"
67text CbStd "-std=gnu11"
68text CbO2 "-O2"
69text CbPic "-fPIC"
70text CbWall "-Wall"
71text CbWext "-Wextra"
72text CbWerr "-Werror"
73text CbShare "-shared"
74text CbCo "-c"
75text CbInc "-include"
76text CbStdi "stdint.h"
77text CbIdir "-Ibuild/cabi"
78text CbSoname "-Wl,-soname,libombrfx.so.1"
79text CbVers "-Wl,--version-script=build/cabi/libombrfx.map"
80text CbDefs "-Wl,-z,defs"
81text CbRpath "-Wl,-rpath,$ORIGIN"
82text CbDo "-o"
83text CbPth "-lpthread"
84text CbDyn "-D"
85text CbDef "--defined-only"
86text CbDd "-d"
87text CbPa "/* GENERATED by omega-bridge cabi-1 from src/toc.om SHA256 "
88text CbPb "; source SHA256 "
89text CbPc ". */\n"
90text CbClose "\n}\n"
91text CbGen "GENERATED"
92text CbErrW "error "
93text CbT " T "
94text CbOmega "omega_"
95text CbSonam "Library soname: [libombrfx.so.1]"
96text CbConf "conflicting types for"
97text CbFxSum "omega_fx_sum"
98text CbCpass "CALLER PASS checks=57 failures=0\n"
99text CbCfail "CALLER FAIL checks="
100text CbLost "lost=0\n"
101text CbS1 "nvmlDeviceGetCount_v2"
102text CbS2 "nvmlDeviceGetHandleByIndex_v2"
103text CbS3 "nvmlDeviceGetName"
104text CbS4 "nvmlDeviceGetMemoryInfo"
105text CbS5 "nvmlDeviceGetComputeRunningProcesses_v2"
106text CbS6 "nvmlErrorString"
107text CbS7 "ombrFxBump"
108text CbS8 "ombrFxSum"
109text CbLdet "generation is deterministic"
110text CbLprov "provenance line names the toc.om and source digests"
111text CbLgold "artifact equals its golden after the provenance line"
112text CbLfunc "exported wrapper equals its golden"
113text CbLnm "nm -D --defined-only shows exactly the declared exports"
114text CbLson "readelf shows the declared soname"
115text CbLcall "caller ORACLE passes against the generated library"
116text CbLproto "import declaration disagreeing with the external header is refused by cc"
117text CbLonce "mutation text occurs exactly once"
118text CbLhit "mutation text occurs"
119text CbLdiag "refusal names the expected error"
120text CbLemit "refusal emits no artifact"
121text CbLgood "unmutated direct input generates"
122text CbLmut "wrapper mutant is caught by the caller ORACLE"
123text CbPgen "PASS generated C, header and version map: deterministic, provenance line and golden bytes\n"
124text CbPfunc "PASS golden wrappers: nvmlDeviceGetCount_v2, nvmlDeviceGetName, nvmlErrorString\n"
125text CbPnm "PASS ORACLE nm/readelf: 8 exports, no omega_ symbols, soname libombrfx.so.1\n"
126text CbPcall "PASS ORACLE caller: 57 checks, nulls, out-params, handles, forged handles, stable strings, 8 threads x 2000 calls lost=0\n"
127text CbPproto "PASS ORACLE cc refuses an import declaration that disagrees with the external unit's generated header\n"
128text CbPref "PASS refused error "
129text CbPsep ": "
130text CbPdir "PASS direct build/bridge input: "
131text CbPmut "PASS wrapper mutant caught: "
132text CbXok "recomputed digests match; output equals the wrapper's (exit 0)\n"
133text CbX52 "no provenance trailer refused (error 52)\n"
134text CbX52z "all-zero digests refused (error 52)\n"
135text CbX52t "zero generator digest refused (error 52)\n"
136text CbX52w "wrong generator digest refused (error 52)\n"
137text CbX52s "wrong source digest refused (error 52)\n"
138text CbX52f "generator source withheld from descriptor 3 refused (error 52)\n"
139text CbX51 "Omega global refused (error 51)\n"
140text CbX51f "\nfn fx_init "
141text CbX51t "\nglobal FxG ulong 1\n\nfn fx_init "
142text CbImpF "span v 3 k value k"
143text CbImpT "span v 3 k"
144text CbAf1 "o_f[2]=deviceCount!=NULL;"
145text CbAt1 "o_f[2]=1;"
146text CbAf2 "(!deviceCount||"
147text CbAt2 "("
148text CbAw "FAIL count null out refused without commit\n"
149text CbBf "*deviceCount=(unsigned int)o_f[3];"
150text CbBt "(void)0;"
151text CbBw "FAIL count published\n"
152text CbCf1 "if(pthread_mutex_lock(&FxLock))return (nvmlReturn_t)999;\n o_f[2]=value!=NULL;"
153text CbCt1 "o_f[2]=value!=NULL;"
154text CbCf2 "*value=(unsigned long long)o_f[3];\n }\n pthread_mutex_unlock(&FxLock);"
155text CbCt2 "*value=(unsigned long long)o_f[3];\n }"
156text CbCw "FAIL no lost updates under concurrent calls\n"
157text CbImpU "span v 2 k value k"
158text CbDm "build/cabi/md"
159text CbMsrc "build/cabi/md.om"
160text CbMout "build/cabi/md.c"
161text CbDw "FAIL import through omega_fx_sum with uchar and ulong spans\n"
162text R40f " FxLock process mutex"
163text R40t " FxLock process spin"
164text R40l "malformed lock kind"
165text R41f "note cabi export ombrFxBump fx_bump status"
166text R41t "note cabi export nvmlDeviceGetName fx_bump status"
167text R41l "duplicate export symbol"
168text R42af "state FxSum ulong 1 process lock FxLock"
169text R42at "state FxSum ulong 1 process lock FxLok"
170text R42al "unknown lock"
171text R42bf "bind nvmlDeviceGetCount_v2 st FxState"
172text R42bt "bind nvmlDeviceGetCount_v2 st FxStat"
173text R42bl "undeclared state"
174text R42cf "export nvmlDeviceGetCount_v2 fx_count"
175text R42ct "export nvmlDeviceGetCount_v2 fx_cnt"
176text R42cl "export of a missing function"
177text R42df "alias nvmlDeviceGetCount nvmlDeviceGetCount_v2"
178text R42dt "alias nvmlDeviceGetCount nvmlDeviceGetCount_v3"
179text R42dl "alias of a missing export"
180text R43f "deviceCount nullable out uint32"
181text R43t "deviceCount out uint32"
182text R43l "wrong nullability"
183text R44af "field nvmlMemory_t used uint64 16"
184text R44at "field nvmlMemory_t used uint64 12"
185text R44al "bad record offset"
186text R44bf "nvmlMemory_st size 24"
187text R44bt "nvmlMemory_st size 32"
188text R44bl "bad record size"
189text R45af "bind nvmlDeviceGetName b FxBytes"
190text R45at "bind nvmlDeviceGetName b FxTexts"
191text R45al "bind to state of the wrong extent"
192text R45bf "nullable out nvmlProcessInfo_v2_t count infoCount commit 2"
193text R45bt "nullable out nvmlProcessInfo_v2_t commit 2"
194text R45bl "record array without count no longer matches the frame"
195text R46af "export ombrFxBump fx_bump status nvmlReturn_t"
196text R46at "export ombrFxBump fx_bump pointer nvmlReturn_t"
197text R46al "raw pointer result"
198text R46bf "arg ombrFxSum seed uint64"
199text R46bt "arg ombrFxSum seed nvmlMemory_t"
200text R46bl "raw pointer argument"
201text R47f "name nullable out char length length commit 0"
202text R47t "name nullable out char commit 0"
203text R47l "out span without length"
204text R48af "export nvmlErrorString fx_err cstr FxTexts"
205text R48at "export nvmlErrorString fx_err cstr FxBytes"
206text R48al "non-stable string storage"
207text R48bf "cstr FxTexts slots 4 width 32"
208text R48bt "cstr FxTexts slots 8 width 32"
209text R48bl "cstr outside its storage"
210text R49f "v view ulong 6 k ulong to ulong\nret 0"
211text R49t "v view ulong 6 k ulong to ulong\nput r 0 1\nret 0"
212text R49l "import stub with a body"
213text R50f "\nfn fx_init "
214text R50t "\nfn main to int\nret 0\nend\n\nfn fx_init "
215text R50l "main in a library unit"
216
217fn cb_say s view uchar * to void
218hp_wpart 1 s 0 len s
219end
220
221fn cb_check ok bool label view uchar * to void
222if not ok
223hp_say CbFailP
224hp_say label
225hp_say CbNl
226exit 1
227end
228end
229
230fn cb_no to void
231hp_say CbNo
232exit 77
233end
234
235fn cb_env key view uchar * dst edit uchar * to ulong
236b = new uchar 8192 0
237for i ulong ulong envcnt
238r = envread i b 0 len b
239if ge r long len key
240if hp_equal key b len key
241n = sub ulong r len key
242hp_require le n len dst
243for j ulong n
244put dst j get b add len key j
245end
246ret n
247end
248end
249end
250ret 0
251end
252
253fn cb_mkdir p view uchar * to void
254r = makedir p 0 len p 493
255if ne r -17
256hp_require eq r 0
257end
258end
259
260fn cb_config to void
261b = new uchar 1024 0
262on = cb_env CbSeedK b
263if eq on 0
264cb_no
265end
266if ne faccess b 0 on 1 0
267cb_no
268end
269if ne faccess CbBr 0 len CbBr 1 0
270cb_no
271end
272if ne faccess CbToc 0 len CbToc 4 0
273cb_no
274end
275put CbOn 0 on
276for i ulong on
277put CbOm i get b i
278end
279cb_mkdir CbDir
280cb_mkdir CbDa
281cb_mkdir CbDb
282cb_mkdir CbDc
283cb_mkdir CbDm
284end
285
286fn cb_exec path view uchar * pn ulong code long to void
287fd = hp_open path pn 524865 420
288hp_exec -1 fd code
289hp_close fd
290end
291
292note cc (ORACLE) runs under /usr/bin/env PATH=/usr/bin:/bin: execprog passes no environment, and
293note collect2 finds ld through PATH.
294fn cb_ccst to void
295hp_start CbEnv len CbEnv
296hp_arg CbPath len CbPath
297hp_arg CbCc len CbCc
298end
299
300fn cb_bridge mode view uchar * unit view uchar * dest view uchar * to void
301b = new uchar 2048 0
302hp_start CbEnv len CbEnv
303hp_arg CbPath len CbPath
304for i ulong len CbSeedK
305put b i get CbSeedK i
306end
307n = get CbOn 0
308for i ulong n
309put b add len CbSeedK i get CbOm i
310end
311hp_arg b add len CbSeedK n
312hp_arg CbSh len CbSh
313hp_arg CbWrap len CbWrap
314hp_arg mode len mode
315hp_arg unit len unit
316cb_exec dest len dest long get CbExp 0
317end
318
319fn cb_hex v uchar to bool
320if and ge v 48 le v 57
321ret true
322end
323ret and ge v 97 le v 102
324end
325
326fn cb_hash path view uchar * dst edit uchar 64 to void
327b = new uchar 2048 0
328hp_start CbSha len CbSha
329hp_arg path len path
330cb_exec CbHash len CbHash 0
331k = hp_read CbHash len CbHash b len b
332hp_require ge k 65
333for i ulong 64
334v = get b i
335hp_require cb_hex v
336put dst i v
337end
338hp_require eq get b 64 32
339end
340
341fn cb_put dst edit uchar * pos ulong w view uchar * wn ulong to ulong
342hp_require le wn len w
343hp_require le pos len dst
344hp_require le wn sub len dst pos
345for i ulong wn
346put dst add pos i get w i
347end
348ret add pos wn
349end
350
351fn cb_join dir view uchar * name view uchar * dst edit uchar 256 to ulong
352n = cb_put dst 0 dir len dir
353ret cb_put dst n name len name
354end
355
356fn cb_atn a view uchar * p ulong w view uchar * wn ulong to bool
357if gt wn len a
358ret false
359end
360if gt p sub len a wn
361ret false
362end
363for i ulong wn
364v = get a add p i
365if ne v get w i
366ret false
367end
368end
369ret true
370end
371
372fn cb_count a view uchar * n ulong w view uchar * wn ulong to ulong
373c = ulong 0
374for p ulong n
375if cb_atn a p w wn
376c = add c 1
377end
378end
379ret c
380end
381
382fn cb_has a view uchar * n ulong w view uchar * to bool
383ret gt cb_count a n w len w 0
384end
385
386fn cb_find a view uchar * n ulong from ulong w view uchar * to ulong
387p = from
388while lt p n bound 999999
389if cb_atn a p w len w
390ret p
391end
392p = add p 1
393end
394ret n
395end
396
397note Source bytes end at the first NUL; the fixture and generated C hold none.
398fn cb_sub a view uchar 131072 f view uchar * t view uchar * d edit uchar 131072 to ulong
399o = ulong 0
400p = ulong 0
401hits = ulong 0
402while lt p len a bound 999999
403if eq get a p 0
404break
405end
406if cb_atn a p f len f
407o = cb_put d o t len t
408p = add p len f
409hits = add hits 1
410else
411hp_require lt o len d
412put d o get a p
413o = add o 1
414p = add p 1
415end
416end
417cb_check gt hits 0 CbLhit
418hp_require lt o len d
419ret o
420end
421
422fn cb_prov line edit uchar 256 to ulong
423th = new uchar 64 0
424sh = new uchar 64 0
425cb_hash CbToc th
426cb_hash CbFix sh
427n = cb_put line 0 CbPa len CbPa
428n = cb_put line n th 64
429n = cb_put line n CbPb len CbPb
430n = cb_put line n sh 64
431ret cb_put line n CbPc len CbPc
432end
433
434fn cb_same a view uchar * off ulong g view uchar * k ulong to bool
435hp_require le off len a
436hp_require le k sub len a off
437hp_require le k len g
438for i ulong k
439v = get a add off i
440if ne v get g i
441ret false
442end
443end
444ret true
445end
446
447fn cb_golden path view uchar * line view uchar 256 ln ulong gold view uchar * to void
448a = new uchar 131072 0
449g = new uchar 131072 0
450n = hp_read path len path a len a
451hp_require lt n len a
452cb_check gt n ln CbLprov
453cb_check hp_equal a line ln CbLprov
454k = hp_read gold len gold g len g
455hp_require lt k len g
456cb_check eq k sub n ln CbLgold
457cb_check cb_same a ln g k CbLgold
458end
459
460fn cb_line a view uchar * p ulong to bool
461if eq p 0
462ret true
463end
464ret eq get a sub p 1 10
465end
466
467fn cb_func path view uchar * gold view uchar * to void
468a = new uchar 131072 0
469g = new uchar 8192 0
470n = hp_read path len path a len a
471hp_require lt n len a
472k = hp_read gold len gold g len g
473hp_require lt k len g
474e = cb_find g k 0 CbNl
475hp_require lt e k
476kl = add e 1
477hits = ulong 0
478pos = ulong 0
479for p ulong n
480if cb_line a p
481if cb_atn a p g kl
482hits = add hits 1
483pos = p
484end
485end
486end
487cb_check eq hits 1 CbLfunc
488q = cb_find a n pos CbClose
489cb_check lt q n CbLfunc
490cb_check eq sub add q 3 pos k CbLfunc
491cb_check cb_same a pos g k CbLfunc
492end
493
494fn cb_gen to void
495line = new uchar 256 0
496cb_bridge CbLc CbFix CbOutC
497cb_bridge CbLc CbFix CbAgain
498cb_check hp_cmp CbOutC len CbOutC CbAgain len CbAgain CbLdet
499cb_bridge CbLh CbFix CbOutH
500cb_bridge CbLm CbFix CbOutM
501cb_bridge CbC CbExtS CbExtC
502cb_bridge CbH CbExtS CbExtH
503ln = cb_prov line
504cb_golden CbOutC line ln CbGc
505cb_golden CbOutH line ln CbGh
506cb_golden CbOutM line ln CbGm
507cb_say CbPgen
508cb_func CbOutC CbG1
509cb_func CbOutC CbG2
510cb_func CbOutC CbG3
511cb_say CbPfunc
512end
513
514fn cb_so dir view uchar * to void
515so = new uchar 256 0
516cs = new uchar 256 0
517lg = new uchar 256 0
518sn = cb_join dir CbSoN so
519cn = cb_join dir CbCN cs
520gn = cb_join dir CbLogN lg
521cb_ccst
522hp_arg CbStd len CbStd
523hp_arg CbO2 len CbO2
524hp_arg CbPic len CbPic
525hp_arg CbWall len CbWall
526hp_arg CbWext len CbWext
527hp_arg CbWerr len CbWerr
528hp_arg CbShare len CbShare
529hp_arg CbInc len CbInc
530hp_arg CbStdi len CbStdi
531hp_arg CbInc len CbInc
532hp_arg CbExtH len CbExtH
533hp_arg CbSoname len CbSoname
534hp_arg CbVers len CbVers
535hp_arg CbDefs len CbDefs
536hp_arg CbDo len CbDo
537hp_arg so sn
538hp_arg cs cn
539hp_arg CbExtC len CbExtC
540hp_arg CbPth len CbPth
541cb_exec lg gn 0
542end
543
544fn cb_caller dir view uchar * code long to void
545so = new uchar 256 0
546ex = new uchar 256 0
547lg = new uchar 256 0
548ot = new uchar 256 0
549sn = cb_join dir CbSoN so
550xn = cb_join dir CbExN ex
551gn = cb_join dir CbLogN lg
552on = cb_join dir CbOutN ot
553cb_ccst
554hp_arg CbStd len CbStd
555hp_arg CbO2 len CbO2
556hp_arg CbWall len CbWall
557hp_arg CbWext len CbWext
558hp_arg CbWerr len CbWerr
559hp_arg CbIdir len CbIdir
560hp_arg CbDo len CbDo
561hp_arg ex xn
562hp_arg CbCall len CbCall
563hp_arg so sn
564hp_arg CbRpath len CbRpath
565hp_arg CbPth len CbPth
566cb_exec lg gn 0
567hp_start ex xn
568cb_exec ot on code
569end
570
571fn cb_output dir view uchar * b edit uchar 16384 to ulong
572ot = new uchar 256 0
573on = cb_join dir CbOutN ot
574n = hp_read ot on b len b
575hp_require lt n len b
576ret n
577end
578
579fn cb_lib to void
580b = new uchar 8192 0
581cb_so CbDir
582hp_start CbNmT len CbNmT
583hp_arg CbDyn len CbDyn
584hp_arg CbDef len CbDef
585hp_arg CbSo len CbSo
586cb_exec CbNm len CbNm 0
587n = hp_read CbNm len CbNm b len b
588hp_require lt n len b
589cb_check eq cb_count b n CbNl 1 8 CbLnm
590cb_sym b n CbS1
591cb_sym b n CbS2
592cb_sym b n CbS3
593cb_sym b n CbS4
594cb_sym b n CbS5
595cb_sym b n CbS6
596cb_sym b n CbS7
597cb_sym b n CbS8
598cb_check not cb_has b n CbOmega CbLnm
599hp_start CbRel len CbRel
600hp_arg CbDd len CbDd
601hp_arg CbSo len CbSo
602cb_exec CbRe len CbRe 0
603k = hp_read CbRe len CbRe b len b
604hp_require lt k len b
605cb_check cb_has b k CbSonam CbLson
606cb_say CbPnm
607end
608
609fn cb_sym b view uchar * n ulong s view uchar * to void
610w = new uchar 128 0
611k = cb_put w 0 CbT len CbT
612k = cb_put w k s len s
613k = cb_put w k CbNl 1
614cb_check eq cb_count b n w k 1 CbLnm
615end
616
617fn cb_ends b view uchar * n ulong w view uchar * to bool
618if lt n len w
619ret false
620end
621ret cb_atn b sub n len w w len w
622end
623
624fn cb_call to void
625b = new uchar 16384 0
626cb_caller CbDir 0
627n = cb_output CbDir b
628cb_check cb_ends b n CbCpass CbLcall
629cb_check cb_has b n CbLost CbLcall
630cb_say CbPcall
631end
632
633fn cb_fixture a edit uchar 131072 to ulong
634n = hp_read CbFix len CbFix a len a
635hp_require lt n len a
636ret n
637end
638
639fn cb_proto to void
640a = new uchar 131072 0
641d = new uchar 131072 0
642b = new uchar 16384 0
643n = cb_fixture a
644hp_require gt n 0
645m = cb_sub a CbImpF CbImpT d
646hp_write CbImp len CbImp d m
647cb_bridge CbLc CbImp CbImpC
648cb_ccst
649hp_arg CbStd len CbStd
650hp_arg CbO2 len CbO2
651hp_arg CbPic len CbPic
652hp_arg CbWall len CbWall
653hp_arg CbWext len CbWext
654hp_arg CbWerr len CbWerr
655hp_arg CbCo len CbCo
656hp_arg CbInc len CbInc
657hp_arg CbStdi len CbStdi
658hp_arg CbInc len CbInc
659hp_arg CbExtH len CbExtH
660hp_arg CbDo len CbDo
661hp_arg CbImpO len CbImpO
662hp_arg CbImpC len CbImpC
663put HMerge 0 1
664cb_exec CbImpL len CbImpL 1
665put HMerge 0 0
666k = hp_read CbImpL len CbImpL b len b
667hp_require lt k len b
668cb_check cb_has b k CbConf CbLproto
669cb_check cb_has b k CbFxSum CbLproto
670cb_say CbPproto
671end
672
673fn cb_errw code long w edit uchar 64 to ulong
674digits = new uchar 32 0
675k = cb_put w 0 CbErrW len CbErrW
676d = hp_num ulong code digits
677k = cb_put w k digits d
678ret cb_put w k CbNl 1
679end
680
681fn cb_refused b view uchar * k ulong code long to void
682w = new uchar 64 0
683wn = cb_errw code w
684cb_check eq cb_count b k w wn 1 CbLdiag
685cb_check not cb_has b k CbGen CbLemit
686end
687
688fn cb_refuse f view uchar * t view uchar * code long to void
689a = new uchar 131072 0
690d = new uchar 131072 0
691b = new uchar 16384 0
692digits = new uchar 32 0
693n = cb_fixture a
694cb_check eq cb_count a n f len f 1 CbLonce
695m = cb_sub a f t d
696hp_write CbRef len CbRef d m
697put CbExp 0 ulong code
698put HMerge 0 1
699cb_bridge CbLc CbRef CbRefO
700put HMerge 0 0
701put CbExp 0 0
702k = hp_read CbRefO len CbRefO b len b
703hp_require lt k len b
704cb_refused b k code
705cb_say CbPref
706dn = hp_num ulong code digits
707hp_wpart 1 digits 0 dn
708cb_say CbPsep
709end
710
711fn cb_tail label view uchar * to void
712cb_say label
713cb_say CbNl
714end
715
716fn cb_refusals to void
717cb_refuse R40f R40t 40
718cb_tail R40l
719cb_refuse R41f R41t 41
720cb_tail R41l
721cb_refuse R42af R42at 42
722cb_tail R42al
723cb_refuse R42bf R42bt 42
724cb_tail R42bl
725cb_refuse R42cf R42ct 42
726cb_tail R42cl
727cb_refuse R42df R42dt 42
728cb_tail R42dl
729cb_refuse R43f R43t 43
730cb_tail R43l
731cb_refuse R44af R44at 44
732cb_tail R44al
733cb_refuse R44bf R44bt 44
734cb_tail R44bl
735cb_refuse R45af R45at 45
736cb_tail R45al
737cb_refuse R45bf R45bt 45
738cb_tail R45bl
739cb_refuse R46af R46at 46
740cb_tail R46al
741cb_refuse R46bf R46bt 46
742cb_tail R46bl
743cb_refuse R47f R47t 47
744cb_tail R47l
745cb_refuse R48af R48at 48
746cb_tail R48al
747cb_refuse R48bf R48bt 48
748cb_tail R48bl
749cb_refuse R49f R49t 49
750cb_tail R49l
751cb_refuse R50f R50t 50
752cb_tail R50l
753end
754
755fn cb_nlen s view uchar 131072 to ulong
756for i ulong len s
757if eq get s i 0
758ret i
759end
760end
761ret len s
762end
763
764note cb_spoil: kind 0 keeps the digest, 1 makes it 64 zeros, 2 changes its first digit.
765fn cb_spoil h edit uchar 64 kind ulong to void
766if eq kind 1
767for i ulong 64
768put h i uchar 48
769end
770end
771if eq kind 2
772if eq get h 0 48
773put h 0 uchar 49
774else
775put h 0 uchar 48
776end
777end
778end
779
780note cb_direct runs build/bridge without the wrapper. mode = toc kind + 3 * source kind (cb_spoil)
781note + 9 when descriptor 3 is withheld + 27 when no trailer is appended. Digests come from the
782note sha256sum ORACLE; the generator must recompute them itself and accept only exact matches.
783fn cb_dfeed s view uchar 131072 mode ulong d edit uchar 140000 to ulong
784th = new uchar 64 0
785sh = new uchar 64 0
786n = cb_nlen s
787hp_write CbDsrc len CbDsrc s n
788cb_hash CbToc th
789cb_hash CbDsrc sh
790cb_spoil th rem mode 3
791cb_spoil sh rem div mode 3 3
792put d 0 uchar 76
793k = cb_put d 1 s n
794if eq div mode 27 0
795put d k uchar 10
796k = cb_put d add k 1 th 64
797put d k uchar 32
798k = cb_put d add k 1 sh 64
799put d k uchar 10
800k = add k 1
801end
802ret k
803end
804
805fn cb_drun mode ulong code long to void
806infd = hp_open CbDin len CbDin 524288 0
807outfd = hp_open CbDout len CbDout 524865 420
808tf = hp_open CbToc len CbToc 524288 0
809hp_require gt tf 3
810if eq rem div mode 9 3 0
811put HFd3 0 add ulong tf 1
812end
813put HMerge 0 1
814hp_start CbBr len CbBr
815hp_exec infd outfd code
816put HMerge 0 0
817put HFd3 0 0
818hp_close tf
819hp_close infd
820hp_close outfd
821end
822
823fn cb_direct s view uchar 131072 mode ulong code long label view uchar * to void
824d = new uchar 140000 0
825b = new uchar 131072 0
826e = new uchar 131072 0
827k = cb_dfeed s mode d
828hp_write CbDin len CbDin d k
829cb_drun mode code
830m = hp_read CbDout len CbDout b len b
831hp_require lt m len b
832if eq code 0
833en = cb_base e
834cb_check eq m en CbLgood
835cb_check hp_equal b e m CbLgood
836else
837cb_refused b m code
838end
839cb_say CbPdir
840cb_say label
841end
842
843fn cb_dirs to void
844a = new uchar 131072 0
845d = new uchar 131072 0
846n = cb_fixture a
847hp_require gt n 0
848cb_direct a 0 0 CbXok
849cb_direct a 27 52 CbX52
850cb_direct a 4 52 CbX52z
851cb_direct a 1 52 CbX52t
852cb_direct a 2 52 CbX52w
853cb_direct a 6 52 CbX52s
854cb_direct a 9 52 CbX52f
855m = cb_sub a CbX51f CbX51t d
856hp_require gt m n
857cb_direct d 0 51 CbX51
858end
859
860fn cb_mrun dir view uchar * c view uchar 131072 n ulong want view uchar * to void
861cs = new uchar 256 0
862b = new uchar 16384 0
863cn = cb_join dir CbCN cs
864hp_write cs cn c n
865cb_so dir
866cb_caller dir 1
867k = cb_output dir b
868cb_check cb_has b k want CbLmut
869cb_check cb_has b k CbCfail CbLmut
870cb_say CbPmut
871cb_say want
872end
873
874fn cb_base a edit uchar 131072 to ulong
875n = hp_read CbOutC len CbOutC a len a
876hp_require lt n len a
877ret n
878end
879
880fn cb_muta to void
881a = new uchar 131072 0
882d = new uchar 131072 0
883e = new uchar 131072 0
884n = cb_base a
885hp_require gt n 0
886m = cb_sub a CbAf1 CbAt1 d
887k = cb_sub d CbAf2 CbAt2 e
888cb_mrun CbDa e k CbAw
889end
890
891fn cb_mutb to void
892a = new uchar 131072 0
893d = new uchar 131072 0
894n = cb_base a
895hp_require gt n 0
896m = cb_sub a CbBf CbBt d
897cb_mrun CbDb d m CbBw
898end
899
900fn cb_mutc to void
901a = new uchar 131072 0
902d = new uchar 131072 0
903e = new uchar 131072 0
904n = cb_base a
905hp_require gt n 0
906m = cb_sub a CbCf1 CbCt1 d
907k = cb_sub d CbCf2 CbCt2 e
908cb_mrun CbDc e k CbCw
909end
910
911note cb_mutd moves the ulong span of the omega_fx_sum import from element 3 to element 2 in the source;
912note the bridge accepts it (the offset is in bounds) and only the caller ORACLE can see the wrong element.
913fn cb_mutd to void
914a = new uchar 131072 0
915d = new uchar 131072 0
916e = new uchar 131072 0
917n = cb_fixture a
918hp_require gt n 0
919cb_check eq cb_count a n CbImpF len CbImpF 1 CbLonce
920m = cb_sub a CbImpF CbImpU d
921hp_write CbMsrc len CbMsrc d m
922cb_bridge CbLc CbMsrc CbMout
923k = hp_read CbMout len CbMout e len e
924hp_require lt k len e
925cb_mrun CbDm e k CbDw
926end
927
928fn cb_mutants to void
929cb_muta
930cb_mutb
931cb_mutc
932cb_mutd
933end
934
935fn main to int
936cb_config
937cb_gen
938cb_lib
939cb_call
940cb_proto
941cb_refusals
942cb_dirs
943cb_mutants
944cb_say CbPass
945ret 0
946end