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
omega-mv / seed / profile / check.om
| 1 | om2 |
| 2 | note SPDX-License-Identifier: AGPL-3.0-only |
| 3 | note seed/profile/check.om: qualification for seed/profile (DRA-419 critical source profile) and the |
| 4 | note profiled authority modules. Seeded Omega, program mode, Linux AArch64. It compiles and runs the |
| 5 | note seeded checker (profile.om), the OM-2 conductor (seed/qualification/om2/gate.om) and the authority |
| 6 | note gates with the pinned omc, and compares their results. |
| 7 | note Build and run from the repository root: |
| 8 | note mkdir -p build/seed && seed/out/omc < seed/profile/check.om > build/seed/profile-check |
| 9 | note chmod +x build/seed/profile-check && build/seed/profile-check |
| 10 | note Exit 0 PASS (last line PROFILE CHECK PASS), 1 FAIL (PROFILE CHECK FAIL failed=N, or a compile |
| 11 | note failure of gate.om or profile.om), 3 NOT_RUN (no seed/out/omc, or its sha256 is not om/units.sh |
| 12 | note OMC_PIN). The sha256 is FIPS 180-4 with the constants of seed/qualification/om2/fixtures. |
| 13 | note Children get an empty environment (execprog); stdin and stderr are inherited unless redirected. |
| 14 | note Scratch: build/seed/profile, removed and recreated on every run. |
| 15 | |
| 16 | text omcp "seed/out/omc" |
| 17 | text units "om/units.sh" |
| 18 | text pinkey "OMC_PIN=" |
| 19 | text kdec "seed/qualification/om2/fixtures/sha256-k.dec" |
| 20 | text ivdec "seed/qualification/om2/fixtures/sha256-iv.dec" |
| 21 | text bd1 "build" |
| 22 | text bd2 "build/seed" |
| 23 | text bdir "build/seed/profile" |
| 24 | text slash "/" |
| 25 | text adir "seed/authority/" |
| 26 | text dotom ".om" |
| 27 | text dotout ".out" |
| 28 | text dnull "/dev/null" |
| 29 | text mname "src" |
| 30 | text gatesrc "seed/qualification/om2/gate.om" |
| 31 | text profsrc "seed/profile/profile.om" |
| 32 | text ngate "gate" |
| 33 | text nprof "profile" |
| 34 | text pcases "seed/profile/profile.cases" |
| 35 | text mcases "seed/profile/mutants.cases" |
| 36 | text ncases "cases" |
| 37 | text nmut "mutants" |
| 38 | text ncaslog "cases.log" |
| 39 | text nmutlog "mutants.log" |
| 40 | text nunit "unit.txt" |
| 41 | text aact "seed/authority/action.om" |
| 42 | text asto "seed/authority/store.om" |
| 43 | text alck "seed/authority/lock.om" |
| 44 | text adis "seed/authority/dispatch.om" |
| 45 | text oldlock "seed/profile/cases/lock-943d955.om" |
| 46 | text olddis "seed/profile/cases/dispatch-943d955.om" |
| 47 | text nlkold "lock-old" |
| 48 | text nlkout "lock-old.out" |
| 49 | text nfold "fault-old" |
| 50 | text nfout "fault-old.out" |
| 51 | text faction "action.om" |
| 52 | text fstore "store.om" |
| 53 | text flck "lock.om" |
| 54 | text fdisp "dispatch.om" |
| 55 | text fdtest "dispatch-test.om" |
| 56 | text fltest "lock-test.om" |
| 57 | text fstest "store-test.om" |
| 58 | text fotest "dispatch-order-test.om" |
| 59 | text fxtest "store-exact-test.om" |
| 60 | text fctest "store-cleanup-test.om" |
| 61 | text fftest "dispatch-fault-test.om" |
| 62 | text gdisp "dispatch-gate" |
| 63 | text glock "lock-gate" |
| 64 | text gstore "store-gate" |
| 65 | text gorder "dispatch-order-gate" |
| 66 | text gexact "store-exact-gate" |
| 67 | text gclean "store-cleanup-gate" |
| 68 | text gfault "dispatch-fault-gate" |
| 69 | text ldisp "action.om store.om lock.om dispatch.om dispatch-test.om" |
| 70 | text llock "lock.om lock-test.om" |
| 71 | text lstore "store.om store-test.om" |
| 72 | text lorder "action.om store.om dispatch.om dispatch-order-test.om" |
| 73 | text lexact "store.om store-exact-test.om" |
| 74 | text ocleanm "store-cleanup-gate.om = injected store.om store-cleanup-test.om\n" |
| 75 | text bcleanm "store-cleanup-gate.om is stale against store.om store-cleanup-test.om\n" |
| 76 | text ofaultm "dispatch-fault-gate.om = injected dispatch.om\n" |
| 77 | text bfaultm "dispatch-fault-gate.om is stale against action.om store.om dispatch.om dispatch-fault-test.om\n" |
| 78 | note store-cleanup-gate routes the store descriptor calls through the test's failure injectors: |
| 79 | note the first occurrence on each line is replaced, in this order. |
| 80 | text cf1 "fopen spath" |
| 81 | text ct1 "cfopen" |
| 82 | text cf2 "write int fd sb" |
| 83 | text ct2 "cwrite int fd" |
| 84 | text cf3 "fsync int fd" |
| 85 | text ct3 "cfsync int fd" |
| 86 | text cf4 "fclose int fd" |
| 87 | text ct4 "cfclose int fd" |
| 88 | text cf5 "renames spkt" |
| 89 | text ct5 "crenames" |
| 90 | note dispatch-fault-gate routes dispatch's actlost, actrecon and writerec results through the |
| 91 | note test's injectors: whole-line replacements. |
| 92 | text ff1 "err = actlost r" |
| 93 | text ft1 "err = factlost r" |
| 94 | text ff2 "err = actrecon r s" |
| 95 | text ft2 "err = factrecon r s" |
| 96 | text ff3 "err = writerec r" |
| 97 | text ft3 "err = fwriterec r" |
| 98 | text okp "ok " |
| 99 | text badp "FAIL " |
| 100 | text nl "\n" |
| 101 | text nrnoomc "NOT_RUN profile: no omc at seed/out/omc\n" |
| 102 | text nrpin "NOT_RUN profile: omc is not the pinned compiler " |
| 103 | text nrsha "NOT_RUN profile: cannot read the SHA-256 constants in seed/qualification/om2/fixtures\n" |
| 104 | text tomc "omc " |
| 105 | text tgatecc "FAIL gate.om does not compile\n" |
| 106 | text tprofcc "FAIL profile.om does not compile\n" |
| 107 | text tprofsha "profile sha256 " |
| 108 | text pass53 "OM2GATE PASS cases=53 pass=53 fail=0 invalid=0 not_run=0" |
| 109 | text mut22 "OM2GATE FAIL cases=22 pass=11 fail=11 invalid=0 not_run=0" |
| 110 | text vctl "VERDICT ctl-" |
| 111 | text vmut "VERDICT m-" |
| 112 | text spass " PASS " |
| 113 | text sfail " FAIL " |
| 114 | text verdict "VERDICT" |
| 115 | text okcases "profile cases (53)\n" |
| 116 | text bdcases "profile cases\n" |
| 117 | text okmut "11 profile.om mutants killed, 11 controls pass\n" |
| 118 | text bdmut "profile mutants (gate exit " |
| 119 | text cpar ")\n" |
| 120 | text profok "PROFILE-PASS" |
| 121 | text okunit "authority unit profile\n" |
| 122 | text bdunit "authority unit: " |
| 123 | text teq ".om = " |
| 124 | text tstale ".om is stale against " |
| 125 | text tnocc " does not compile\n" |
| 126 | text texit0 " exit 0: " |
| 127 | text texit " exit " |
| 128 | text tcolon ": " |
| 129 | text oklk "pre-fix lock.om refused by lock-test (exit 1)\n" |
| 130 | text bdlk "pre-fix lock.om: lock-test exit " |
| 131 | text casep "case " |
| 132 | text want "234578" |
| 133 | text okfault "pre-fix dispatch.om fails fault cases 2 3 4 5 7 8 (79 77 78 79 77 78)\n" |
| 134 | text bdfault "pre-fix dispatch.om: fault gate exit " |
| 135 | text tcases " cases '" |
| 136 | text tquote "'\n" |
| 137 | text tpass "PROFILE CHECK PASS\n" |
| 138 | text tfail "PROFILE CHECK FAIL failed=" |
| 139 | text dbig "FAIL check.om: input or line too large\n" |
| 140 | text dproc "FAIL check.om: fork, wait or memfd failed\n" |
| 141 | text dargs "FAIL check.om: path or argument capacity\n" |
| 142 | text dwipe "FAIL check.om: cannot remove build/seed/profile\n" |
| 143 | |
| 144 | global pb uchar 4096 |
| 145 | global pbn ulong 1 |
| 146 | global av uchar 16384 |
| 147 | global avp ulong 1 |
| 148 | global avc ulong 1 |
| 149 | global avl ulong 1 |
| 150 | global fa uchar 4194304 |
| 151 | global fan ulong 1 |
| 152 | global fb uchar 4194304 |
| 153 | global fbn ulong 1 |
| 154 | global ln uchar 65536 |
| 155 | global lnn ulong 1 |
| 156 | global l2 uchar 65536 |
| 157 | global pin uchar 4096 |
| 158 | global pinn ulong 1 |
| 159 | global hexd uchar 64 |
| 160 | global kk uint 64 |
| 161 | global ivs uint 8 |
| 162 | global nums ulong 64 |
| 163 | global hv uint 8 |
| 164 | global ws uint 64 |
| 165 | global st uint 8 |
| 166 | global blk uchar 64 |
| 167 | global bk ulong 2 |
| 168 | global stb uchar 4 |
| 169 | global nfail ulong 1 |
| 170 | global wpath uchar 4096 |
| 171 | global dg uchar 4096 |
| 172 | global dgn ulong 1 |
| 173 | global nb uchar 32 |
| 174 | |
| 175 | note ---- output ------------------------------------------------------------------------------ |
| 176 | fn say t view uchar * to void |
| 177 | r = write 1 t 0 len t |
| 178 | end |
| 179 | |
| 180 | fn num v ulong to void |
| 181 | n = ulong 0 |
| 182 | x = v |
| 183 | while true bound 32 |
| 184 | put nb sub 31 n uchar add rem x 10 48 |
| 185 | n = add n 1 |
| 186 | x = div x 10 |
| 187 | if eq x 0 |
| 188 | break |
| 189 | end |
| 190 | end |
| 191 | r = write 1 nb sub 32 n n |
| 192 | end |
| 193 | |
| 194 | fn die t view uchar * to void |
| 195 | r = write 1 t 0 len t |
| 196 | exit 1 |
| 197 | end |
| 198 | |
| 199 | fn okh to void |
| 200 | say okp |
| 201 | end |
| 202 | |
| 203 | fn badh to void |
| 204 | put nfail 0 add get nfail 0 1 |
| 205 | say badp |
| 206 | end |
| 207 | |
| 208 | note ---- paths and argument lists ----------------------------------------------------------- |
| 209 | fn pclear to void |
| 210 | put pbn 0 0 |
| 211 | end |
| 212 | |
| 213 | fn pcat t view uchar * to void |
| 214 | p = get pbn 0 |
| 215 | n = len t |
| 216 | if gt add p n 4095 |
| 217 | die dargs |
| 218 | end |
| 219 | for i ulong n |
| 220 | put pb add p i get t i |
| 221 | end |
| 222 | put pbn 0 add p n |
| 223 | end |
| 224 | |
| 225 | note pb = build/seed/profile/NAME |
| 226 | fn bpath t view uchar * to void |
| 227 | pclear |
| 228 | pcat bdir |
| 229 | pcat slash |
| 230 | pcat t |
| 231 | end |
| 232 | |
| 233 | fn areset to void |
| 234 | put avc 0 0 |
| 235 | put avp 0 2 |
| 236 | put av 0 0 |
| 237 | put av 1 0 |
| 238 | end |
| 239 | |
| 240 | fn afix to void |
| 241 | p = get avp 0 |
| 242 | q = get avl 0 |
| 243 | m = sub sub p q 2 |
| 244 | if gt m 65535 |
| 245 | die dargs |
| 246 | end |
| 247 | put av q uchar and m 255 |
| 248 | put av add q 1 uchar shr m 8 |
| 249 | end |
| 250 | |
| 251 | note start a new argument record |
| 252 | fn anew to void |
| 253 | p = get avp 0 |
| 254 | if gt add p 2 len av |
| 255 | die dargs |
| 256 | end |
| 257 | put avl 0 p |
| 258 | put avp 0 add p 2 |
| 259 | c = add get avc 0 1 |
| 260 | put avc 0 c |
| 261 | put av 0 uchar and c 255 |
| 262 | put av 1 uchar shr c 8 |
| 263 | afix |
| 264 | end |
| 265 | |
| 266 | fn amore t view uchar * to void |
| 267 | p = get avp 0 |
| 268 | n = len t |
| 269 | if gt add p n len av |
| 270 | die dargs |
| 271 | end |
| 272 | for i ulong n |
| 273 | put av add p i get t i |
| 274 | end |
| 275 | put avp 0 add p n |
| 276 | afix |
| 277 | end |
| 278 | |
| 279 | fn apin to void |
| 280 | p = get avp 0 |
| 281 | n = get pinn 0 |
| 282 | if gt add p n len av |
| 283 | die dargs |
| 284 | end |
| 285 | for i ulong n |
| 286 | put av add p i get pin i |
| 287 | end |
| 288 | put avp 0 add p n |
| 289 | afix |
| 290 | end |
| 291 | |
| 292 | note argv[0] = build/seed/profile/NAME |
| 293 | fn abin t view uchar * to void |
| 294 | areset |
| 295 | anew |
| 296 | amore bdir |
| 297 | amore slash |
| 298 | amore t |
| 299 | end |
| 300 | |
| 301 | note ---- children --------------------------------------------------------------------------- |
| 302 | note run the argument list; a negative descriptor is inherited. Shell-style status: the exit status, |
| 303 | note 128 + signal for a signalled child, 127 when the program is missing, 126 when it cannot run. |
| 304 | fn spawn fi int fo int fe int ss bool to ulong |
| 305 | pid = fork |
| 306 | if lt pid 0 |
| 307 | die dproc |
| 308 | end |
| 309 | if eq pid 0 |
| 310 | if ge fi 0 |
| 311 | r = dupfd fi 0 0 |
| 312 | end |
| 313 | if ge fo 0 |
| 314 | r = dupfd fo 1 0 |
| 315 | end |
| 316 | if ge fe 0 |
| 317 | r = dupfd fe 2 0 |
| 318 | end |
| 319 | if ss |
| 320 | r = setsid |
| 321 | end |
| 322 | r = execprog av 0 get avp 0 |
| 323 | if eq r -2 |
| 324 | exit 127 |
| 325 | end |
| 326 | exit 126 |
| 327 | end |
| 328 | r = waitpid int pid stb 0 4 0 |
| 329 | if ne r pid |
| 330 | die dproc |
| 331 | end |
| 332 | sg = and ulong get stb 0 127 |
| 333 | if eq sg 0 |
| 334 | ret ulong get stb 1 |
| 335 | end |
| 336 | ret add sg 128 |
| 337 | end |
| 338 | |
| 339 | fn opr to long |
| 340 | ret fopen pb 0 get pbn 0 0 0 |
| 341 | end |
| 342 | |
| 343 | fn opw to long |
| 344 | ret fopen pb 0 get pbn 0 577 420 |
| 345 | end |
| 346 | |
| 347 | fn fclo fd long to void |
| 348 | if ge fd 0 |
| 349 | r = fclose int fd |
| 350 | end |
| 351 | end |
| 352 | |
| 353 | note run the argument list with stdout to the file pb (stderr too when both), stdin /dev/null when |
| 354 | note nul, in a new session when ss; status 1 when the output file cannot be created |
| 355 | fn runpb nul bool both bool ss bool to ulong |
| 356 | ofd = opw |
| 357 | if lt ofd 0 |
| 358 | ret 1 |
| 359 | end |
| 360 | ifd = long -1 |
| 361 | if nul |
| 362 | ifd = fopen dnull 0 len dnull 0 0 |
| 363 | end |
| 364 | efd = long -1 |
| 365 | if both |
| 366 | efd = ofd |
| 367 | end |
| 368 | s = spawn int ifd int ofd int efd ss |
| 369 | fclo ifd |
| 370 | fclo ofd |
| 371 | ret s |
| 372 | end |
| 373 | |
| 374 | note compile the source on descriptor sfd with the pinned omc into build/seed/profile/NAME; on |
| 375 | note exit 0 the output is made executable (0755) |
| 376 | fn compfd sfd long t view uchar * to ulong |
| 377 | if lt sfd 0 |
| 378 | ret 1 |
| 379 | end |
| 380 | bpath t |
| 381 | ofd = opw |
| 382 | if lt ofd 0 |
| 383 | fclo sfd |
| 384 | ret 1 |
| 385 | end |
| 386 | areset |
| 387 | anew |
| 388 | amore omcp |
| 389 | s = spawn int sfd int ofd -1 false |
| 390 | fclo sfd |
| 391 | fclo ofd |
| 392 | if eq s 0 |
| 393 | r = chmod pb 0 get pbn 0 493 |
| 394 | end |
| 395 | ret s |
| 396 | end |
| 397 | |
| 398 | fn comptx src view uchar * t view uchar * to ulong |
| 399 | pclear |
| 400 | pcat src |
| 401 | fd = opr |
| 402 | ret compfd fd t |
| 403 | end |
| 404 | |
| 405 | note a memfd holding fa, positioned at 0 |
| 406 | fn famem to long |
| 407 | fd = memfd mname 0 len mname 0 |
| 408 | if lt fd 0 |
| 409 | die dproc |
| 410 | end |
| 411 | n = get fan 0 |
| 412 | o = ulong 0 |
| 413 | while lt o n bound 4194304 |
| 414 | r = write int fd fa o sub n o |
| 415 | if le r 0 |
| 416 | die dproc |
| 417 | end |
| 418 | o = add o ulong r |
| 419 | end |
| 420 | r = fseek int fd 0 0 |
| 421 | if ne r 0 |
| 422 | die dproc |
| 423 | end |
| 424 | ret fd |
| 425 | end |
| 426 | |
| 427 | note ---- files ------------------------------------------------------------------------------ |
| 428 | note fb = the bytes of the file pb; false when it cannot be read |
| 429 | fn rdb to bool |
| 430 | put fbn 0 0 |
| 431 | fd = opr |
| 432 | if lt fd 0 |
| 433 | ret false |
| 434 | end |
| 435 | n = ulong 0 |
| 436 | while true bound 4194305 |
| 437 | if eq n len fb |
| 438 | die dbig |
| 439 | end |
| 440 | r = read int fd fb n sub len fb n |
| 441 | if lt r 0 |
| 442 | fclo fd |
| 443 | put fbn 0 n |
| 444 | ret false |
| 445 | end |
| 446 | if eq r 0 |
| 447 | break |
| 448 | end |
| 449 | n = add n ulong r |
| 450 | end |
| 451 | fclo fd |
| 452 | put fbn 0 n |
| 453 | ret true |
| 454 | end |
| 455 | |
| 456 | note append the bytes of the file pb to fa (cat: an unreadable file adds nothing) |
| 457 | fn rda to void |
| 458 | fd = opr |
| 459 | if lt fd 0 |
| 460 | ret |
| 461 | end |
| 462 | n = get fan 0 |
| 463 | while true bound 4194305 |
| 464 | if eq n len fa |
| 465 | die dbig |
| 466 | end |
| 467 | r = read int fd fa n sub len fa n |
| 468 | if le r 0 |
| 469 | break |
| 470 | end |
| 471 | n = add n ulong r |
| 472 | end |
| 473 | fclo fd |
| 474 | put fan 0 n |
| 475 | end |
| 476 | |
| 477 | fn cata t view uchar * to void |
| 478 | pclear |
| 479 | pcat t |
| 480 | rda |
| 481 | end |
| 482 | |
| 483 | fn cats t view uchar * to void |
| 484 | pclear |
| 485 | pcat adir |
| 486 | pcat t |
| 487 | rda |
| 488 | end |
| 489 | |
| 490 | note fa equals fb |
| 491 | fn sameab to bool |
| 492 | n = get fan 0 |
| 493 | if ne n get fbn 0 |
| 494 | ret false |
| 495 | end |
| 496 | i = ulong 0 |
| 497 | while lt i n bound 4194304 |
| 498 | if ne get fa i get fb i |
| 499 | ret false |
| 500 | end |
| 501 | i = add i 1 |
| 502 | end |
| 503 | ret true |
| 504 | end |
| 505 | |
| 506 | fn faputb b uchar to void |
| 507 | n = get fan 0 |
| 508 | if ge n len fa |
| 509 | die dbig |
| 510 | end |
| 511 | put fa n b |
| 512 | put fan 0 add n 1 |
| 513 | end |
| 514 | |
| 515 | note ---- lines of fb ------------------------------------------------------------------------ |
| 516 | note index of the next newline at or after s, or the end of fb |
| 517 | fn lend s ulong to ulong |
| 518 | n = get fbn 0 |
| 519 | e = s |
| 520 | while lt e n bound 4194305 |
| 521 | if eq get fb e 10 |
| 522 | ret e |
| 523 | end |
| 524 | e = add e 1 |
| 525 | end |
| 526 | ret n |
| 527 | end |
| 528 | |
| 529 | fn eqat p ulong t view uchar * to bool |
| 530 | if gt add p len t get fbn 0 |
| 531 | ret false |
| 532 | end |
| 533 | for i ulong len t |
| 534 | if ne get fb add p i get t i |
| 535 | ret false |
| 536 | end |
| 537 | end |
| 538 | ret true |
| 539 | end |
| 540 | |
| 541 | note grep -qx: some line of fb equals t |
| 542 | fn hasline t view uchar * to bool |
| 543 | n = get fbn 0 |
| 544 | s = ulong 0 |
| 545 | while lt s n bound 4194305 |
| 546 | e = lend s |
| 547 | if eq sub e s len t |
| 548 | if eqat s t |
| 549 | ret true |
| 550 | end |
| 551 | end |
| 552 | s = add e 1 |
| 553 | end |
| 554 | ret false |
| 555 | end |
| 556 | |
| 557 | fn hasin s ulong e ulong t view uchar * to bool |
| 558 | p = s |
| 559 | while le add p len t e bound 4194305 |
| 560 | if eqat p t |
| 561 | ret true |
| 562 | end |
| 563 | p = add p 1 |
| 564 | end |
| 565 | ret false |
| 566 | end |
| 567 | |
| 568 | fn isnm c uchar to bool |
| 569 | if and ge c 97 le c 122 |
| 570 | ret true |
| 571 | end |
| 572 | if and ge c 48 le c 57 |
| 573 | ret true |
| 574 | end |
| 575 | ret eq c 45 |
| 576 | end |
| 577 | |
| 578 | note does line [s, e) match ^PRE[a-z0-9-]*SUF |
| 579 | fn verok s ulong e ulong pre view uchar * suf view uchar * to bool |
| 580 | if gt add s len pre e |
| 581 | ret false |
| 582 | end |
| 583 | if eqat s pre |
| 584 | p = add s len pre |
| 585 | while lt p e bound 4194305 |
| 586 | if isnm get fb p |
| 587 | p = add p 1 |
| 588 | else |
| 589 | break |
| 590 | end |
| 591 | end |
| 592 | if gt add p len suf e |
| 593 | ret false |
| 594 | end |
| 595 | ret eqat p suf |
| 596 | end |
| 597 | ret false |
| 598 | end |
| 599 | |
| 600 | note grep -c '^PRE[a-z0-9-]*SUF' over fb |
| 601 | fn cntver pre view uchar * suf view uchar * to ulong |
| 602 | n = get fbn 0 |
| 603 | c = ulong 0 |
| 604 | s = ulong 0 |
| 605 | while lt s n bound 4194305 |
| 606 | e = lend s |
| 607 | if verok s e pre suf |
| 608 | c = add c 1 |
| 609 | end |
| 610 | s = add e 1 |
| 611 | end |
| 612 | ret c |
| 613 | end |
| 614 | |
| 615 | note grep -v ' PASS ' | grep '^VERDICT' over fb |
| 616 | fn badver to void |
| 617 | n = get fbn 0 |
| 618 | s = ulong 0 |
| 619 | while lt s n bound 4194305 |
| 620 | e = lend s |
| 621 | if eqat s verdict |
| 622 | if hasin s e spass |
| 623 | else |
| 624 | r = write 1 fb s sub e s |
| 625 | say nl |
| 626 | end |
| 627 | end |
| 628 | s = add e 1 |
| 629 | end |
| 630 | end |
| 631 | |
| 632 | note tail -1 of fb: raw keeps the final newline; otherwise as $(tail -1) |
| 633 | fn tailln raw bool to void |
| 634 | n = get fbn 0 |
| 635 | k = n |
| 636 | if gt n 0 |
| 637 | if eq get fb sub n 1 10 |
| 638 | k = sub n 1 |
| 639 | end |
| 640 | end |
| 641 | s = k |
| 642 | while gt s 0 bound 4194305 |
| 643 | if eq get fb sub s 1 10 |
| 644 | break |
| 645 | end |
| 646 | s = sub s 1 |
| 647 | end |
| 648 | if raw |
| 649 | r = write 1 fb s sub n s |
| 650 | else |
| 651 | r = write 1 fb s sub k s |
| 652 | end |
| 653 | end |
| 654 | |
| 655 | note $(cat): fb without its trailing newlines |
| 656 | fn catstr to void |
| 657 | n = get fbn 0 |
| 658 | while gt n 0 bound 4194305 |
| 659 | if ne get fb sub n 1 10 |
| 660 | break |
| 661 | end |
| 662 | n = sub n 1 |
| 663 | end |
| 664 | r = write 1 fb 0 n |
| 665 | end |
| 666 | |
| 667 | note ---- line rewriting (fb to fa) ---------------------------------------------------------- |
| 668 | fn lnat p ulong t view uchar * to bool |
| 669 | if gt add p len t get lnn 0 |
| 670 | ret false |
| 671 | end |
| 672 | for i ulong len t |
| 673 | if ne get ln add p i get t i |
| 674 | ret false |
| 675 | end |
| 676 | end |
| 677 | ret true |
| 678 | end |
| 679 | |
| 680 | note ln[p .. p+fl) becomes t |
| 681 | fn splice p ulong fl ulong t view uchar * to void |
| 682 | r = add p fl |
| 683 | k = sub get lnn 0 r |
| 684 | q = add p len t |
| 685 | if gt add q k len ln |
| 686 | die dbig |
| 687 | end |
| 688 | for i ulong k |
| 689 | put l2 i get ln add r i |
| 690 | end |
| 691 | for i ulong len t |
| 692 | put ln add p i get t i |
| 693 | end |
| 694 | for i ulong k |
| 695 | put ln add q i get l2 i |
| 696 | end |
| 697 | put lnn 0 add q k |
| 698 | end |
| 699 | |
| 700 | note sed s/F/T/: the first occurrence of f in ln becomes t |
| 701 | fn subst f view uchar * t view uchar * to void |
| 702 | n = get lnn 0 |
| 703 | p = ulong 0 |
| 704 | while le add p len f n bound 65537 |
| 705 | if lnat p f |
| 706 | splice p len f t |
| 707 | ret |
| 708 | end |
| 709 | p = add p 1 |
| 710 | end |
| 711 | end |
| 712 | |
| 713 | note sed s/^F$/T/: a line equal to f becomes t |
| 714 | fn wsub f view uchar * t view uchar * to void |
| 715 | if eq get lnn 0 len f |
| 716 | if lnat 0 f |
| 717 | for i ulong len t |
| 718 | put ln i get t i |
| 719 | end |
| 720 | put lnn 0 len t |
| 721 | end |
| 722 | end |
| 723 | end |
| 724 | |
| 725 | note fa += fb with mode 1 the store-cleanup injection, mode 2 the dispatch-fault injection |
| 726 | fn xform mode ulong to void |
| 727 | n = get fbn 0 |
| 728 | s = ulong 0 |
| 729 | while lt s n bound 4194305 |
| 730 | e = lend s |
| 731 | k = sub e s |
| 732 | if gt k len ln |
| 733 | die dbig |
| 734 | end |
| 735 | for i ulong k |
| 736 | put ln i get fb add s i |
| 737 | end |
| 738 | put lnn 0 k |
| 739 | if eq mode 1 |
| 740 | subst cf1 ct1 |
| 741 | subst cf2 ct2 |
| 742 | subst cf3 ct3 |
| 743 | subst cf4 ct4 |
| 744 | subst cf5 ct5 |
| 745 | else |
| 746 | wsub ff1 ft1 |
| 747 | wsub ff2 ft2 |
| 748 | wsub ff3 ft3 |
| 749 | end |
| 750 | for i ulong get lnn 0 |
| 751 | faputb get ln i |
| 752 | end |
| 753 | if lt e n |
| 754 | faputb 10 |
| 755 | end |
| 756 | s = add e 1 |
| 757 | end |
| 758 | end |
| 759 | |
| 760 | note fa = action.om store.om, injected D, dispatch-fault-test.om |
| 761 | fn faultsrc d view uchar * to void |
| 762 | put fan 0 0 |
| 763 | cats faction |
| 764 | cats fstore |
| 765 | pclear |
| 766 | pcat d |
| 767 | b = rdb |
| 768 | xform 2 |
| 769 | cats fftest |
| 770 | end |
| 771 | |
| 772 | note ---- SHA-256 (FIPS 180-4), for compiler and checker identity ---------------------------- |
| 773 | fn shasched to void |
| 774 | for i ulong 16 |
| 775 | b = mul i 4 |
| 776 | v = shl uint get blk b 24 |
| 777 | v = or v shl uint get blk add b 1 16 |
| 778 | v = or v shl uint get blk add b 2 8 |
| 779 | v = or v uint get blk add b 3 |
| 780 | put ws i v |
| 781 | end |
| 782 | for j ulong 48 |
| 783 | q = add j 16 |
| 784 | x = get ws sub q 15 |
| 785 | y = get ws sub q 2 |
| 786 | s0 = xor xor rotr x 7 rotr x 18 shr x 3 |
| 787 | s1 = xor xor rotr y 17 rotr y 19 shr y 10 |
| 788 | put ws q add add add get ws sub q 16 s0 get ws sub q 7 s1 |
| 789 | end |
| 790 | end |
| 791 | |
| 792 | fn shat1 i ulong to uint |
| 793 | e = get st 4 |
| 794 | s1 = xor xor rotr e 6 rotr e 11 rotr e 25 |
| 795 | ch = xor and e get st 5 and not e get st 6 |
| 796 | ret add add add add get st 7 s1 ch get kk i get ws i |
| 797 | end |
| 798 | |
| 799 | fn shat2 to uint |
| 800 | a = get st 0 |
| 801 | b = get st 1 |
| 802 | c = get st 2 |
| 803 | s0 = xor xor rotr a 2 rotr a 13 rotr a 22 |
| 804 | mj = xor xor and a b and a c and b c |
| 805 | ret add s0 mj |
| 806 | end |
| 807 | |
| 808 | fn shacomp to void |
| 809 | shasched |
| 810 | for i ulong 8 |
| 811 | put st i get hv i |
| 812 | end |
| 813 | for i ulong 64 |
| 814 | t1 = shat1 i |
| 815 | t2 = shat2 |
| 816 | put st 7 get st 6 |
| 817 | put st 6 get st 5 |
| 818 | put st 5 get st 4 |
| 819 | put st 4 add get st 3 t1 |
| 820 | put st 3 get st 2 |
| 821 | put st 2 get st 1 |
| 822 | put st 1 get st 0 |
| 823 | put st 0 add t1 t2 |
| 824 | end |
| 825 | for i ulong 8 |
| 826 | put hv i add get hv i get st i |
| 827 | end |
| 828 | end |
| 829 | |
| 830 | fn shabyte b uchar to void |
| 831 | n = get bk 0 |
| 832 | put blk n b |
| 833 | n = add n 1 |
| 834 | if eq n 64 |
| 835 | shacomp |
| 836 | n = ulong 0 |
| 837 | end |
| 838 | put bk 0 n |
| 839 | put bk 1 add get bk 1 1 |
| 840 | end |
| 841 | |
| 842 | fn hexch v uint to uchar |
| 843 | if lt v 10 |
| 844 | ret uchar add v 48 |
| 845 | end |
| 846 | ret uchar add v 87 |
| 847 | end |
| 848 | |
| 849 | fn shafinal to void |
| 850 | bits = mul get bk 1 8 |
| 851 | shabyte 128 |
| 852 | while ne get bk 0 56 bound 64 |
| 853 | shabyte 0 |
| 854 | end |
| 855 | for i ulong 8 |
| 856 | shabyte uchar and shr bits mul sub 7 i 8 255 |
| 857 | end |
| 858 | for i ulong 8 |
| 859 | v = get hv i |
| 860 | for j ulong 8 |
| 861 | put hexd add mul i 8 j hexch and shr v mul sub 7 j 4 15 |
| 862 | end |
| 863 | end |
| 864 | end |
| 865 | |
| 866 | note hexd = sha256 of the file pb; false when it cannot be read |
| 867 | fn hashpb to bool |
| 868 | fd = opr |
| 869 | if lt fd 0 |
| 870 | ret false |
| 871 | end |
| 872 | for i ulong 8 |
| 873 | put hv i get ivs i |
| 874 | end |
| 875 | put bk 0 0 |
| 876 | put bk 1 0 |
| 877 | while true bound 1000000000 |
| 878 | r = read int fd ln 0 len ln |
| 879 | if lt r 0 |
| 880 | fclo fd |
| 881 | ret false |
| 882 | end |
| 883 | if eq r 0 |
| 884 | fclo fd |
| 885 | shafinal |
| 886 | ret true |
| 887 | end |
| 888 | for i ulong ulong r |
| 889 | shabyte get ln i |
| 890 | end |
| 891 | end |
| 892 | ret false |
| 893 | end |
| 894 | |
| 895 | note fb as WANT decimal lines, each below 2^32, into nums |
| 896 | fn parsenum wn ulong to bool |
| 897 | n = get fbn 0 |
| 898 | k = ulong 0 |
| 899 | v = ulong 0 |
| 900 | nd = ulong 0 |
| 901 | for i ulong n |
| 902 | c = get fb i |
| 903 | if and ge c 48 le c 57 |
| 904 | if ge nd 10 |
| 905 | ret false |
| 906 | end |
| 907 | v = add mul v 10 ulong sub c 48 |
| 908 | nd = add nd 1 |
| 909 | else |
| 910 | if or ne c 10 eq nd 0 |
| 911 | ret false |
| 912 | end |
| 913 | if or ge k wn gt v 4294967295 |
| 914 | ret false |
| 915 | end |
| 916 | put nums k v |
| 917 | k = add k 1 |
| 918 | v = ulong 0 |
| 919 | nd = ulong 0 |
| 920 | end |
| 921 | end |
| 922 | ret and eq k wn eq nd 0 |
| 923 | end |
| 924 | |
| 925 | fn ldconst to bool |
| 926 | pclear |
| 927 | pcat kdec |
| 928 | if rdb |
| 929 | if parsenum 64 |
| 930 | for i ulong 64 |
| 931 | put kk i uint get nums i |
| 932 | end |
| 933 | pclear |
| 934 | pcat ivdec |
| 935 | if rdb |
| 936 | if parsenum 8 |
| 937 | for i ulong 8 |
| 938 | put ivs i uint get nums i |
| 939 | end |
| 940 | ret true |
| 941 | end |
| 942 | end |
| 943 | end |
| 944 | end |
| 945 | ret false |
| 946 | end |
| 947 | |
| 948 | note ---- pin -------------------------------------------------------------------------------- |
| 949 | note pin += fb[a .. e), after a newline when pin is not empty |
| 950 | fn pinadd a ulong e ulong to void |
| 951 | m = get pinn 0 |
| 952 | if gt add m add 1 sub e a len pin |
| 953 | die dbig |
| 954 | end |
| 955 | if gt m 0 |
| 956 | put pin m 10 |
| 957 | m = add m 1 |
| 958 | end |
| 959 | for i ulong sub e a |
| 960 | put pin add m i get fb add a i |
| 961 | end |
| 962 | put pinn 0 add m sub e a |
| 963 | end |
| 964 | |
| 965 | note pin = the rest of every om/units.sh line that starts with OMC_PIN=, joined by newlines |
| 966 | fn ldpin to void |
| 967 | put pinn 0 0 |
| 968 | pclear |
| 969 | pcat units |
| 970 | b = rdb |
| 971 | n = get fbn 0 |
| 972 | s = ulong 0 |
| 973 | while lt s n bound 4194305 |
| 974 | e = lend s |
| 975 | if eqat s pinkey |
| 976 | pinadd add s len pinkey e |
| 977 | end |
| 978 | s = add e 1 |
| 979 | end |
| 980 | end |
| 981 | |
| 982 | fn pinok to bool |
| 983 | if ne get pinn 0 64 |
| 984 | ret false |
| 985 | end |
| 986 | for i ulong 64 |
| 987 | if ne get pin i get hexd i |
| 988 | ret false |
| 989 | end |
| 990 | end |
| 991 | ret true |
| 992 | end |
| 993 | |
| 994 | note ---- scratch directory ------------------------------------------------------------------ |
| 995 | fn wname d view uchar * o ulong base ulong to ulong |
| 996 | k = add o 19 |
| 997 | if eq get d k 46 |
| 998 | if eq get d add k 1 0 |
| 999 | ret 0 |
| 1000 | end |
| 1001 | if eq get d add k 1 46 |
| 1002 | if eq get d add k 2 0 |
| 1003 | ret 0 |
| 1004 | end |
| 1005 | end |
| 1006 | end |
| 1007 | put wpath base 47 |
| 1008 | p = add base 1 |
| 1009 | while ne get d k 0 bound 4096 |
| 1010 | if ge p 4095 |
| 1011 | die dwipe |
| 1012 | end |
| 1013 | put wpath p get d k |
| 1014 | p = add p 1 |
| 1015 | k = add k 1 |
| 1016 | end |
| 1017 | ret p |
| 1018 | end |
| 1019 | |
| 1020 | fn wone d view uchar * o ulong base ulong depth ulong to ulong |
| 1021 | rl = or ulong get d add o 16 shl ulong get d add o 17 8 |
| 1022 | if eq rl 0 |
| 1023 | die dwipe |
| 1024 | end |
| 1025 | q = wname d o base |
| 1026 | if eq q 0 |
| 1027 | ret rl |
| 1028 | end |
| 1029 | r = unlink wpath 0 q |
| 1030 | if eq r -21 |
| 1031 | if eq depth 0 |
| 1032 | die dwipe |
| 1033 | end |
| 1034 | wipe q sub depth 1 |
| 1035 | r = rmdir wpath 0 q |
| 1036 | end |
| 1037 | if ne r 0 |
| 1038 | die dwipe |
| 1039 | end |
| 1040 | ret rl |
| 1041 | end |
| 1042 | |
| 1043 | fn wipe base ulong depth ulong to void |
| 1044 | d = new uchar 8192 0 |
| 1045 | fd = fopen wpath 0 base 16384 0 |
| 1046 | if lt fd 0 |
| 1047 | die dwipe |
| 1048 | end |
| 1049 | while true bound 1000000 |
| 1050 | n = getdnts int fd d 0 len d |
| 1051 | if lt n 0 |
| 1052 | die dwipe |
| 1053 | end |
| 1054 | if eq n 0 |
| 1055 | break |
| 1056 | end |
| 1057 | o = ulong 0 |
| 1058 | while lt o ulong n bound 8192 |
| 1059 | o = add o wone d o base depth |
| 1060 | end |
| 1061 | end |
| 1062 | fclo fd |
| 1063 | end |
| 1064 | |
| 1065 | note rm -rf build/seed/profile; mkdir -p build/seed/profile |
| 1066 | fn fresh0 to void |
| 1067 | n = len bdir |
| 1068 | for i ulong n |
| 1069 | put wpath i get bdir i |
| 1070 | end |
| 1071 | r = unlink wpath 0 n |
| 1072 | if eq r -21 |
| 1073 | wipe n 16 |
| 1074 | r = rmdir wpath 0 n |
| 1075 | end |
| 1076 | if and ne r 0 ne r -2 |
| 1077 | die dwipe |
| 1078 | end |
| 1079 | r = makedir bd1 0 len bd1 511 |
| 1080 | r = makedir bd2 0 len bd2 511 |
| 1081 | r = makedir bdir 0 len bdir 511 |
| 1082 | end |
| 1083 | |
| 1084 | note ---- checks ----------------------------------------------------------------------------- |
| 1085 | note gate OMC PIN CASES build/seed/profile/SCRATCH > build/seed/profile/LOG; fb = LOG; gate status |
| 1086 | fn rungate cases view uchar * scr view uchar * log view uchar * to ulong |
| 1087 | abin ngate |
| 1088 | anew |
| 1089 | amore omcp |
| 1090 | anew |
| 1091 | apin |
| 1092 | anew |
| 1093 | amore cases |
| 1094 | anew |
| 1095 | amore bdir |
| 1096 | amore slash |
| 1097 | amore scr |
| 1098 | bpath log |
| 1099 | s = runpb false false false |
| 1100 | bpath log |
| 1101 | b = rdb |
| 1102 | ret s |
| 1103 | end |
| 1104 | |
| 1105 | note 1. Rule fixtures, real-module pre-fix controls, capacity and stop rows. |
| 1106 | fn step1 to void |
| 1107 | s = rungate pcases ncases ncaslog |
| 1108 | if hasline pass53 |
| 1109 | okh |
| 1110 | say okcases |
| 1111 | else |
| 1112 | badh |
| 1113 | say bdcases |
| 1114 | badver |
| 1115 | end |
| 1116 | end |
| 1117 | |
| 1118 | note 2. One profile.om mutant per rule: every control PASS, every kill row FAIL. |
| 1119 | fn step2 to void |
| 1120 | s = rungate mcases nmut nmutlog |
| 1121 | g = false |
| 1122 | if eq s 1 |
| 1123 | if hasline mut22 |
| 1124 | if eq cntver vctl spass 11 |
| 1125 | if eq cntver vmut sfail 11 |
| 1126 | g = true |
| 1127 | end |
| 1128 | end |
| 1129 | end |
| 1130 | end |
| 1131 | if g |
| 1132 | okh |
| 1133 | say okmut |
| 1134 | else |
| 1135 | badh |
| 1136 | say bdmut |
| 1137 | num s |
| 1138 | say cpar |
| 1139 | tailln true |
| 1140 | end |
| 1141 | end |
| 1142 | |
| 1143 | note 3. The profiled modules pass the profile as one unit (dispatch is the consumer of lock and store). |
| 1144 | fn step3 to void |
| 1145 | abin nprof |
| 1146 | anew |
| 1147 | amore aact |
| 1148 | anew |
| 1149 | amore asto |
| 1150 | anew |
| 1151 | amore alck |
| 1152 | anew |
| 1153 | amore adis |
| 1154 | bpath nunit |
| 1155 | s = runpb false false false |
| 1156 | bpath nunit |
| 1157 | b = rdb |
| 1158 | g = false |
| 1159 | if eq s 0 |
| 1160 | if hasline profok |
| 1161 | g = true |
| 1162 | end |
| 1163 | end |
| 1164 | if g |
| 1165 | okh |
| 1166 | say okunit |
| 1167 | else |
| 1168 | badh |
| 1169 | say bdunit |
| 1170 | catstr |
| 1171 | say nl |
| 1172 | end |
| 1173 | end |
| 1174 | |
| 1175 | note fb = seed/authority/G.om; report whether fa equals it |
| 1176 | fn gatecmp g view uchar * to bool |
| 1177 | pclear |
| 1178 | pcat adir |
| 1179 | pcat g |
| 1180 | pcat dotom |
| 1181 | if rdb |
| 1182 | ret sameab |
| 1183 | end |
| 1184 | ret false |
| 1185 | end |
| 1186 | |
| 1187 | note 4. The authority gates are the committed module text plus the test. |
| 1188 | fn same g view uchar * lbl view uchar * to void |
| 1189 | if gatecmp g |
| 1190 | okh |
| 1191 | say g |
| 1192 | say teq |
| 1193 | else |
| 1194 | badh |
| 1195 | say g |
| 1196 | say tstale |
| 1197 | end |
| 1198 | say lbl |
| 1199 | say nl |
| 1200 | end |
| 1201 | |
| 1202 | fn step4a to void |
| 1203 | put fan 0 0 |
| 1204 | cats faction |
| 1205 | cats fstore |
| 1206 | cats flck |
| 1207 | cats fdisp |
| 1208 | cats fdtest |
| 1209 | same gdisp ldisp |
| 1210 | put fan 0 0 |
| 1211 | cats flck |
| 1212 | cats fltest |
| 1213 | same glock llock |
| 1214 | put fan 0 0 |
| 1215 | cats fstore |
| 1216 | cats fstest |
| 1217 | same gstore lstore |
| 1218 | put fan 0 0 |
| 1219 | cats faction |
| 1220 | cats fstore |
| 1221 | cats fdisp |
| 1222 | cats fotest |
| 1223 | same gorder lorder |
| 1224 | put fan 0 0 |
| 1225 | cats fstore |
| 1226 | cats fxtest |
| 1227 | same gexact lexact |
| 1228 | end |
| 1229 | |
| 1230 | fn step4b to void |
| 1231 | put fan 0 0 |
| 1232 | pclear |
| 1233 | pcat asto |
| 1234 | b = rdb |
| 1235 | xform 1 |
| 1236 | cats fctest |
| 1237 | if gatecmp gclean |
| 1238 | okh |
| 1239 | say ocleanm |
| 1240 | else |
| 1241 | badh |
| 1242 | say bcleanm |
| 1243 | end |
| 1244 | faultsrc adis |
| 1245 | if gatecmp gfault |
| 1246 | okh |
| 1247 | say ofaultm |
| 1248 | else |
| 1249 | badh |
| 1250 | say bfaultm |
| 1251 | end |
| 1252 | end |
| 1253 | |
| 1254 | note compile seed/authority/G.om to build/seed/profile/G and run it: stdin /dev/null, stdout and |
| 1255 | note stderr to build/seed/profile/G.out |
| 1256 | fn rungt g view uchar * to void |
| 1257 | pclear |
| 1258 | pcat adir |
| 1259 | pcat g |
| 1260 | pcat dotom |
| 1261 | fd = opr |
| 1262 | s = compfd fd g |
| 1263 | if ne s 0 |
| 1264 | badh |
| 1265 | say g |
| 1266 | say tnocc |
| 1267 | ret |
| 1268 | end |
| 1269 | abin g |
| 1270 | bpath g |
| 1271 | pcat dotout |
| 1272 | s = runpb true true false |
| 1273 | bpath g |
| 1274 | pcat dotout |
| 1275 | b = rdb |
| 1276 | if eq s 0 |
| 1277 | okh |
| 1278 | say g |
| 1279 | say texit0 |
| 1280 | else |
| 1281 | badh |
| 1282 | say g |
| 1283 | say texit |
| 1284 | num s |
| 1285 | say tcolon |
| 1286 | end |
| 1287 | tailln false |
| 1288 | say nl |
| 1289 | end |
| 1290 | |
| 1291 | fn step4c to void |
| 1292 | rungt gdisp |
| 1293 | rungt glock |
| 1294 | rungt gstore |
| 1295 | rungt gorder |
| 1296 | rungt gexact |
| 1297 | rungt gclean |
| 1298 | rungt gfault |
| 1299 | end |
| 1300 | |
| 1301 | note the digit after every "case " in fb (grep -o 'case [0-9]' | tr -d 'case ' | tr -d '\n') |
| 1302 | fn digits to void |
| 1303 | n = get fbn 0 |
| 1304 | m = ulong 0 |
| 1305 | p = ulong 0 |
| 1306 | while lt add p 5 n bound 4194305 |
| 1307 | g = false |
| 1308 | if eqat p casep |
| 1309 | c = get fb add p 5 |
| 1310 | if and ge c 48 le c 57 |
| 1311 | g = true |
| 1312 | if ge m len dg |
| 1313 | die dbig |
| 1314 | end |
| 1315 | put dg m c |
| 1316 | m = add m 1 |
| 1317 | end |
| 1318 | end |
| 1319 | if g |
| 1320 | p = add p 6 |
| 1321 | else |
| 1322 | p = add p 1 |
| 1323 | end |
| 1324 | end |
| 1325 | put dgn 0 m |
| 1326 | end |
| 1327 | |
| 1328 | fn dgok to bool |
| 1329 | if ne get dgn 0 len want |
| 1330 | ret false |
| 1331 | end |
| 1332 | for i ulong len want |
| 1333 | if ne get dg i get want i |
| 1334 | ret false |
| 1335 | end |
| 1336 | end |
| 1337 | ret true |
| 1338 | end |
| 1339 | |
| 1340 | note 5. Negative controls: the pre-fix modules of main 943d955 fail the new regression tests. |
| 1341 | note The old lock test run may signal its own process group, so it runs in a new session. |
| 1342 | fn step5a to void |
| 1343 | put fan 0 0 |
| 1344 | cata oldlock |
| 1345 | cats fltest |
| 1346 | fd = famem |
| 1347 | s = compfd fd nlkold |
| 1348 | abin nlkold |
| 1349 | bpath nlkout |
| 1350 | s = runpb true true true |
| 1351 | if eq s 1 |
| 1352 | okh |
| 1353 | say oklk |
| 1354 | else |
| 1355 | badh |
| 1356 | say bdlk |
| 1357 | num s |
| 1358 | say nl |
| 1359 | end |
| 1360 | end |
| 1361 | |
| 1362 | fn step5b to void |
| 1363 | faultsrc olddis |
| 1364 | fd = famem |
| 1365 | s = compfd fd nfold |
| 1366 | abin nfold |
| 1367 | bpath nfout |
| 1368 | s = runpb true true true |
| 1369 | bpath nfout |
| 1370 | b = rdb |
| 1371 | digits |
| 1372 | g = false |
| 1373 | if eq s 1 |
| 1374 | if dgok |
| 1375 | g = true |
| 1376 | end |
| 1377 | end |
| 1378 | if g |
| 1379 | okh |
| 1380 | say okfault |
| 1381 | else |
| 1382 | badh |
| 1383 | say bdfault |
| 1384 | num s |
| 1385 | say tcases |
| 1386 | r = write 1 dg 0 get dgn 0 |
| 1387 | say tquote |
| 1388 | end |
| 1389 | end |
| 1390 | |
| 1391 | fn main to int |
| 1392 | ldpin |
| 1393 | r = faccess omcp 0 len omcp 1 |
| 1394 | if ne r 0 |
| 1395 | say nrnoomc |
| 1396 | ret 3 |
| 1397 | end |
| 1398 | if ldconst |
| 1399 | else |
| 1400 | say nrsha |
| 1401 | ret 3 |
| 1402 | end |
| 1403 | pclear |
| 1404 | pcat omcp |
| 1405 | g = false |
| 1406 | if hashpb |
| 1407 | g = pinok |
| 1408 | end |
| 1409 | if g |
| 1410 | else |
| 1411 | say nrpin |
| 1412 | r = write 1 pin 0 get pinn 0 |
| 1413 | say nl |
| 1414 | ret 3 |
| 1415 | end |
| 1416 | fresh0 |
| 1417 | put nfail 0 0 |
| 1418 | say tomc |
| 1419 | r = write 1 pin 0 get pinn 0 |
| 1420 | say nl |
| 1421 | if ne comptx gatesrc ngate 0 |
| 1422 | say tgatecc |
| 1423 | ret 1 |
| 1424 | end |
| 1425 | if ne comptx profsrc nprof 0 |
| 1426 | say tprofcc |
| 1427 | ret 1 |
| 1428 | end |
| 1429 | bpath nprof |
| 1430 | g = hashpb |
| 1431 | say tprofsha |
| 1432 | r = write 1 hexd 0 64 |
| 1433 | say nl |
| 1434 | step1 |
| 1435 | step2 |
| 1436 | step3 |
| 1437 | step4a |
| 1438 | step4b |
| 1439 | step4c |
| 1440 | step5a |
| 1441 | step5b |
| 1442 | if eq get nfail 0 0 |
| 1443 | say tpass |
| 1444 | ret 0 |
| 1445 | end |
| 1446 | say tfail |
| 1447 | num get nfail 0 |
| 1448 | say nl |
| 1449 | ret 1 |
| 1450 | end |