Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/ng/tests/ngbuild/gate.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / tests / ngbuild / gate.om` 544 lines ยท 10546 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Independent first-birth and regression gate for ngbuild. This file has no helper units. 3 note omc < seed/ng/tests/ngbuild/gate.om > GATE; GATE OMC SCRATCH 4 note Runs from repository root; creates SCRATCH if absent. All joining, process control and checks 5 note are Omega. Only first birth uses the independent two-unit join here; every later build uses 6 note ngbuild's pinned units parser. No cat, shell command or shell process runs in this gate. 7 note Exit 0 all checks passed; 1 a check failed; 2 usage/fixture IO failed; 3 bootstrap failed. 8 note Optional fourth argument "wrong" inverts the missing-unit expected exit: the gate must fail. 9 note Any other fourth argument names a different NGBUILD to test an implementation mutant. 10 text g_words "ngbuild ngbuild2 ngbuild2.src out out.src err units large alias missing ng ng.src source seed/ng/sha256.om seed/ng/ngbuild.om seed/ng/ngbuild.units seed/ng/ng.units build sums wrong stdout " 11 text g_zero "`0000000000000000000000000000000000000000000000000000000000000000` " 12 text g_pass "NGBUILDGATE PASS\n" 13 text g_fail "NGBUILDGATE FAIL\n" 14 text g_case "PASS case " 15 text g_bad "FAIL case " 16 text g_nl "\n" 17 text g_exp "ngbuild: unreadable: |ngbuild: duplicate unit line 2: |ngbuild: malformed units line 0|ngbuild: no units|ngbuild: more than 64 units|ngbuild: too large: |ngbuild: sha256 mismatch | have `049532d3bf88d8abaede42dff6642b402008e141b7635cb1e1f8aca26a5e4ebf`|" 18 text g_wrong "wrong" 19 text g_prog "fn main to int\nret 0\nend\n" 20 global g_ep ulong 1 21 global g_pa uchar 4096 22 global g_pn ulong 1 23 global g_sc uchar 2048 24 global g_sn ulong 1 25 global g_om uchar 2048 26 global g_on ulong 1 27 global g_nb uchar 4096 28 global g_nn ulong 1 29 global g_arg uchar 2048 30 global g_av uchar 16384 31 global g_an ulong 2 32 global g_wo ulong 32 33 global g_wl ulong 32 34 global g_a uchar `16777216` 35 global g_b uchar `16777216` 36 global g_n ulong 8 37 global g_st uchar 4 38 global g_d uchar 24 39 fn g_init to void 40 s = ulong 0 41 k = ulong 0 42 for i ulong len g_words 43 if eq get g_words i 32 44 put g_wo k s 45 put g_wl k sub i s 46 k = add k 1 47 s = add i 1 48 end 49 end 50 end 51 fn g_path k ulong scratch bool to void 52 n = ulong 0 53 if scratch 54 for i ulong get g_sn 0 bound 2048 55 put g_pa i get g_sc i 56 end 57 n = get g_sn 0 58 put g_pa n 47 59 n = add n 1 60 end 61 s = get g_wo k 62 for i ulong get g_wl k bound 4096 63 put g_pa add n i get g_words add s i 64 end 65 put g_pn 0 add n get g_wl k 66 end 67 fn g_open flags int mode int to int 68 fd = fopen g_pa 0 get g_pn 0 flags mode 69 if lt fd 0 70 exit 2 71 end 72 ret int fd 73 end 74 fn g_load which bool to ulong 75 fd = g_open 0 0 76 n = ulong 0 77 while lt n len g_a bound `16777217` 78 x = long 0 79 if which 80 x = read fd g_a n sub len g_a n 81 else 82 x = read fd g_b n sub len g_b n 83 end 84 if lt x 0 85 exit 2 86 end 87 if eq x 0 88 r = fclose fd 89 ret n 90 end 91 n = add n ulong x 92 end 93 exit 2 94 end 95 fn g_save n ulong mode int to void 96 fd = g_open 577 mode 97 o = ulong 0 98 while lt o n bound `16777217` 99 x = write fd g_a o sub n o 100 if le x 0 101 exit 2 102 end 103 o = add o ulong x 104 end 105 r = fclose fd 106 end 107 fn g_equal n ulong m ulong to bool 108 if ne n m 109 ret false 110 end 111 for i ulong n bound `16777216` 112 if ne get g_a i get g_b i 113 ret false 114 end 115 end 116 ret true 117 end 118 fn g_clr to void 119 put g_an 0 2 120 put g_an 1 0 121 end 122 fn g_pack a view uchar 4096 n ulong to void 123 p = get g_an 0 124 put g_av p uchar and n 255 125 put g_av add p 1 uchar shr n 8 126 for i ulong n bound 4096 127 put g_av add add p 2 i get a i 128 end 129 put g_an 0 add add p 2 n 130 put g_an 1 add get g_an 1 1 131 end 132 note Global arrays cannot be arguments: copy the current path to one local argument buffer. 133 fn g_argp to void 134 a = new uchar 4096 0 135 n = get g_pn 0 136 for i ulong n bound 4096 137 put a i get g_pa i 138 end 139 g_pack a n 140 end 141 fn g_argo to void 142 for i ulong get g_on 0 bound 2048 143 put g_pa i get g_om i 144 end 145 put g_pn 0 get g_on 0 146 g_argp 147 end 148 fn g_argn to void 149 for i ulong get g_nn 0 bound 4096 150 put g_pa i get g_nb i 151 end 152 put g_pn 0 get g_nn 0 153 g_argp 154 end 155 fn g_run fi int fo int to ulong 156 g_path 5 true 157 fe = g_open 577 420 158 c = get g_an 1 159 put g_av 0 uchar and c 255 160 put g_av 1 uchar shr c 8 161 pid = fork 162 if lt pid 0 163 exit 2 164 end 165 if eq pid 0 166 r = dupfd fi 0 0 167 r = dupfd fo 1 0 168 r = dupfd fe 2 0 169 r = execprog g_av 0 get g_an 0 170 exit 127 171 end 172 r = fclose fi 173 r = fclose fo 174 r = fclose fe 175 r = waitpid int pid g_st 0 4 0 176 if ne r pid 177 exit 2 178 end 179 if ne get g_st 0 0 180 ret add 256 ulong get g_st 0 181 end 182 ret ulong get g_st 1 183 end 184 fn g_nullin to int 185 g_path 6 true 186 ret g_open 0 0 187 end 188 fn g_stdout to int 189 g_path 20 true 190 ret g_open 577 420 191 end 192 fn g_call sums bool units ulong output ulong to ulong 193 g_clr 194 g_argn 195 if sums 196 g_path 18 false 197 g_argp 198 else 199 g_path 17 false 200 g_argp 201 g_argo 202 end 203 g_path units true 204 g_argp 205 if not sums 206 g_path output true 207 g_argp 208 end 209 fi = g_nullin 210 fo = g_stdout 211 ret g_run fi fo 212 end 213 note Construct one fixture line (zero pin), from the scratch path k. append at offset n. 214 fn g_line n ulong k ulong to ulong 215 for i ulong len g_zero 216 put g_a add n i get g_zero i 217 end 218 p = add n len g_zero 219 g_path k true 220 for i ulong get g_pn 0 bound 4096 221 put g_a add p i get g_pa i 222 end 223 p = add p get g_pn 0 224 put g_a p 10 225 ret add p 1 226 end 227 fn g_fixture n ulong to void 228 g_path 6 true 229 g_save n 420 230 end 231 fn g_num n ulong to void 232 if ge n 10 233 g_num div n 10 234 end 235 put g_d 0 uchar add 48 rem n 10 236 r = write 1 g_d 0 1 237 end 238 fn g_check id ulong ok bool to void 239 put g_n 2 add get g_n 2 1 240 if ok 241 r = write 1 g_case 0 len g_case 242 else 243 put g_n 1 add get g_n 1 1 244 r = write 1 g_bad 0 len g_bad 245 end 246 g_num id 247 r = write 1 g_nl 0 len g_nl 248 end 249 note Every refusal must happen before output or its source is created; stdout must be empty and stderr 250 note must begin with ngbuild: (not a runtime trap). OMC is real, so a surviving refusal would compile. 251 note Independent exact diagnostics; the fixture digest is GNU sha256sum of g_prog. 252 fn g_et k ulong to void 253 s = ulong 0 254 c = ulong 0 255 for i ulong len g_exp 256 if eq get g_exp i 124 257 if eq c k 258 p = get g_ep 0 259 for j ulong sub i s bound 512 260 put g_b add p j get g_exp add s j 261 end 262 put g_ep 0 add p sub i s 263 ret 264 end 265 s = add i 1 266 c = add c 1 267 end 268 end 269 end 270 fn g_etpath k ulong to void 271 g_path k true 272 p = get g_ep 0 273 for i ulong get g_pn 0 bound 4096 274 put g_b add p i get g_pa i 275 end 276 put g_ep 0 add p get g_pn 0 277 end 278 fn g_exact id ulong n ulong to bool 279 put g_ep 0 0 280 if eq id 4 281 g_et 0 282 g_etpath 9 283 end 284 if eq id 5 285 g_et 1 286 g_etpath 9 287 end 288 if eq id 6 289 g_et 1 290 g_etpath 8 291 end 292 if or or eq id 7 eq id 8 ge id 17 293 g_et 2 294 end 295 if eq id 9 296 g_et 3 297 end 298 if eq id 10 299 g_et 4 300 end 301 if eq id 11 302 g_et 5 303 g_etpath 6 304 end 305 if or eq id 12 eq id 13 306 g_et 5 307 g_etpath 7 308 end 309 if eq id 14 310 g_et 6 311 g_etpath 7 312 g_et 7 313 end 314 p = get g_ep 0 315 put g_b p 10 316 ret g_equal n add p 1 317 end 318 fn g_refuse id ulong expected ulong to void 319 g_path 3 true 320 r = unlink g_pa 0 get g_pn 0 321 g_path 4 true 322 r = unlink g_pa 0 get g_pn 0 323 x = g_call false 6 3 324 ok = eq x expected 325 g_path 3 true 326 if ge faccess g_pa 0 get g_pn 0 0 0 327 ok = false 328 end 329 g_path 4 true 330 if ge faccess g_pa 0 get g_pn 0 0 0 331 ok = false 332 end 333 g_path 20 true 334 n = g_load true 335 if ne n 0 336 ok = false 337 end 338 g_path 5 true 339 n = g_load true 340 if not g_exact id n 341 ok = false 342 end 343 g_check id ok 344 end 345 note first birth, independent of ngbuild and ngbuild.units: exact two-unit join, no separators 346 fn g_birth to void 347 g_path 13 false 348 n = g_load true 349 g_path 14 false 350 m = g_load false 351 for i ulong m bound `16777216` 352 put g_a add n i get g_b i 353 end 354 g_path 12 true 355 g_save add n m 420 356 g_clr 357 g_argo 358 g_path 12 true 359 fi = g_open 0 0 360 g_path 0 true 361 fo = g_open 577 493 362 if ne g_run fi fo 0 363 exit 3 364 end 365 g_path 0 true 366 n = get g_pn 0 367 for i ulong n bound 4096 368 put g_nb i get g_pa i 369 end 370 put g_nn 0 n 371 end 372 fn g_self to void 373 g_clr 374 g_argn 375 g_path 17 false 376 g_argp 377 g_argo 378 g_path 15 false 379 g_argp 380 g_path 1 true 381 g_argp 382 fi = g_nullin 383 fo = g_stdout 384 x = g_run fi fo 385 g_check 1 eq x 0 386 if ne x 0 387 exit 1 388 end 389 g_path 0 true 390 n = g_load true 391 g_path 1 true 392 m = g_load false 393 g_check 2 g_equal n m 394 g_path 12 true 395 n = g_load true 396 g_path 2 true 397 m = g_load false 398 g_check 3 g_equal n m 399 end 400 fn g_tests wrong bool to void 401 note missing unit 402 a = g_line 0 9 403 g_fixture a 404 ex = ulong 5 405 if wrong 406 ex = 0 407 end 408 g_refuse 4 ex 409 note duplicate path, checked before reading either missing unit 410 a = g_line 0 9 411 a = g_line a 9 412 g_fixture a 413 g_refuse 5 8 414 note duplicate pin under two distinct paths 415 a = g_line 0 9 416 a = g_line a 8 417 g_fixture a 418 g_refuse 6 8 419 note malformed lowercase digest 420 a = g_line 0 9 421 put g_a 0 71 422 g_fixture a 423 g_refuse 7 4 424 note missing final newline 425 a = g_line 0 9 426 g_fixture sub a 1 427 g_refuse 8 4 428 note empty list 429 g_fixture 0 430 g_refuse 9 4 431 note 65 entries checked before duplicate detection 432 a = ulong 0 433 for i ulong 65 434 a = g_line a 9 435 end 436 g_fixture a 437 g_refuse 10 9 438 note oversize UNITS, one byte over the 65536-byte bound 439 for i ulong 65537 440 put g_a i 65 441 end 442 g_fixture 65537 443 g_refuse 11 9 444 note oversize unit, at the 16 MiB file buffer bound: sparse fixture, never allocated on disk 445 g_path 7 true 446 fd = g_open 577 420 447 r = ftrunc fd `16777216` 448 r = fclose fd 449 a = g_line 0 7 450 g_fixture a 451 g_refuse 12 9 452 note total input at `8388608` bytes, one over omc's accepted size 453 g_path 7 true 454 r = truncate g_pa 0 get g_pn 0 `8388608` 455 a = g_line 0 7 456 g_fixture a 457 g_refuse 13 9 458 note wrong pin on a small readable unit 459 g_path 7 true 460 for i ulong len g_prog 461 put g_a i get g_prog i 462 end 463 g_save len g_prog 420 464 a = g_line 0 7 465 g_fixture a 466 g_refuse 14 3 467 note sums prints the measured pin, then build takes that manifest and compiles the valid program 468 note into out, so the self-built ngbuild2 and ngbuild2.src of cases 2 and 3 stay for inspection. 469 x = g_call true 6 3 470 g_check 15 eq x 0 471 g_path 20 true 472 n = g_load true 473 g_fixture n 474 x = g_call false 6 3 475 g_check 16 eq x 0 476 note embedded NUL path refused by parser, not host-word trap 477 a = g_line 0 9 478 put g_a 65 0 479 g_fixture a 480 g_refuse 17 4 481 note path of 4096 bytes refused before copying into nb_p 482 for i ulong 4096 483 put g_a add 65 i 65 484 end 485 for i ulong 64 486 put g_a i 48 487 end 488 put g_a 64 32 489 put g_a 4161 10 490 g_fixture 4162 491 g_refuse 18 4 492 note attempted ordering metadata is not in the format (cycles have no representation) 493 for i ulong len g_prog 494 put g_a i get g_prog i 495 end 496 g_fixture len g_prog 497 g_refuse 19 4 498 end 499 fn main to int 500 if or lt argcnt 3 gt argcnt 4 501 ret 2 502 end 503 g_init 504 n = argread 1 g_om 0 len g_om 505 m = argread 2 g_sc 0 len g_sc 506 if or le n 0 le m 0 507 ret 2 508 end 509 put g_on 0 ulong n 510 put g_sn 0 ulong m 511 r = makedir g_sc 0 ulong m 493 512 note empty units fixture is also the harmless stdin for all child tools 513 g_fixture 0 514 g_birth 515 g_self 516 wrong = false 517 if eq argcnt 4 518 n = argread 3 g_arg 0 len g_arg 519 if eq n long len g_wrong 520 wrong = true 521 for i ulong len g_wrong 522 if ne get g_arg i get g_wrong i 523 wrong = false 524 end 525 end 526 end 527 if not wrong 528 if le n 0 529 ret 2 530 end 531 for i ulong ulong n bound 2048 532 put g_nb i get g_arg i 533 end 534 put g_nn 0 ulong n 535 end 536 end 537 g_tests wrong 538 if ne get g_n 1 0 539 r = write 1 g_fail 0 len g_fail 540 ret 1 541 end 542 r = write 1 g_pass 0 len g_pass 543 ret 0 544 end