Clients connect over a Unix socket, are handed a shared buffer, draw into it and commit; Schcom composites and presents. Both of the hard blockers its README listed -- unix domain sockets and raw input events -- have been done for a while, so nothing was in the way. The model is Wayland's, on purpose. A surface is not a window: it is a rectangle of pixels with no policy attached, because placement belongs to SchWM and the moment this program starts deciding where windows go the split has failed. Nothing is shown until COMMIT, so a client halfway through drawing is never presented. The compositor tells clients when to draw rather than letting them render frames nobody sees. Wayland is MIT-licensed and supporting it later is intended, so the divergences are the ones that are cheap to undo: a buffer handle is a System V shm id rather than an fd over SCM_RIGHTS, and the message carries a handle_kind field so switching is a new value rather than a protocol break. Every message carries its own length, so an unknown message is skipped instead of desynchronising the stream -- which is what lets a v0 compositor survive a v1 client. The compositor owns the shm segment, not the client: it has to survive a client crashing mid-frame, and it must not be something a client can resize underneath it. A dropped connection takes its surfaces and their segments with it. Composites into a back buffer and copies once, because compositing straight into the framebuffer shows every intermediate state -- the flicker would be the whole desktop being repainted under the user's eyes. projects/ gets build glue for the first time: `make projects` builds against the sysroot's libc and stages into sysroot/bin. It is not a dependency of anything above it, and `make` never descends there. Verified by `make schcom-test`, which boots SchOS, runs the compositor and a client, screendumps the framebuffer and asserts the pixels on the host. That last part is the point -- the compositor reporting that it composited something proves nothing, and a screenshot nobody inspects proves less. It checks the client's colour mid-surface, the compositor's background, and the white border exactly at the requested origin, so "arrived" and "arrived at the wrong offset" cannot pass for each other. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
117 lines
3.6 KiB
Shell
117 lines
3.6 KiB
Shell
#!/bin/sh
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Run Schcom and a client inside SchOS, then check the actual pixels from the
|
|
# host with QEMU's screendump. The host has no connection to the compositor, so
|
|
# it is a real oracle: if the block is the right colour in the right place, the
|
|
# buffer really was shared, composited and presented.
|
|
#
|
|
# One display device on purpose (-vga std, no virtio-gpu): with two, screendump
|
|
# captures whichever QEMU considers active, which need not be the one /dev/fb0
|
|
# maps.
|
|
set -e
|
|
BUILD=${BUILD:-build}
|
|
mkdir -p "$BUILD"
|
|
|
|
LOG=$BUILD/schcom-test.log
|
|
PPM=${1:-$BUILD/schcom.ppm}
|
|
rm -f "$LOG" "$PPM"
|
|
|
|
PORT=$(python3 - <<'EOF'
|
|
import socket
|
|
s=socket.socket(); s.bind(('127.0.0.1',0)); print(s.getsockname()[1]); s.close()
|
|
EOF
|
|
)
|
|
|
|
(
|
|
sleep 26
|
|
printf 'schcom --frames 8 &\n'; sleep 6
|
|
printf 'schcom-demo --colour 0x00C04020 --at 100 80 --size 240 160 --wait 25\n'; sleep 14
|
|
printf '\n'
|
|
sleep 40
|
|
) | timeout -k 5 120 qemu-system-x86_64 \
|
|
-machine pc-i440fx-9.2 -cpu qemu64,+rdtscp \
|
|
-hda schos.img -hdb build/schfs.img -m 1G -smp 1 \
|
|
-display none -vga std \
|
|
-monitor tcp:127.0.0.1:$PORT,server,nowait \
|
|
-chardev stdio,id=c0,logfile="$LOG" -serial chardev:c0 \
|
|
>/dev/null 2>&1 &
|
|
QPID=$!
|
|
|
|
# Wait until the client says it committed, then photograph.
|
|
for i in $(seq 1 60); do
|
|
grep -aq 'committed' "$LOG" 2>/dev/null && break
|
|
sleep 1
|
|
done
|
|
sleep 2
|
|
|
|
python3 - "$PORT" "$PPM" <<'EOF'
|
|
import socket, sys, time
|
|
port, ppm = int(sys.argv[1]), sys.argv[2]
|
|
s = socket.create_connection(('127.0.0.1', port), timeout=10)
|
|
time.sleep(0.5)
|
|
s.sendall(b'screendump ' + ppm.encode() + b'\n')
|
|
time.sleep(2.0)
|
|
s.close()
|
|
EOF
|
|
|
|
sleep 1
|
|
kill -9 $QPID 2>/dev/null || true
|
|
wait 2>/dev/null || true
|
|
|
|
echo "=== guest output ==="
|
|
sed 's/\x1b\[[0-9;=]*[A-Za-z]//g' "$LOG" | tr -d '\r' | grep -aE 'schcom|surface|committed|listening' | head -12
|
|
|
|
echo "=== pixel check (host oracle) ==="
|
|
python3 - "$PPM" <<'EOF'
|
|
import sys
|
|
path = sys.argv[1]
|
|
try:
|
|
data = open(path, 'rb').read()
|
|
except FileNotFoundError:
|
|
print("FAIL: no screendump produced"); sys.exit(1)
|
|
|
|
# Binary PPM: P6, whitespace-separated width height maxval, then RGB triples.
|
|
def token(buf, i):
|
|
while buf[i:i+1].isspace(): i += 1
|
|
j = i
|
|
while not buf[j:j+1].isspace(): j += 1
|
|
return buf[i:j], j
|
|
|
|
if data[:2] != b'P6':
|
|
print("FAIL: not a P6 PPM"); sys.exit(1)
|
|
i = 2
|
|
w, i = token(data, i); h, i = token(data, i); mx, i = token(data, i)
|
|
w, h = int(w), int(h)
|
|
px = data[i+1:]
|
|
print(f" screendump {w}x{h}")
|
|
|
|
def at(x, y):
|
|
o = (y*w + x)*3
|
|
return px[o], px[o+1], px[o+2]
|
|
|
|
def near(got, want, tol=8):
|
|
return all(abs(a-b) <= tol for a, b in zip(got, want))
|
|
|
|
fails = 0
|
|
inside = at(150, 120) # middle of the 240x160 block at 100,80
|
|
if near(inside, (0xC0, 0x40, 0x20)):
|
|
print(f" [ok] surface pixel at 150,120 is {inside} -- the client's colour")
|
|
else:
|
|
print(f" FAIL: 150,120 is {inside}, expected (192, 64, 32)"); fails += 1
|
|
|
|
desktop = at(20, 20) # compositor background 0x203040
|
|
if near(desktop, (0x20, 0x30, 0x40)):
|
|
print(f" [ok] desktop pixel at 20,20 is {desktop} -- compositor background")
|
|
else:
|
|
print(f" FAIL: 20,20 is {desktop}, expected (32, 48, 64)"); fails += 1
|
|
|
|
border = at(100, 80) # top-left of the surface: white border
|
|
if near(border, (0xFF, 0xFF, 0xFF)):
|
|
print(f" [ok] border pixel at 100,80 is {border} -- surface landed exactly")
|
|
else:
|
|
print(f" FAIL: 100,80 is {border}, expected white border"); fails += 1
|
|
|
|
print("schcom end-to-end: PASSED" if not fails else f"schcom end-to-end: {fails} FAILED")
|
|
sys.exit(1 if fails else 0)
|
|
EOF
|