Repository navigation
593 lines (550 loc) · 30.7 KB
/
Copy pathci.yml
File metadata and controls
593 lines (550 loc) · 30.7 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
name: CI
# What this workflow asserts about openkal-platform.
#
# resolves every member the platform names, and every xim package a
# runner requires, is listed in the indexes mcpp reads (the
# published artifacts, not the index repositories' main); the
# other jobs need it, so a package not yet indexed is one
# failure that names it rather than one per job
# tests `mcpp test` on the platform package: the test image runs on the
# machine's architecture and is built for the other one
# image a project that declares nothing builds, runs and packs an ok
# image over this platform: the `openkal` set as one tree (vendored
# and self-contained), one target alone, a single file and an okb
# hosted the machine's own triple takes the platform's hosted arrangement
# host-graph a build program is compiled as an ok image and run by okrun
# i686 Linux's thirty-two bit row: the hosted program and the
# specification's conformance suite, run on Linux x86_64
# i686-openkal the ok image of i386, run by okrun built for i686-linux-musl
# dos a DOS program, and the i386 image carried as one (technical
# experiment only), run under DOSBox Staging through dirun
# svr4 a System V Release 4 program (i386), run under ibcs-us, an
# emulation of the kernel's interface, as each of its three interfaces
# freebsd the musl rows of FreeBSD are built here and run in a FreeBSD VM,
# with okrun built for them running an ok image there
#
# The platform is read by mcpp 2026.10.30.1 and later (SPEC-013, SPEC-015). CI
# measures with 2026.10.31.3: from 2026.10.31.2 a set's Windows launcher is built
# over the platform of mcpp's own openkal rows rather than the one a project
# selects, whose version group may name another openkal than the launcher's os.
# A dispatch, or the repository variable MCPP_SOURCE_REF, may name a branch of
# mcpp instead, which the latest released mcpp builds and which is then used.
# 0.23.0 measures with 2026.11.3.1: from it the std module is compiled with
# the platform's compile words, and this platform's `-fcf-protection=full`
# recorded in an importer's command and not in the module's refused the import
# (the release candidate, through MCPP_SOURCE_REF, until it is released).
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
inputs:
mcpp_ref:
description: "Branch of mcpp-community/mcpp to build and test with (empty = the released mcpp)"
required: false
default: ""
env:
MCPP_SOURCE_REF: ${{ github.event.inputs.mcpp_ref || vars.MCPP_SOURCE_REF || '' }}
MCPP_VERSION: 2026.11.18.1
XLINGS_VERSION: v2026.10.26.1
XLINGS_NON_INTERACTIVE: '1'
jobs:
resolves:
name: every member is in the index mcpp reads
runs-on: ubuntu-24.04
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: mcpp-community/setup-mcpp@v1
with:
version: ${{ env.MCPP_VERSION }}
xlings-version: ${{ env.XLINGS_VERSION }}
- name: Every member and runner package is in the indexes mcpp reads
run: |
mcpp index update
mcpp index status | tee status.log
synced=$(awk '$1 == "mcpplibs" { print $NF }' status.log)
xim=$(awk '$1 == "xim" { print $NF }' status.log)
[ -d "$synced" ] || { echo "::error::mcpp names no synced copy of the mcpplibs index"; exit 1; }
[ -d "$xim" ] || { echo "::error::mcpp names no synced copy of the xim index"; exit 1; }
python3 tools/family_release.py visible "$synced" --xim "$xim" | tee -a "$GITHUB_STEP_SUMMARY"
platform:
needs: resolves
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
# `host`: the machine's own triple, as a program of the hosted
# arrangement names it (a Windows host defaults to the MSVC target,
# and openkal's Windows implementation is reached through the GNU one).
- { os: ubuntu-24.04, arch: x86_64, host: '' }
- { os: ubuntu-24.04-arm, arch: aarch64, host: '' }
- { os: macos-15, arch: aarch64, host: '--target aarch64-macos' }
- { os: windows-2022, arch: x86_64, host: '--target x86_64-windows-gnu' }
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Install xlings and mcpp (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 and mcpp (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: The mcpp under cross-validation
run: |
want="mcpp@$MCPP_VERSION"
[ -n "${MCPP_SOURCE_REF:-}" ] && want=mcpp
for attempt in 1 2 3 4 5 6; do
xlings update > /dev/null 2>&1 || true
if xlings install "$want" -y -g; then break; fi
[ "$attempt" = 6 ] && { echo "::error::mcpp could not be installed"; exit 1; }
sleep 60
done
mcpp --version
mcpp self config --mirror GLOBAL
if [ -n "${MCPP_SOURCE_REF:-}" ]; then
src="$RUNNER_TEMP/mcpp-src"
git clone --quiet --depth 1 --branch "$MCPP_SOURCE_REF" https://github.com/mcpp-community/mcpp.git "$src"
rm -f "$src/.xlings.json"
( cd "$src" && mcpp build --release )
built=$(find "$src/target" -type f \( -name mcpp -o -name mcpp.exe \) -path '*/bin/*' | head -1)
[ -n "$built" ] || { echo "::error::mcpp did not build from $MCPP_SOURCE_REF"; exit 1; }
echo "$(cd "$(dirname "$built")" && pwd)" >> "$GITHUB_PATH"
echo "under review: $("$built" --version) (from $MCPP_SOURCE_REF)"
fi
- name: The platform's tests
env:
MCPP_TOOL_BUILD_VERBOSE: '1'
run: |
mcpp test -v 2>&1 | tee tests.log
grep -Eq "image_test .*ok" tests.log || { echo "::error::the test image did not run or did not pass"; exit 1; }
- name: An ok image that declares nothing (run, the set's tree, self-contained, one target, single file, okb)
working-directory: checks/image
run: |
t='${{ matrix.arch }}-openkal'
other=x86_64; [ '${{ matrix.arch }}' = x86_64 ] && other=aarch64
py=python3; command -v python3 > /dev/null 2>&1 && python3 -c '' 2>/dev/null || py=python
mcpp run --target "$t" -- one two | tee run.log
grep -q "image ok: 3 args" run.log || { echo "::error::the image's output"; exit 1; }
okrun=$(mcpp self env --target "$t" --format json | $py -c 'import json,sys; print(json.load(sys.stdin)["data"]["runner"]["program"])')
if [ "${{ runner.os }}" = Windows ]; then bin=bin/image.exe; else bin=bin/image; fi
# The `openkal` set: one tree of both architectures, the launchers, the runner on PATH.
mcpp pack --target openkal --pkg-format dir -o uni
for f in lib/x86_64/image.oke lib/aarch64/image.oke bin/image bin/image.exe mcpp-package.json; do
[ -f "target/dist/uni/$f" ] || { echo "::error::the set's tree has no $f"; exit 1; }
done
okdir=$(dirname "$okrun")
if [ "${{ runner.os }}" = Windows ]; then okdir=$(cygpath -u "$okdir"); fi
PATH="$okdir:$PATH" "target/dist/uni/$bin" one two | tee uni.log
grep -q "image ok: 3 args" uni.log || { echo "::error::the launcher's output"; exit 1; }
# Self-contained: the runner inside, nothing on PATH.
mcpp pack --target openkal --mode self-contained --pkg-format dir -o sc
"target/dist/sc/$bin" one two | tee sc.log
grep -q "image ok: 3 args" sc.log || { echo "::error::the self-contained tree's output"; exit 1; }
# One target: its architecture alone, in the same layout.
mcpp pack --target "$t" --pkg-format dir -o one
[ -f "target/dist/one/lib/${{ matrix.arch }}/image.oke" ] || { echo "::error::one target's tree has no lib/${{ matrix.arch }}/image.oke"; exit 1; }
[ -d "target/dist/one/lib/$other" ] && { echo "::error::one target packed lib/$other"; exit 1; }
PATH="$okdir:$PATH" "target/dist/one/$bin" one two | tee one-tree.log
grep -q "image ok: 3 args" one-tree.log || { echo "::error::one target's tree's output"; exit 1; }
# One file: a program of this system carrying the image.
mcpp pack --target "$t" --pkg-format single-file -o single
one=
for f in target/dist/single target/dist/single.exe; do [ -f "$f" ] && one=$f; done
[ -n "$one" ] || { echo "::error::no single file"; exit 1; }
"$one" one two | tee one.log
grep -q "image ok: 3 args" one.log || { echo "::error::the single file's output"; exit 1; }
# The okb of the set: one file of both architectures, checked and run.
mcpp pack --target openkal --pkg-format okb --message-format json > okb.json
okb=$($py -c 'import json; print(json.load(open("okb.json"))["data"]["artifacts"][0]["path"])')
okld=$(mcpp self env --target "$t" --format json | $py -c 'import json,sys; print(json.load(sys.stdin)["data"]["tools"]["okld"])')
"$okld" bundle check "$okb"
"$okrun" "$okb" one two | tee okb.log
grep -q "image ok: 3 args" okb.log || { echo "::error::the okb's output"; exit 1; }
# SEALED AT ITS BASE (0.23.0): the image states a placement, and runs
# the same placed anywhere.
image=$(find target -path "*${{ matrix.arch }}-openkal*" -path '*bin*' -name image.oke -type f | head -1)
"$okld" inspect "$image" | tee inspect.log
grep -Eq '^placement +0x[0-9a-f]+, [1-8] writable' inspect.log || { echo "::error::the sealed image states no placement"; exit 1; }
OKRUN_PLACE=0 "$okrun" "$image" one two | tee anywhere.log
grep -q "image ok: 3 args" anywhere.log || { echo "::error::the image placed anywhere"; exit 1; }
- name: Debug relocations and the selected debuggee runner
run: |
py=python3; command -v python3 > /dev/null 2>&1 && python3 -c '' 2>/dev/null || py=python
"$py" .github/scripts/check-debug-producer.py --arch '${{ matrix.arch }}'
- name: ThinLTO keeps thread-local storage emulated
working-directory: checks/lto
run: |
t='${{ matrix.arch }}-openkal'
other=x86_64; [ '${{ matrix.arch }}' = x86_64 ] && other=aarch64
mcpp run --release --target "$t" | tee lto.log
grep -q 'LTO TLS ok' lto.log || { echo "::error::LTO TLS isolation failed"; exit 1; }
mcpp build --release --target "$other-openkal"
py=python3; command -v python3 > /dev/null 2>&1 && python3 -c '' 2>/dev/null || py=python
"$py" - <<'PY'
from pathlib import Path
for arch in ('x86_64', 'aarch64'):
objects = list(Path('target', arch + '-openkal').rglob('main.o'))
if not any(p.read_bytes()[:4] == b'BC\xc0\xde' for p in objects):
raise SystemExit('no ThinLTO bitcode object for ' + arch)
PY
- name: A snapshot of a C++ program's initialisers (0.23.0)
working-directory: checks/snapshot
run: |
# The first start runs the initialisers and has a snapshot made; the
# next starts from it (its phases name the snapshot) and observes the
# same; a start whose named value the initialisers read differs runs
# them again, and observes its own value.
t='${{ matrix.arch }}-openkal'
py=python3; command -v python3 > /dev/null 2>&1 && python3 -c '' 2>/dev/null || py=python
mcpp build --release --target "$t"
okrun=$(mcpp self env --target "$t" --format json | $py -c 'import json,sys; print(json.load(sys.stdin)["data"]["runner"]["program"])')
image=$(find target -path "*$t*" -path '*bin*' -name snapshot.oke -type f | head -1)
export OKRUN_CACHE="$RUNNER_TEMP/okcache"
mkdir -p "$OKRUN_CACHE"
"$okrun" "$image" one | tr -d '\r' | tee first.log
grep -q -- '-- failures: 0 --' first.log || { echo "::error::the first start"; exit 1; }
for i in $(seq 100); do grep -qs '^made\|^refused' "$OKRUN_CACHE"/*.sealing && break; sleep 0.1; done
cat "$OKRUN_CACHE"/*.sealing
grep -q '^made' "$OKRUN_CACHE"/*.sealing || { echo "::error::no snapshot was made"; exit 1; }
rm -rf prof && mkdir prof
OKRUN_PROF=phases:prof "$okrun" "$image" two | tr -d '\r' | tee second.log
grep -q -- '-- failures: 0 --' second.log && grep -q 'local two' second.log || { echo "::error::the start from the snapshot"; exit 1; }
grep -q '"name": "snapshot"' prof/okprof-*.json || { echo "::error::the second start did not start from the snapshot"; exit 1; }
SNAPSHOT_CHECK_NAME=set "$okrun" "$image" three | tr -d '\r' | tee third.log
grep -q 'named: set' third.log && grep -q -- '-- failures: 0 --' third.log \
|| { echo "::error::a start whose named value differs observed the snapshot's"; exit 1; }
- name: The hosted arrangement
working-directory: checks/hosted
run: |
mcpp run ${{ matrix.host }} -- one two | tee run.log
grep -q "hosted ok: hosted" run.log || { echo "::error::the hosted program's output"; exit 1; }
grep -q "hosted args: 3 two" run.log || { echo "::error::the hosted program's arguments"; exit 1; }
- name: A build program as an ok image (the host graph)
working-directory: checks/host-graph
run: |
mcpp run | tee run.log
grep -q "host graph ok: 1" run.log || { echo "::error::the build program's definition did not arrive"; exit 1; }
# FREEBSD (0.26.0): the hosted arrangement's musl rows, openkal-musl over
# openkal-freebsd standalone, built here for both architectures as static
# programs; the x86_64 one runs in a FreeBSD virtual machine, beside okrun
# built for the same row from the openkal-image release this group names,
# which runs an ok image there.
# I686 (0.28.0): Linux's thirty-two bit row, which a Linux x86_64 machine runs
# itself: the hosted program, and the specification's conformance suite through
# the platform, over the implementation at the group's version.
i686:
needs: resolves
name: i686-linux-musl (built and run on Linux x86_64)
runs-on: ubuntu-24.04
timeout-minutes: 90
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: mcpp-community/setup-mcpp@v1
with:
version: ${{ env.MCPP_VERSION }}
xlings-version: ${{ env.XLINGS_VERSION }}
- name: The hosted program, thirty-two bit
working-directory: checks/hosted
run: |
mcpp run --target i686-linux-musl -- one two | tee run.log
grep -q "hosted ok: hosted" run.log || { echo "::error::the hosted program's output"; exit 1; }
grep -q "hosted args: 3 two" run.log || { echo "::error::the hosted program's arguments"; exit 1; }
p=$(find target/i686-linux-musl -path '*bin/hosted' -type f | head -1)
file "$p"
file "$p" | grep -q 'ELF 32-bit' && file "$p" | grep -q 'Intel 80386' && file "$p" | grep -q 'statically linked' \
|| { echo "::error::i686-linux-musl is not a static i386 program"; exit 1; }
- name: The specification's conformance suite
run: |
set -euo pipefail
spec=$(sed -n 's/^openkal *= *"\(.*\)"/\1/p' mcpp.toml | head -1)
impl=$(sed -n 's/^openkal-linux *= *"\(.*\)"/\1/p' mcpp.toml | head -1)
git clone --quiet --depth 1 --branch "$spec" https://github.com/mcpplibs/openkal.git .spec
git clone --quiet --depth 1 --branch "$impl" https://github.com/mcpplibs/openkal-linux.git .impl
# The platform serves the row mcpp registers as planned (mcpp 2026.11.14.1+).
bash .spec/tools/run-conformance.sh openkal-linux .impl full,optional \
--target i686-linux-musl --platform "path:$GITHUB_WORKSPACE" | tee conformance.log
grep -qE '^observations: [0-9]+ held, 0 did not hold' conformance.log \
|| { echo "::error::an observation did not hold on i686-linux-musl"; exit 1; }
uefi:
needs: resolves
name: x86_64-uefi (built on Linux x86_64, run under OVMF)
runs-on: ubuntu-24.04
timeout-minutes: 90
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: mcpp-community/setup-mcpp@v1
with:
version: ${{ env.MCPP_VERSION }}
xlings-version: ${{ env.XLINGS_VERSION }}
# The provider's runner: dirun, xim's OVMF with its profile, and QEMU, installed by the
# first run; the status returns through the board's exit.
- name: The application, built and booted
working-directory: checks/uefi
run: |
set +e
mcpp run --release --target x86_64-uefi -- one "two three" "a b" | tee run.log
status=${PIPESTATUS[0]}
set -e
grep -q 'uefi ok: \[1, 2, 3\] \["one", "two three", "a b"\]' run.log || { echo "::error::the application's output or arguments"; exit 1; }
grep -q 'files: true' run.log || { echo "::error::a file was not renamed or a listing shortened its name (release profile)"; exit 1; }
[ "$status" -eq 42 ] || { echo "::error::the application returned $status, not 42"; exit 1; }
p=$(find target/x86_64-uefi -path '*bin/uefi.efi' -type f | head -1)
file "$p"
file "$p" | grep -q 'PE32+' && file "$p" | grep -q 'EFI application' \
|| { echo "::error::x86_64-uefi is not a PE32+ EFI application"; exit 1; }
# I686-OPENKAL (0.28.0): the ok image of i386 (ELF32, REL), built from
# checks/i386 in both modes, checked by okld, and run by okrun built for
# i686-linux-musl from the openkal-image release this group names.
i686-openkal:
needs: resolves
name: i686-openkal (an ok image of i386, run on Linux x86_64)
runs-on: ubuntu-24.04
timeout-minutes: 90
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: mcpp-community/setup-mcpp@v1
with:
version: ${{ env.MCPP_VERSION }}
xlings-version: ${{ env.XLINGS_VERSION }}
- name: okrun for i686-linux-musl
run: |
tag=$(sed -n 's/^openkal-tools *= *"\(.*\)"/\1/p' mcpp.toml | head -1)
git clone --quiet --depth 1 --branch "$tag" https://github.com/mcpplibs/openkal-image.git "$RUNNER_TEMP/oi"
printf '\n[target.i686-linux-musl]\nplatform = { path = "%s" }\ntoolchain = "llvm@23.1.3"\n' "$GITHUB_WORKSPACE" >> "$RUNNER_TEMP/oi/tools/mcpp.toml"
(cd "$RUNNER_TEMP/oi/tools" && mcpp build --release --target i686-linux-musl)
okrun=$(find "$RUNNER_TEMP/oi/target/i686-linux-musl" -path '*bin/openkal-tools/okrun' -type f | head -1)
file "$okrun"
file "$okrun" | grep -q 'ELF 32-bit' || { echo "::error::okrun is not an i386 program"; exit 1; }
echo "OKRUN32=$okrun" >> "$GITHUB_ENV"
- name: The image, built, checked and run (dev and release)
working-directory: checks/i386
run: |
py=python3
for mode in "" --release; do
rm -rf target/i686-openkal
mcpp build --target i686-openkal $mode
okld=$(mcpp self env --target i686-openkal --format json | $py -c 'import json,sys; print(json.load(sys.stdin)["data"]["tools"]["okld"])')
image=$(find target/i686-openkal -path '*bin*' -name i386.oke -type f | head -1)
"$okld" check "$image"
"$okld" inspect "$image" | tee inspect.log
grep -Eq '^architecture +i686' inspect.log || { echo "::error::the image does not state i686"; exit 1; }
set +e
"$OKRUN32" "$image" two one | tee run.log
status=${PIPESTATUS[0]}
set -e
grep -q 'i386 ok: \["one", "two"\]' run.log && grep -q 'caught: across a frame' run.log \
|| { echo "::error::the image's output ($mode)"; exit 1; }
[ "$status" -eq 7 ] || { echo "::error::the image returned $status, not 7 ($mode)"; exit 1; }
done
# System V Release 4 on i386 (0.30.0): a program of i686-svr4-musl (openkal-musl
# over openkal-svr4) built in both modes and run by the provider's runner,
# ibcs-us in a user namespace; then the same executable under the two other
# interfaces the emulation has. The runs are under an emulation of the
# interface on Linux x86_64, none on a System V kernel.
svr4:
needs: resolves
name: i686-svr4-musl (built on Linux x86_64, run under ibcs-us)
runs-on: ubuntu-24.04
timeout-minutes: 60
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: mcpp-community/setup-mcpp@v1
with:
version: ${{ env.MCPP_VERSION }}
xlings-version: ${{ env.XLINGS_VERSION }}
# ibcs-us asks for the root identity and has it in a user namespace; a
# runner image whose AppArmor refuses an unprivileged one is told to allow it.
- name: The host lets an unprivileged user make a user namespace
run: |
if ! unshare -Ur true 2>/dev/null; then
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
fi
unshare -Ur true
- name: The System V program (dev and release)
working-directory: checks/svr4
run: |
for mode in "" --release; do
set +e
mcpp run --target i686-svr4-musl $mode -- two one | tee run.log
status=${PIPESTATUS[0]}
set -e
grep -q 'svr4 ok: \["one", "two"\]' run.log && grep -q 'caught: across a frame' run.log \
&& grep -q 'files: true' run.log && grep -q 'here: true' run.log \
|| { echo "::error::the System V program's output ($mode)"; exit 1; }
[ "$status" -eq 7 ] || { echo "::error::the System V program returned $status, not 7 ($mode)"; exit 1; }
done
p=$(find target/i686-svr4-musl -path '*bin/svr4' -type f | head -1)
file "$p"
file "$p" | grep -q 'ELF 32-bit LSB executable, Intel 80386.*statically linked' \
|| { echo "::error::the program is not a static ELF32 i386 executable"; exit 1; }
# 0.30.1: the kernel of System V/386 Release 4.0 kills a static program
# that has PT_PHDR, so the row's link (link/svr4.ld) writes none; the
# emulation above accepts either, and this is what holds the statement.
for q in $(find target/i686-svr4-musl -path '*bin/svr4' -type f); do
readelf -lW "$q" | tee headers.log
if grep -qE '^ +(PHDR|INTERP) ' headers.log; then echo "::error::$q has a PT_PHDR or PT_INTERP entry"; exit 1; fi
[ "$(grep -cE '^ +LOAD ' headers.log)" -eq 3 ] || { echo "::error::$q does not have three PT_LOAD segments"; exit 1; }
done
# The same executable under the interfaces the emulation is told to answer
# as: the part of the interface the program issues is the one they share.
- name: The same executable as Solaris and as OpenServer 5
working-directory: checks/svr4
run: |
# The emulator the runner installed, among the packages mcpp holds.
ibcs=$(find "$HOME/.mcpp" "$HOME/.xlings" -path '*xim-x-ibcs-us/*/bin/ibcs-us' -type f 2>/dev/null | sort | tail -1 || true)
[ -n "$ibcs" ] || { echo "::error::ibcs-us is not installed"; exit 1; }
p=$(find "$PWD/target/i686-svr4-musl" -path '*bin/svr4' -type f | head -1)
for interface in per_solaris per_osr5; do
set +e
unshare -Ur "$ibcs" -p "$interface" "$p" two one | tee "$interface.log"
status=${PIPESTATUS[0]}
set -e
grep -q 'files: true' "$interface.log" || { echo "::error::the program's output under $interface"; exit 1; }
[ "$status" -eq 7 ] || { echo "::error::the program returned $status under $interface, not 7"; exit 1; }
done
# DOS (0.28.0; technical experiment only): a program of i686-dos-musl
# (openkal-musl over openkal-dos, run under CWSDPMI) built in both modes and
# run by the provider's runner, dirun with DOSBox Staging; and the i386 ok
# image packed as one DOS program, the core runner carrying it, and run there.
dos:
needs: resolves
name: i686-dos-musl (built on Linux x86_64, run under DOSBox Staging)
runs-on: ubuntu-24.04
timeout-minutes: 90
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: mcpp-community/setup-mcpp@v1
with:
version: ${{ env.MCPP_VERSION }}
xlings-version: ${{ env.XLINGS_VERSION }}
- name: The DOS program (dev and release)
working-directory: checks/dos
run: |
for mode in "" --release; do
set +e
mcpp run --target i686-dos-musl $mode -- two one | tr -d '\r' | tee run.log
status=${PIPESTATUS[0]}
set -e
grep -q 'dos ok: \["one", "two"\]' run.log && grep -q 'caught: across a frame' run.log \
&& grep -q 'deep: 2080' run.log \
&& grep -q 'files: true' run.log \
|| { echo "::error::the DOS program's output ($mode)"; exit 1; }
[ "$status" -eq 7 ] || { echo "::error::the DOS program returned $status, not 7 ($mode)"; exit 1; }
done
p=$(find target/i686-dos-musl -path '*bin/dos.exe' -type f | head -1)
file "$p"
# The row's stack (0.29.1): the executable after the stub states 1 MiB in PT_GNU_STACK.
python3 - "$p" <<'PY'
import struct, sys
data = open(sys.argv[1], "rb").read()
at = data.find(b"\x7fELF\x01\x01")
phoff, = struct.unpack_from("<I", data, at + 28)
phentsize, phnum = struct.unpack_from("<HH", data, at + 42)
sizes = [struct.unpack_from("<6I", data, at + phoff + i * phentsize)[5]
for i in range(phnum) if struct.unpack_from("<I", data, at + phoff + i * phentsize)[0] == 0x6474E551]
print("PT_GNU_STACK memsz:", sizes)
sys.exit(0 if sizes == [1048576] else "::error::the DOS program states no 1 MiB stack")
PY
- name: The i386 image carried as a DOS program
working-directory: checks/i386
run: |
# `-o` names the file as written; DOS runs a program named .exe.
mcpp pack --target i686-openkal --pkg-format single-file --systems dos-i686 -o carried.exe
exe=target/dist/carried.exe
[ -f "$exe" ] || { echo "::error::no DOS program was packed"; ls target/dist; exit 1; }
file "$exe"
# The DOS row's runner, which the previous step installed: dirun, and
# the profile of the DOSBox Staging package beside it.
dirun=$(cd ../dos && mcpp self env --target i686-dos-musl --format json \
| python3 -c 'import json,sys; print(json.load(sys.stdin)["data"]["runner"]["program"])')
root=$(cd "$(dirname "$dirun")/../../.." && pwd)
profile=$(find "$root"/xim-x-dosbox-staging -name dirun.toml -type f | sort | tail -1)
[ -n "$dirun" ] && [ -n "$profile" ] || { echo "::error::dirun or the DOSBox profile is not installed"; exit 1; }
set +e
"$dirun" --payload "$exe" --profile "$profile" -- two one | tr -d '\r' | tee carried.log
status=${PIPESTATUS[0]}
set -e
grep -q 'i386 ok: \["one", "two"\]' carried.log || { echo "::error::the carried image's output"; exit 1; }
[ "$status" -eq 7 ] || { echo "::error::the carried image returned $status, not 7"; exit 1; }
freebsd:
needs: resolves
name: freebsd (built for x86_64 and aarch64, run in a VM)
runs-on: ubuntu-24.04
timeout-minutes: 90
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: mcpp-community/setup-mcpp@v1
with:
version: ${{ env.MCPP_VERSION }}
xlings-version: ${{ env.XLINGS_VERSION }}
- name: The musl rows, built for FreeBSD
working-directory: checks/hosted
run: |
mkdir -p ../../.fb
for a in x86_64 aarch64; do
mcpp build --target "$a-freebsd-musl"
p=$(find "target/$a-freebsd-musl" -path '*bin/hosted' -type f | head -1)
file "$p"
file "$p" | grep -q 'FreeBSD' && file "$p" | grep -q 'statically linked' \
|| { echo "::error::$a-freebsd-musl is not a static FreeBSD program"; exit 1; }
done
cp "$(find target/x86_64-freebsd-musl -path '*bin/hosted' -type f | head -1)" ../../.fb/hosted
- name: okrun for FreeBSD, and an ok image
run: |
(cd checks/image && mcpp build --target x86_64-openkal)
cp "$(find checks/image/target -path '*x86_64-openkal*' -path '*bin*' -name image.oke -type f | head -1)" .fb/image.oke
tag=$(sed -n 's/^openkal-tools *= *"\(.*\)"/\1/p' mcpp.toml | head -1)
git clone --quiet --depth 1 --branch "$tag" https://github.com/mcpplibs/openkal-image.git "$RUNNER_TEMP/oi"
printf '\n[target.x86_64-freebsd-musl]\nplatform = { path = "%s" }\ntoolchain = "llvm@23.1.3"\n' "$GITHUB_WORKSPACE" >> "$RUNNER_TEMP/oi/tools/mcpp.toml"
(cd "$RUNNER_TEMP/oi/tools" && mcpp build --release --target x86_64-freebsd-musl)
cp "$(find "$RUNNER_TEMP/oi/target/x86_64-freebsd-musl" -path '*bin/openkal-tools/okrun' -type f | head -1)" .fb/okrun
file .fb/okrun
- name: Run in FreeBSD
uses: vmactions/freebsd-vm@v1
with:
usesh: true
run: |
set -e
uname -a
./.fb/hosted one two > .fb/hosted.log 2>&1 || echo "status $?" >> .fb/hosted.log
./.fb/okrun ./.fb/image.oke one two > .fb/image.log 2>&1 || echo "status $?" >> .fb/image.log
cat .fb/hosted.log .fb/image.log
- name: The verdict
run: |
grep -q "hosted ok: hosted" .fb/hosted.log && grep -q "hosted args: 3 two" .fb/hosted.log \
|| { echo "::error::the FreeBSD musl program's output"; cat .fb/hosted.log; exit 1; }
grep -q "image ok: 3 args" .fb/image.log \
|| { echo "::error::the ok image under okrun on FreeBSD"; cat .fb/image.log; exit 1; }