Boot signed Xlib, font encoding and Pixman libraries in Vinix
@@ -22,3 +22,9 @@ To reproduce it, supply the two original sidecars, per-architecture inventories
2222```sh
2323v run tests/x11/release-elf.v "$release_assets" "$reference_apks" "$new_output"
2424```
25+
26+## Signed packages in a Vinix guest
27+
28+The x86-64 client test booted Vinix with ten PGP-validated packages, including libX11, libfontenc and Pixman. `client.v` parsed a signed X geometry, mapped the Latin-9 euro character to Unicode and copied a one-pixel ARGB image through Pixman. All three checks passed. Its additional `--display` mode performs a pixmap readback against a running X server.
29+
30+The font test installed `mkfontscale` and both bitmap font packages by name. The cold install ran the pacman hook inside the target root and produced 766 owned file and link paths across twelve signed packages. Inside Vinix, `font-index.v` ran the installed hook’s command with the cursor font present, removed and restored. It verified the header count, the cursor entry and the fixed-font entry. Both QEMU runs used one vCPU and 384 MiB. Receipts and serial transcripts are under `~/.local/state/vinix/ports/musl-busybox-CqkBEA/xorg/worker/{x11-client-guest-04,font-index-guest-02}`.
@@ -0,0 +1,83 @@
1+// With --display, also round-trip a pixel through the running X server.
2+module main
3+
4+import os
5+
6+#include <X11/Xlib.h>
7+#include <X11/Xutil.h>
8+#include <X11/fonts/fontenc.h>
9+#include <pixman.h>
10+#pkgconfig pixman-1
11+#flag -lX11
12+#flag -lfontenc
13+
14+fn C.XParseGeometry(&char, &int, &int, &u32, &u32) int
15+fn C.FontEncMapFind(&char, int, int, int, &char) voidptr
16+fn C.FontEncRecode(u32, voidptr) u32
17+fn C.pixman_image_create_bits(u32, int, int, &u32, int) voidptr
18+fn C.pixman_image_composite32(int, voidptr, voidptr, voidptr, int, int, int, int, int, int, int, int)
19+fn C.pixman_image_unref(voidptr) int
20+fn C.XOpenDisplay(&char) voidptr
21+fn C.XDefaultScreen(voidptr) int
22+fn C.XRootWindow(voidptr, int) u64
23+fn C.XDefaultDepth(voidptr, int) int
24+fn C.XWhitePixel(voidptr, int) u64
25+fn C.XCreatePixmap(voidptr, u64, u32, u32, u32) u64
26+fn C.XCreateGC(voidptr, u64, u64, voidptr) voidptr
27+fn C.XSetForeground(voidptr, voidptr, u64) int
28+fn C.XFillRectangle(voidptr, u64, voidptr, int, int, u32, u32) int
29+@[typedef]
30+struct C.XImage {}
31+
32+fn C.XGetImage(voidptr, u64, int, int, u32, u32, u64, int) &C.XImage
33+fn C.XGetPixel(&C.XImage, int, int) u64
34+fn C.XDestroyImage(&C.XImage) int
35+fn C.XFreeGC(voidptr, voidptr) int
36+fn C.XFreePixmap(voidptr, u64) int
37+fn C.XCloseDisplay(voidptr) int
38+
39+fn display_pixel() {
40+ display := C.XOpenDisplay(unsafe { nil })
41+ assert display != unsafe { nil }
42+ defer { C.XCloseDisplay(display) }
43+ screen := C.XDefaultScreen(display)
44+ pixmap := C.XCreatePixmap(display, C.XRootWindow(display, screen), 1, 1,
45+ u32(C.XDefaultDepth(display, screen)))
46+ defer { C.XFreePixmap(display, pixmap) }
47+ gc := C.XCreateGC(display, pixmap, 0, unsafe { nil })
48+ defer { C.XFreeGC(display, gc) }
49+ white := C.XWhitePixel(display, screen)
50+ C.XSetForeground(display, gc, white)
51+ C.XFillRectangle(display, pixmap, gc, 0, 0, 1, 1)
52+ image := C.XGetImage(display, pixmap, 0, 0, 1, 1, ~u64(0), C.ZPixmap)
53+ assert image != unsafe { nil }
54+ defer { C.XDestroyImage(image) }
55+ assert C.XGetPixel(image, 0, 0) == white
56+ println('X server pixmap round-trip passed.')
57+}
58+
59+fn main() {
60+ zero := unsafe { C.malloc(0) }
61+ assert zero != unsafe { nil }
62+ unsafe { C.free(zero) }
63+ mut x, mut y := 0, 0
64+ mut w, mut h := u32(0), u32(0)
65+ assert C.XParseGeometry(c'=17x9-2+3', &x, &y, &w, &h) & C.XNegative != 0
66+ assert x == -2 && y == 3 && w == 17 && h == 9
67+ mapping := C.FontEncMapFind(c'iso8859-15', C.FONT_ENCODING_UNICODE, 0, 0, unsafe { nil })
68+ assert mapping != unsafe { nil }
69+ assert C.FontEncRecode(0xa4, mapping) == 0x20ac
70+ mut input := u32(0xff3388cc)
71+ mut output := u32(0)
72+ src := C.pixman_image_create_bits(C.PIXMAN_a8r8g8b8, 1, 1, &input, 4)
73+ dst := C.pixman_image_create_bits(C.PIXMAN_a8r8g8b8, 1, 1, &output, 4)
74+ assert src != unsafe { nil } && dst != unsafe { nil }
75+ defer { C.pixman_image_unref(src) }
76+ defer { C.pixman_image_unref(dst) }
77+ C.pixman_image_composite32(C.PIXMAN_OP_SRC, src, unsafe { nil }, dst, 0, 0, 0, 0, 0, 0, 1, 1)
78+ assert output == input
79+ println('Xlib geometry, Latin-9 font mapping and Pixman pixel copy passed.')
80+ if os.args[1..] == ['--display'] {
81+ display_pixel()
82+ }
83+}