Repository navigation
638 lines (632 loc) · 41 KB
/
Copy pathci.yml
File metadata and controls
638 lines (632 loc) · 41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
name: CI
# What this workflow asserts about the ok format's reference implementation.
#
# images images are built once, on one machine, for each architecture:
# freestanding C, linked by an ordinary linker, noted and checked by
# okld; one is signed. libokld's cryptography holds against the
# published vectors. The binding list is generated from the
# specification's SURFACE.txt at every build (run/build.mcpp).
# An okb of both architectures is written by `okld bundle', checked by
# `okld bundle check' and by the ZIP tools; libokld's digests, ZIP
# reader and writer and manifest reader hold against their vectors.
# run THE SAME BYTES run on every system of their architecture through
# okrun built there --- arguments, thread-local storage, a callback
# into the image, an image another needs --- and the refusals hold:
# an unsigned image where a signature is required, a changed byte,
# an untrusted key. The okb runs through okrun and from memory; a
# program of the system calls an image's library through libokrun
# and through the binding openkal-bind generates, and the binding's
# refusals hold. An image at its base, anywhere and unplaced
# observes the same memory (0.4.0). Asked to end, okrun names the
# openkal call each task of an image waits in, then ends the
# program as the request would have (0.7.0). Under a debugger
# continued to the end, the program ends as the image ends it
# (0.7.1).
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
XLINGS_VERSION: v2026.10.26.1
XLINGS_NON_INTERACTIVE: '1'
# 2026.11.10.1: openkal-run binds the interfaces its implementation provides
# (MCPP_KERNEL_ABI_INTERFACES).
# 0.6.3: 2026.11.13.1, the floor of openkal-run (the core runner, by `cfg(interface)').
MCPP_VERSION: 2026.11.13.1
LLVM: llvm@23.1.3
jobs:
images:
name: images (built once)
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: Install xlings and mcpp
run: |
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s "$XLINGS_VERSION"
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"
- name: mcpp and LLVM
run: |
xlings update
xlings install "mcpp@$MCPP_VERSION" -y -g
mcpp --version
test "$(mcpp --version)" = "mcpp $MCPP_VERSION"
mcpp self config --mirror GLOBAL
mcpp toolchain install llvm 23.1.3
mcpp toolchain default "$LLVM"
- name: libokld against the published vectors
run: (cd ld && mcpp test)
# The run `mcpp test` kept (ld/target/mtest): this job's report in its
# summary, and the store for the workflow run's report (`report`).
- uses: ./.github/actions/test-report
if: always()
with:
name: mtest-images
- name: Debugger object bounds and failed-admission ownership
run: python3 .github/scripts/check-debugger-contract.py --cxx "$HOME/.mcpp/registry/data/xpkgs/xim-x-llvm/23.1.3/bin/clang++"
- name: okld
run: |
(cd tools && mcpp build --release)
echo "OKLD=$(find "$PWD/target" -path '*bin*' -name okld -type f | head -1)" >> "$GITHUB_ENV"
- name: The images
run: |
bin="$HOME/.mcpp/registry/data/xpkgs/xim-x-llvm/23.1.3/bin"
export CLANG="$bin/clang" LLD="$bin/ld.lld"
mkdir -p out
for arch in x86_64 aarch64; do
mkdir -p "out/$arch"
bash examples/build-image.sh "$arch" "out/$arch/hello.oke" examples/hello/app.c
# The declarations are compiled from the public specification the
# tools resolved: any patch of its minor version (openkal clause 8),
# 0.26 since 0.7.0.
spec=$(find "$HOME/.mcpp" -path '*openkal*0.26.*/include/openkal/process.h' -type f | sort -V | tail -1)
test -n "$spec"
CPATH="${spec%/openkal/process.h}" bash examples/build-image.sh "$arch" "out/$arch/process-unit.oke" examples/process-unit/app.c
bash examples/build-image.sh "$arch" "out/$arch/liboktwice.okso" examples/needed/lib.c
bash examples/build-image.sh "$arch" "out/$arch/needed.oke" examples/needed/app.c -- "out/$arch/liboktwice.okso"
# A weak import requires no interface (SPEC 12.4).
req=$(bash examples/build-image.sh "$arch" "out/$arch/weak.oke" examples/weak/app.c | grep 'requires')
echo "$req"
grep -q 'openkal.stream' <<<"$req" && ! grep -q 'openkal.net' <<<"$req" \
|| { echo "::error::a weak import made the image require its interface"; exit 1; }
# 6 MiB of frames on the main thread, the runner's on Windows (0.5.2).
bash examples/build-image.sh "$arch" "out/$arch/stack.oke" examples/stack/app.c
# The convention's floating-point state at the entry and in a context (0.5.3).
bash examples/build-image.sh "$arch" "out/$arch/fpstate.oke" examples/fpstate/app.c
# Tasks that wait when the program is asked to end (0.7.0).
bash examples/build-image.sh "$arch" "out/$arch/ending.oke" examples/ending/app.c
# An image that ends the program itself, through kal_exit (0.7.1).
bash examples/build-image.sh "$arch" "out/$arch/exits.oke" examples/exits/app.c
# An image that starts images, itself and exits.oke, each entered by
# the runner's loader, and a program of the system as given (0.7.1).
CPATH="${spec%/openkal/process.h}" bash examples/build-image.sh "$arch" "out/$arch/starts.oke" examples/starts/app.c
cp "out/$arch/starts.oke" "out/$arch/signed-starts.oke"
# An image that starts a context in a copy of itself, whose context
# ends the copy with kal_exit (0.7.2, #44).
CPATH="${spec%/openkal/process.h}" bash examples/build-image.sh "$arch" "out/$arch/forks.oke" examples/forks/app.c
cp "out/$arch/hello.oke" "out/$arch/signed.oke"
# The library examples/bind binds for a program of each system.
bash examples/build-image.sh "$arch" "out/$arch/libmathlib.okso" examples/bind/mathlib/image/mathlib.c
# 8 MiB of the file's bytes, and a sleep: what stays resident once it is loaded.
bash examples/build-image.sh "$arch" "out/$arch/resident.oke" examples/resident/app.c
# Mapping the first touched block succeeds on Windows; its later
# sub-64-KiB tail is refused. It must be copied without rewriting
# the first read-only mapping (the large-image startup regression).
bash examples/build-image.sh "$arch" "out/$arch/mapped-tail.oke" examples/mapped-tail/app.c
python3 examples/mapped-tail/check-layout.py "out/$arch/mapped-tail.oke"
printf '{"touches":[{"image":"mapped-tail.oke","offset":0}]}\n' > mapped-tail-touch.json
"$OKLD" touch "out/$arch/mapped-tail.oke" mapped-tail-touch.json
"$OKLD" check "out/$arch/mapped-tail.oke"
bash examples/build-image.sh "$arch" "out/$arch/prof.oke" examples/prof/app.c
# AT ITS BASE (0.4.0): every image here is placed by build-image.sh;
# this one is also left unplaced, its placement note empty.
bash examples/build-image.sh "$arch" "out/$arch/placed.oke" examples/placed/app.c
PLACE=0 bash examples/build-image.sh "$arch" "out/$arch/unplaced.oke" examples/placed/app.c
# A SNAPSHOT OF THE INITIALISERS (0.4.0): an image whose C library
# takes part, and one whose initialiser asks for the time.
bash examples/build-image.sh "$arch" "out/$arch/snapshot.oke" examples/snapshot/app.c
bash examples/build-image.sh "$arch" "out/$arch/snapshot-timed.oke" examples/snapshot/timed.c
"$OKLD" inspect "out/$arch/placed.oke" | awk '$1 == "placement" { sub(",", "", $2); print $2 }' > "out/$arch/placed.base"
grep -q '^0x' "out/$arch/placed.base" || { echo "::error::okld place stated no base"; exit 1; }
"$OKLD" inspect "out/$arch/unplaced.oke" | grep -q '^placement *none' \
|| { echo "::error::an image left unplaced states a placement"; exit 1; }
# Placed again, the same base and the same bytes.
cp "out/$arch/placed.oke" again.oke
"$OKLD" place again.oke
cmp again.oke "out/$arch/placed.oke" || { echo "::error::placing a placed image changed it"; exit 1; }
# A changed byte of a stored segment is refused by the checker.
python3 -c "import sys; d=bytearray(open(sys.argv[1],'rb').read()); d[-1]^=1; open(sys.argv[2],'wb').write(d)" \
"out/$arch/placed.oke" changed.oke
if "$OKLD" check changed.oke 2> changed-placement.txt; then echo "::error::a changed stored segment passed okld check"; exit 1; fi
grep -q "SPEC 12.4" changed-placement.txt
done
# i386 (0.6.3): read, placed and checked here; a runner of i386 runs
# them where it is built (openkal-platform's row i686-openkal).
mkdir -p out/i686
bash examples/build-image.sh i686 out/i686/hello.oke examples/hello/app.c
bash examples/build-image.sh i686 out/i686/liboktwice.okso examples/needed/lib.c
bash examples/build-image.sh i686 out/i686/needed.oke examples/needed/app.c -- out/i686/liboktwice.okso
"$OKLD" inspect out/i686/hello.oke | grep -q '^architecture *i686$' \
|| { echo "::error::an i386 image is not named i686"; exit 1; }
"$OKLD" bundle i386.okb --version 0.1.0 out/x86_64/hello.oke out/i686/hello.oke
"$OKLD" bundle check i386.okb | grep -q 'i686 (1 image(s))'
"$OKLD" keygen "$RUNNER_TEMP/seed" > out/key.hex
for arch in x86_64 aarch64; do
"$OKLD" sign "out/$arch/signed.oke" "$RUNNER_TEMP/seed"
"$OKLD" sign "out/$arch/signed-starts.oke" "$RUNNER_TEMP/seed"
"$OKLD" inspect "out/$arch/signed.oke"
# The signature is over the stored segments too: placed, then signed.
if "$OKLD" place "out/$arch/signed.oke" 2> signed-place.txt; then echo "::error::a signed image was placed"; exit 1; fi
grep -q "place it, then sign it" signed-place.txt
python3 -c "import sys; d=bytearray(open(sys.argv[1],'rb').read()); d[len(d)//2]^=1; open(sys.argv[2],'wb').write(d)" \
"out/$arch/signed.oke" "out/$arch/tampered.oke"
done
# THE OKB: both architectures in one file.
"$OKLD" bundle out/hello.okb --version 0.1.2 out/x86_64/hello.oke out/aarch64/hello.oke
"$OKLD" bundle out/resident.okb out/x86_64/resident.oke out/aarch64/resident.oke
"$OKLD" bundle out/mapped-tail.okb out/x86_64/mapped-tail.oke out/aarch64/mapped-tail.oke
"$OKLD" bundle out/needed.okb --entry needed.oke \
out/x86_64/needed.oke out/x86_64/liboktwice.okso out/aarch64/needed.oke out/aarch64/liboktwice.okso
# COMPRESSED (okb 2, 0.4.0): the economy form, its images DEFLATE.
"$OKLD" bundle out/needed-z.okb --compress --entry needed.oke \
out/x86_64/needed.oke out/x86_64/liboktwice.okso out/aarch64/needed.oke out/aarch64/liboktwice.okso
"$OKLD" bundle check out/needed-z.okb
python3 - out/needed-z.okb <<'PY'
import json, sys, zipfile
z = zipfile.ZipFile(sys.argv[1])
assert z.testzip() is None
for i in z.infolist():
want = 8 if i.filename.endswith(('.oke', '.okso')) else 0
assert i.compress_type == want, (i.filename, i.compress_type)
assert json.loads(z.read('okb.json'))['okb'] == 2
print(' ok a compressed okb: its images DEFLATE, its manifest stored, version 2')
PY
python3 - out/needed-z.okb out/tampered-z.okb <<'PY'
import sys, zipfile
d = bytearray(open(sys.argv[1], 'rb').read())
i = zipfile.ZipFile(sys.argv[1]).getinfo('x86_64/liboktwice.okso')
import struct
n, e = struct.unpack('<HH', d[i.header_offset + 26:i.header_offset + 30])
d[i.header_offset + 30 + n + e + i.compress_size // 2] ^= 1
i = zipfile.ZipFile(sys.argv[1]).getinfo('aarch64/liboktwice.okso')
n, e = struct.unpack('<HH', d[i.header_offset + 26:i.header_offset + 30])
d[i.header_offset + 30 + n + e + i.compress_size // 2] ^= 1
open(sys.argv[2], 'wb').write(d)
PY
if "$OKLD" bundle check out/tampered-z.okb 2> tampered-z.txt; then echo "::error::a changed compressed okb passed bundle check"; exit 1; fi
cat tampered-z.txt
"$OKLD" bundle out/signed.okb --sign "$RUNNER_TEMP/seed" --entry needed.oke \
out/x86_64/needed.oke out/x86_64/liboktwice.okso out/aarch64/needed.oke out/aarch64/liboktwice.okso
# From a universal package mcpp staged (mcpp-package.json, SPEC-014 §4.5).
python3 examples/package/stage.py staged out
"$OKLD" bundle out/package.okb --package staged/tree
cp -R staged/tree staged/changed
printf 'x' >> staged/changed/lib/x86_64/needed.oke
if "$OKLD" bundle out/changed.okb --package staged/changed 2> changed.txt; then echo "::error::a package whose image is not its stated content was bundled"; exit 1; fi
grep -q "mcpp-package.json states" changed.txt
for okb in hello needed signed package; do "$OKLD" bundle check "out/$okb.okb"; done
"$OKLD" bundle check out/signed.okb --require-signature --trust "$(cat out/key.hex)"
if "$OKLD" bundle check out/hello.okb --require-signature 2> unsigned.txt; then echo "::error::an unsigned okb passed --require-signature"; exit 1; fi
grep -q "not signed" unsigned.txt
# Any ZIP tool reads it; every image member begins at a multiple of 64 KiB.
python3 - out/needed.okb <<'PY'
import struct, sys, zipfile
z = zipfile.ZipFile(sys.argv[1])
assert z.testzip() is None
d = open(sys.argv[1], 'rb').read()
for i in z.infolist():
assert i.compress_type == zipfile.ZIP_STORED, i.filename
n, e = struct.unpack('<HH', d[i.header_offset + 26:i.header_offset + 30])
if i.filename.endswith(('.oke', '.okso')):
assert (i.header_offset + 30 + n + e) % 65536 == 0, i.filename
print(' ok the okb is a ZIP archive, stored, its images aligned to 64 KiB')
PY
unzip -t out/needed.okb
# A changed byte inside an image member.
python3 - out/needed.okb out/tampered.okb <<'PY'
import struct, sys, zipfile
d = bytearray(open(sys.argv[1], 'rb').read())
i = zipfile.ZipFile(sys.argv[1]).getinfo('x86_64/liboktwice.okso')
n, e = struct.unpack('<HH', d[i.header_offset + 26:i.header_offset + 30])
d[i.header_offset + 30 + n + e + 100] ^= 1
i = zipfile.ZipFile(sys.argv[1]).getinfo('aarch64/liboktwice.okso')
n, e = struct.unpack('<HH', d[i.header_offset + 26:i.header_offset + 30])
d[i.header_offset + 30 + n + e + 100] ^= 1
open(sys.argv[2], 'wb').write(d)
PY
if "$OKLD" bundle check out/tampered.okb 2> tampered.txt; then echo "::error::a changed okb passed bundle check"; exit 1; fi
grep -q "sha256" tampered.txt
(cd out && sha256sum */*.oke */*.okso *.okb | tee SHA256SUMS)
- uses: actions/upload-artifact@v4
with: { name: images, path: out/ }
run:
name: run (${{ matrix.host }})
needs: images
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- { host: linux-x86_64, os: ubuntu-24.04, arch: x86_64 }
- { host: linux-aarch64, os: ubuntu-24.04-arm, arch: aarch64 }
- { host: macos-arm64, os: macos-15, arch: aarch64 }
- { host: windows-x86_64, os: windows-2022, arch: x86_64 }
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with: { name: images, path: out }
- name: Install xlings (Unix)
if: runner.os != 'Windows'
run: |
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s "$XLINGS_VERSION"
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"
- name: Install xlings (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
irm https://d2learn.org/xlings-install.ps1.txt | iex
"$env:USERPROFILE\.xlings\subos\current\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: okrun, built here
run: |
xlings update
xlings install "mcpp@$MCPP_VERSION" -y -g
mcpp --version
test "$(mcpp --version)" = "mcpp $MCPP_VERSION"
mcpp self config --mirror GLOBAL
mcpp toolchain install llvm 23.1.3
mcpp toolchain default "$LLVM"
# libokld's vectors on this machine: SHA-256 runs on its own instructions
# where it has them (the SHA extensions here, ARMv8's on macOS arm64).
(cd ld && mcpp test)
(cd tools && mcpp build --release)
okrun=$(find "$PWD/target" -path '*bin*' \( -name okrun -o -name okrun.exe \) -type f | head -1)
[ -n "$okrun" ] || { echo "::error::okrun did not build"; exit 1; }
echo "OKRUN=$okrun" >> "$GITHUB_ENV"
okld=$(find "$PWD/target" -path '*bin*' \( -name okld -o -name okld.exe \) -type f | head -1)
echo "OKLD_HOST=$okld" >> "$GITHUB_ENV"
okprof=$(find "$PWD/target" -path '*bin*' \( -name okprof -o -name okprof.exe \) -type f | head -1)
[ -n "$okprof" ] || { echo "::error::okprof did not build"; exit 1; }
echo "OKPROF=$okprof" >> "$GITHUB_ENV"
- uses: ./.github/actions/test-report
if: always()
with:
name: mtest-run-${{ matrix.host }}
- name: okprof forwards environment values and the child's status
run: |
python=python3; [ "$RUNNER_OS" = Windows ] && python=python
"$python" tools/tests/record_env.py --okprof "$OKPROF"
- name: A request to end names the call each task waits in (0.7.0)
run: |
# Asked to end (SIGTERM; a console's CTRL_BREAK_EVENT on Windows),
# okrun writes the openkal call each task of the image waits in, then
# ends the program as the request would have; an image that took the
# requests over is named the same and ends by itself.
python=python3; [ "$RUNNER_OS" = Windows ] && python=python
"$python" tools/tests/end_request.py --okrun "$OKRUN" --image "out/${{ matrix.arch }}/ending.oke"
- name: Under a debugger, a program ends as its image ends it (0.7.1)
if: runner.os == 'Linux'
run: |
# GDB stopped before the end while the runner's task waits and then
# continued: the runner's task returns before the program ends, so
# each run ends normally, the image's main returning or calling kal_exit.
# The debugger is the index's static build (xim:gdb), the same on every
# Linux runner, not the distribution's the runner may or may not carry.
xlings install xim:gdb@18.1 -y -g
gdb --version | head -1
python3 tools/tests/debugger_end.py --okrun "$OKRUN" --images "out/${{ matrix.arch }}"
- name: An image starts images, each entered by the runner (0.7.1)
run: |
# An image file an image starts is entered through the loader the
# runner names, with the runner's signature requirements, and observes
# the vector its starter gave; a program of the system is started as
# given (openkal-image#42). Under 0.7.0 the image's start of itself
# ended by SIGSEGV on Linux.
# The program of the system is named in the system's spelling: the
# vector reaches it as given, and cmd.exe given its own name as
# `C:/Windows/System32/cmd.exe' answered `The syntax of the command
# is incorrect.' (run 44538697059). The image's lines are printed
# before they are judged.
a='${{ matrix.arch }}'
if [ "$RUNNER_OS" = Windows ]; then native=('C:\Windows\System32\cmd.exe' /c "exit 5"); else native=(/bin/sh -c "exit 5"); fi
out=$({ MSYS_NO_PATHCONV=1 "$OKRUN" "out/$a/starts.oke" "${native[@]}" || true; } | tr -d '\r')
echo "$out"
grep -qx "starts: ok" <<<"$out" || { echo "::error::an image's start of an image, or of a program of the system"; exit 1; }
# Signed, under a signature requirement: itself starts, and the
# unsigned exits.oke is refused by its reason, kal_err_permission (6).
out=$({ "$OKRUN" --require-signature --trust "$(cat out/key.hex)" "out/$a/signed-starts.oke" || true; } | tr -d '\r')
echo "$out"
grep -qx "starts: itself 7" <<<"$out" && grep -qx "starts: exits.oke -1006" <<<"$out" \
|| { echo "::error::the runner's signature requirements reach the image it starts"; exit 1; }
echo " ok an image starts images through the runner, and a program of the system as given"
- name: A copy of the program ends as the copy ends itself (0.7.2)
if: runner.os == 'Linux'
run: |
# A library composes fork by starting a context in a copy of the
# address space (openkal.space); the copy holds the runner's memory
# and not the runner's task. Under 0.7.1 the copy's kal_exit waited
# for that task's return and never ended (#44, Sunrisepeak/cmd#5).
# The limit makes a copy that does not end a failure, not a hang.
out=$({ timeout 60 "$OKRUN" "out/${{ matrix.arch }}/forks.oke" || echo "status $?"; } | tr -d '\r')
echo "$out"
grep -qx "forks: 7" <<<"$out" || { echo "::error::a copy of the program did not end as it ended itself"; exit 1; }
echo " ok a copy of the program ends with its own status"
- name: The same bytes
run: |
a='${{ matrix.arch }}'
if command -v sha256sum > /dev/null; then (cd out && sha256sum -c --ignore-missing SHA256SUMS)
else (cd out && shasum -a 256 -c --ignore-missing SHA256SUMS); fi
unit=$("$OKRUN" "out/$a/process-unit.oke" | tr -d '\r')
test "$unit" = 'observable unit image: ok'
out=$("$OKRUN" "out/$a/hello.oke" one two | tr -d '\r')
echo "$out"
grep -q "argc as kal_env_arg_count = 3" <<<"$out" || { echo "::error::the image's arguments"; exit 1; }
grep -q "mix = 204" <<<"$out" || { echo "::error::the calling convention"; exit 1; }
grep -q "tls main=1 ctx1=10 ctx2=20" <<<"$out" || { echo "::error::thread-local storage or the callback"; exit 1; }
# A RELATIVE NAME THAT CLIMBS (0.6.2): `..' above the working
# directory folds against its name and opens through the supplied
# directory that then holds it; `./' beside it and an absolute name
# already ran.
mkdir -p rel/below
(cd rel/below && "$OKRUN" ../../"out/$a/hello.oke" one | tr -d '\r' \
| grep -q "argc as kal_env_arg_count = 2") \
|| { echo "::error::a relative image name with .. was not opened"; exit 1; }
echo " ok a relative name that climbs opens the image"
# A NAME WITH EMPTY COMPONENTS (0.6.4): `//' and `/./' in an absolute
# name, as a build system's joined paths carry them, fold lexically.
abs="$PWD"; [ "$RUNNER_OS" = Windows ] && abs=$(cygpath -m "$PWD")
"$OKRUN" "$abs//out/./$a//hello.oke" one | tr -d '\r' | grep -q "argc as kal_env_arg_count = 2" \
|| { echo "::error::an absolute image name with // was not opened"; exit 1; }
(cd rel/below && "$OKRUN" "..//..//out/$a/hello.oke" one | tr -d '\r' \
| grep -q "argc as kal_env_arg_count = 2") \
|| { echo "::error::a relative image name with // was not opened"; exit 1; }
echo " ok a name with empty components opens the image"
n=$("$OKRUN" "out/$a/needed.oke" | tr -d '\r')
echo "$n"
grep -q "twice(21) = 42, next_value() = 41" <<<"$n" || { echo "::error::an image another needs"; exit 1; }
# THE MAIN THREAD HAS A THREAD'S STACK (0.5.2): on Windows the runner's
# reservation, which was the linker's 1 MiB default.
st=$("$OKRUN" "out/$a/stack.oke" | tr -d '\r')
test "$st" = 'stack: 6 MiB on the main thread' || { echo "::error::the image's main thread has less than a thread's stack: $st"; exit 1; }
# THE CONVENTION'S FLOATING-POINT STATE (0.5.3): on Windows a thread
# begins with the x87 at double precision.
fp=$("$OKRUN" "out/$a/fpstate.oke" | tr -d '\r')
test "$fp" = "fp: the convention's at the entry, the convention's in a context" || { echo "::error::the image's floating-point state: $fp"; exit 1; }
w=$("$OKRUN" "out/$a/weak.oke" | tr -d '\r')
echo "$w"
grep -q "weak: openkal.net bound" <<<"$w" || { echo "::error::a weak import the implementation provides was not bound"; exit 1; }
# A MEASUREMENT AND THE NAME OF AN ADDRESS (0.2). Unmeasured, the
# image is told so and the loader names its function; measured, the
# report holds its calls, its counter and its phase.
p=$("$OKRUN" "out/$a/prof.oke" | tr -d '\r')
echo "$p"
grep -q "prof: not measured" <<<"$p" || { echo "::error::an unmeasured image was told it is measured"; exit 1; }
grep -q "debug: prof_named_function" <<<"$p" || { echo "::error::the loader did not name the image's function"; exit 1; }
rm -rf prof && mkdir prof
# A directory relative to the working one: under Git Bash `$(pwd)` is
# an MSYS spelling (/d/a/...), which a Windows program does not open.
"$OKRUN" "--prof=calls,counters:prof" "out/$a/prof.oke" > prof.out
grep -q "prof: measured" prof.out || { echo "::error::a measured image was told it is not"; exit 1; }
report=$(ls prof/okprof-*.json | head -1)
[ -n "$report" ] || { echo "::error::a measured image wrote no report"; exit 1; }
cat "$report"
grep -q '"example.widgets", "value": 42' "$report" || { echo "::error::the counter was not read"; exit 1; }
grep -q '"example.phase", "count": 2' "$report" || { echo "::error::the phase was not counted"; exit 1; }
grep -q '"kal_stream_write", "count": ' "$report" || { echo "::error::the calls were not counted"; exit 1; }
"$OKPROF" report prof | tee okprof.out
grep -q "openkal.stream" okprof.out || { echo "::error::okprof report did not group the calls by interface"; exit 1; }
- name: A refused mapping tail preserves the earlier read-only run
run: |
set -euo pipefail
for image in "out/${{ matrix.arch }}/mapped-tail.oke" out/mapped-tail.okb; do
"$OKRUN" "$image" | tr -d '\r' | grep -q '^mapped tail: bytes intact$'
done
- name: At its base (0.4.0)
run: |
# Placed where the implementation places memory where it is asked
# (KAL_EXEC_PROP_PLACE): at this boot's base for the image, its data
# prepared once for that base in the runner's cache; at the base
# `okld place' chose (OKRUN_PLACE=sealed), its relative relocations
# already in its bytes. Anywhere (OKRUN_PLACE=0), and an image left
# unplaced: relocated. What the image prints is the same.
a='${{ matrix.arch }}'
base=$(cat "out/$a/placed.base")
export OKRUN_CACHE="$RUNNER_TEMP/okplaced"
mkdir -p "$OKRUN_CACHE"
"$OKRUN" "out/$a/placed.oke" | tr -d '\r' > local.txt
"$OKRUN" "out/$a/placed.oke" | tr -d '\r' > again.txt
OKRUN_PLACE=sealed "$OKRUN" "out/$a/placed.oke" | tr -d '\r' > placed.txt
OKRUN_PLACE=0 "$OKRUN" "out/$a/placed.oke" | tr -d '\r' > anywhere.txt
"$OKRUN" "out/$a/unplaced.oke" | tr -d '\r' > unplaced.txt
cat local.txt placed.txt anywhere.txt unplaced.txt
ls "$OKRUN_CACHE"
grep -qx "base $base" placed.txt || { echo "::error::the image was not placed at the base it states ($base)"; exit 1; }
if grep -qx "base $base" anywhere.txt; then echo "::error::OKRUN_PLACE=0 placed the image at its base"; exit 1; fi
local=$(sed -n 's/^base //p' local.txt)
b=$((local))
(( b % 65536 == 0 && b >= (1 << 44) && b < (1 << 45) )) \
|| { echo "::error::this boot's base $local is not one the runner chooses"; exit 1; }
grep -qx "base $local" again.txt || { echo "::error::a second start of the boot chose another base"; exit 1; }
ls "$OKRUN_CACHE"/*.okseg > /dev/null || { echo "::error::no data was prepared for this boot's base"; exit 1; }
for f in local placed anywhere unplaced; do grep -v '^base ' "$f.txt" > "$f.out"; done
cmp local.out placed.out && cmp placed.out anywhere.out && cmp placed.out unplaced.out \
|| { echo "::error::an image at its base observes other memory"; exit 1; }
for want in "the table holds its text" "the entry is the implementation's" "written two one"; do
grep -q "placed: $want" placed.out || { echo "::error::at its base: $want"; exit 1; }
done
echo " ok an image at its base, anywhere, and unplaced observes the same memory"
- name: A snapshot of the initialisers (0.4.0)
run: |
# The first start runs the initialiser and has a snapshot made beside
# it; the next starts from it. A named value the initialiser read,
# set otherwise, and OKRUN_SNAPSHOT=0 start by the initialiser again;
# an initialiser that asks for the time is refused a snapshot, and the
# marker says so.
a='${{ matrix.arch }}'
export OKRUN_CACHE="$RUNNER_TEMP/okcache"
mkdir -p "$OKRUN_CACHE"
run() { "$OKRUN" "out/$a/$1.oke" | tr -d '\r'; }
expect() { grep -q "$2" <<<"$1" || { echo "::error::$3"; echo "$1"; exit 1; }; }
out=$(run snapshot); expect "$out" 'started by its initialisers' 'the first start ran no initialiser'
run snapshot-timed > /dev/null
for i in $(seq 100); do
n=$(cat "$OKRUN_CACHE"/*.sealing 2>/dev/null | grep -c '^made\|^refused' || true)
[ "$n" -ge 2 ] && break; sleep 0.1
done
cat "$OKRUN_CACHE"/*.sealing
grep -q '^made' "$OKRUN_CACHE"/*.sealing || { echo "::error::no snapshot was made"; exit 1; }
grep -q 'refused: an initialiser asked for kal_time_monotonic' "$OKRUN_CACHE"/*.sealing \
|| { echo "::error::the initialiser that asked for the time was not refused"; exit 1; }
rm -rf snapprof && mkdir snapprof
out=$(OKRUN_PROF=phases:snapprof run snapshot); echo "$out"
cat snapprof/*.json | tr -d '\r' | sed -n '/"runner"/,/]/p'
expect "$out" 'started from the snapshot' 'the second start did not start from the snapshot'
expect "$out" 'the memory is filled' 'the snapshot holds other memory'
out=$(OKIMG_SNAPSHOT_NAME=set run snapshot)
expect "$out" 'started by its initialisers' 'a start whose named value differs used the snapshot'
expect "$out" 'the name is set' 'the initialiser read another value'
out=$(OKRUN_SNAPSHOT=0 run snapshot); expect "$out" 'started by its initialisers' 'OKRUN_SNAPSHOT=0 used the snapshot'
out=$(run snapshot-timed); expect "$out" 'started by its initialisers' 'an image refused a snapshot started from one'
echo " ok a snapshot is made once, used, compared, declined and refused"
# WHAT THE RUNNER KEEPS (0.4.0): listed, and an economy start writes
# nothing to it.
"$OKRUN" cache | tee cache.txt
grep -q '\.oksnap' cache.txt || { echo "::error::okrun cache lists no snapshot"; exit 1; }
export OKRUN_CACHE="$RUNNER_TEMP/okcache-economy"
mkdir -p "$OKRUN_CACHE"
KAL_RESOURCES=economy "$OKRUN" "out/$a/snapshot.oke" > /dev/null
sleep 1
if ls "$OKRUN_CACHE" | grep -qv '^boot$'; then echo "::error::an economy start wrote to the cache"; ls "$OKRUN_CACHE"; exit 1; fi
"$OKRUN" cache gc --all
echo " ok okrun cache lists what it keeps; an economy start writes nothing"
- name: The refusals
run: |
a='${{ matrix.arch }}'
key=$(cat out/key.hex)
"$OKRUN" --require-signature --trust "$key" "out/$a/signed.oke" > /dev/null || { echo "::error::a signed image by a trusted key was refused"; exit 1; }
if "$OKRUN" --require-signature "out/$a/hello.oke" 2> e1.txt; then echo "::error::an unsigned image ran"; exit 1; fi
grep -q "not signed" e1.txt
if "$OKRUN" --require-signature "out/$a/tampered.oke" 2> e2.txt; then echo "::error::a changed image ran"; exit 1; fi
grep -q "does not hold" e2.txt
if "$OKRUN" --trust 00000000000000000000000000000000000000000000000000000000000000aa "out/$a/signed.oke" 2> e3.txt; then echo "::error::an untrusted key's image ran"; exit 1; fi
grep -q "not trusted" e3.txt
echo " ok unsigned, changed and untrusted images are refused, and say why"
- name: The okb, through okrun
run: |
key=$(cat out/key.hex)
out=$("$OKRUN" out/hello.okb one two | tr -d '\r')
echo "$out"
grep -q "argc as kal_env_arg_count = 3" <<<"$out" || { echo "::error::the okb's entry and arguments"; exit 1; }
n=$("$OKRUN" out/needed.okb | tr -d '\r')
grep -q "twice(21) = 42, next_value() = 41" <<<"$n" || { echo "::error::an image the okb's entry needs, from the okb"; exit 1; }
"$OKRUN" out/package.okb | tr -d '\r' | grep -q "twice(21) = 42" || { echo "::error::the okb of a staged package"; exit 1; }
"$OKRUN" --require-signature --trust "$key" out/signed.okb > /dev/null || { echo "::error::a signed okb was refused"; exit 1; }
if "$OKRUN" --require-signature out/needed.okb 2> e4.txt; then echo "::error::an unsigned okb ran under --require-signature"; exit 1; fi
grep -q "okb.json is not signed" e4.txt
if "$OKRUN" out/tampered.okb 2> e5.txt; then echo "::error::a changed okb ran"; exit 1; fi
grep -q "sha256" e5.txt
# An image the okb does not hold is found in OKRUN_PATH.
mkdir -p path/${{ matrix.arch }}
cp out/${{ matrix.arch }}/liboktwice.okso path/${{ matrix.arch }}/
"$OKLD_HOST" bundle alone.okb --entry needed.oke out/${{ matrix.arch }}/needed.oke
if "$OKRUN" alone.okb 2> e6.txt; then echo "::error::a needed image that is nowhere was found"; exit 1; fi
# The system's own spelling of a directory list: `;' and a drive on Windows.
sep=':'; here="$PWD"
if [ "$RUNNER_OS" = Windows ]; then sep=';'; here=$(pwd -W); fi
OKRUN_PATH="nowhere${sep}${here}/path" "$OKRUN" alone.okb | tr -d '\r' | grep -q "twice(21) = 42" \
|| { echo "::error::OKRUN_PATH"; exit 1; }
echo " ok the okb runs; an unsigned or changed okb is refused; OKRUN_PATH is searched"
# COMPRESSED (0.4.0): expanded once into the user's cache, then mapped
# from there; a changed byte of it is refused.
export XDG_CACHE_HOME="$RUNNER_TEMP/xdg"
for i in 1 2; do
z=$("$OKRUN" out/needed-z.okb | tr -d '\r')
grep -q "twice(21) = 42, next_value() = 41" <<<"$z" || { echo "::error::a compressed okb, start $i"; echo "$z"; exit 1; }
done
if "$OKRUN" out/tampered-z.okb 2> e7.txt; then echo "::error::a changed compressed okb ran"; exit 1; fi
cat e7.txt
echo " ok a compressed okb runs, expanded once; a changed one is refused"
- name: What stays resident once an image is loaded (Linux)
if: runner.os == 'Linux'
run: |
# The runner releases its mapping of the file it ran once the image is
# placed: while the image runs, what the process maps of the image or
# the okb is the segments that are the file's pages (0.3.0), and it
# holds the 8 MiB segment once.
for f in "out/${{ matrix.arch }}/resident.oke" out/resident.okb; do
"$OKRUN" "$f" > resident.txt & pid=$!
for i in $(seq 1 50); do grep -q loaded resident.txt 2>/dev/null && break; sleep 0.05; done
grep -q "resident: loaded" resident.txt || { echo "::error::$f did not start"; exit 1; }
maps=$(grep "resident\.ok" "/proc/$pid/maps" || true)
rss=$(awk '/^Rss:/ {print $2}' "/proc/$pid/smaps_rollup")
wait "$pid"
echo " $f: $rss KiB resident; of the file, mapped:"
echo "$maps"
if grep -q ' rw-p ' <<<"$maps"; then echo "::error::the runner still holds its mapping of $f while the image runs"; exit 1; fi
[ "$rss" -lt 14336 ] || { echo "::error::$rss KiB resident for an 8 MiB image: the file's pages beside its copy"; exit 1; }
done
echo " ok once loaded, the image is resident once: the runner's mapping of the file is released"
- name: From memory, and a library from a program of this system (libokrun)
run: |
(cd examples/host && mcpp build --release)
host=$(find "$PWD/examples/host/target" -path '*bin*' \( -name okrun-host -o -name okrun-host.exe \) -type f | head -1)
a='${{ matrix.arch }}'
"$host" library "out/$a/liboktwice.okso" | tr -d '\r' | tee lib.txt
grep -q "library: twice(21) = 42, next_value() = 41, 42" lib.txt || { echo "::error::okrun_open_library"; exit 1; }
"$host" okb out/needed.okb | tr -d '\r' | grep -q "twice(21) = 42" || { echo "::error::okrun_run_okb_bytes"; exit 1; }
"$host" images "out/$a/needed.oke" "out/$a/liboktwice.okso" | tr -d '\r' | grep -q "twice(21) = 42" || { echo "::error::okrun_run_images"; exit 1; }
# A program that names no loader: the image's start of an image file is
# refused as kal_err_not_program, and nothing is started (0.7.1).
"$host" file "out/$a/starts.oke" refused | tr -d '\r' | grep -q "refused as not a program" \
|| { echo "::error::an image's start of an image file where no loader is named"; exit 1; }
# The archive a program that carries its images holds: no okb.json,
# the images at the root, zipalign's field and bytes between members.
python3 examples/package/stage.py staged out
"$host" archive staged/carried.zip needed.oke | tr -d '\r' | grep -q "twice(21) = 42" || { echo "::error::an archive without okb.json, from memory"; exit 1; }
python3 -c "import sys; d=bytearray(open(sys.argv[1],'rb').read()); d[65536+200]^=1; open(sys.argv[2],'wb').write(d)" staged/carried.zip staged/bad.zip
if "$host" archive staged/bad.zip needed.oke 2> crc.txt; then echo "::error::a changed member ran"; exit 1; fi
grep -q "CRC-32" crc.txt
echo " ok an okb and a group of images run from memory; a library's exports are called from here"
- name: The binding openkal-bind generates
run: |
for a in x86_64 aarch64; do mkdir -p "examples/bind/mathlib/lib/$a"; cp "out/$a/libmathlib.okso" "examples/bind/mathlib/lib/$a/"; done
(cd examples/bind/app && mcpp run) | tr -d '\r' | tee bind.txt
for want in "add: 42" "scale: 6.00" "mirror: -3 7" "length: 7" "each: 4 visited, sum 10" "fp: the convention's in the image, the caller's here"; do
grep -q "$want" bind.txt || { echo "::error::the binding: $want"; exit 1; }
done
bash examples/bind/check-refusals.sh
# EVERY JOB'S TEST RUNS AS ONE REPORT (`mtest ci report`, the workflow run's
# group): libokld's vectors on the image machine and on each system.
report:
name: tests (report)
needs: [images, run]
if: ${{ always() && !cancelled() }}
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install xlings
run: |
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s "$XLINGS_VERSION"
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"
- uses: ./.github/actions/mtest
- uses: actions/download-artifact@v4
with:
pattern: mtest-*
path: stores
- name: Every job's runs, reported together
run: |
set -euo pipefail
found=0
for store in stores/*/; do
[ -f "$store/index.ndjson" ] || continue
"$MTEST" store import --from "$store"
found=1
done
[ "$found" = 1 ] || { echo "no job kept a run" >> "$GITHUB_STEP_SUMMARY"; exit 0; }
"$MTEST" ci report --group "$GITHUB_RUN_ID" --out tests.md
cat tests.md >> "$GITHUB_STEP_SUMMARY"