Wire goldens
make xserver captures from a fresh Xvfb and compares every packet with the
committed golden. Comparison is independent of the server build:
- Server-chosen values (root window, visual, colormap, interned atom,
resource IDs from the client's resource base, extension opcodes and
event/error bases) are listed per golden by field offset in
serverFields. -update records their capture-time values in
testdata/golden/xvfb-roles.json. Compare mode checks that the golden holds
the recorded value and the live packet holds the live server's value, masks
both, then compares the remaining bytes exactly. Server timestamps are
masked without a value check.
ListExtensions and Render QueryPictFormats replies depend on how the
server was built (extension list, visuals, formats), so live compare
checks invariants: framing, counts matching list lengths, the bound
extensions present, the root visual mapped to the format CreatePicture uses.
Unit tests still decode the committed goldens byte-exactly. The test is
skipped when Xvfb is not installed. XTURBO_XVFB_ARGS adds Xvfb options to
simulate another server layout, e.g. XTURBO_XVFB_ARGS="-extension GLX".
Screen size and depth (800x600x24) and the bound extensions are capture
inputs and must stay as captured. Rewrite the goldens from the repository
root with:
PATH="$PATH:/usr/sbin" go test -tags xserver ./internal/xtest -update
The local /usr/sbin/xtrace is glibc's program execution tracer, not the X11
protocol proxy. The permitted fallback uses a raw Unix socketpair tee connected
to a fresh Xvfb server. A small independent reference encoder (not the generated
bindings) sends the requests; the tee records their actual bytes. GetGeometry's
successful response also establishes that the preceding MapWindow was accepted.
The captured target is the root window; XFIXES's major opcode is negotiated.
Tests read target/opcode from the fixture, not a hard-coded server assignment.
No runtime Conn is needed at this phase.
The same run also writes reply goldens (<Name>.reply.hex): the server's
response to each reference request, read back through the tee. Events and
runtime integration belong to their subsequent tasks.
T2.4 adds InternAtom, ChangeProperty and XRes QueryClientIds. A GetProperty
read-back validates the property contents. XRes's major opcode is negotiated;
QueryVersion 1.2 precedes the ClientIdSpec-list query. The capture is independent
of generated code, including counts, framing, and padding.
T2.5 adds ConfigureWindow with empty, sparse and all-seven-bit masks,
CreateWindow, ChangeWindowAttributes and Render CreatePicture. The reference
encoder creates sibling windows, exercises signed coordinates and both BOOL32
values, and fences void requests with a successful reply (any preceding error
fails capture). RENDER's opcode and the root visual's picture format are queried
from Xvfb. Tests reuse only server-assigned resource/format IDs from fixtures;
mask bits, values and ordering remain independent expected inputs.
T2.6 keeps the replies to QueryExtension, xfixes QueryVersion, GetGeometry,
InternAtom, GetProperty, res QueryClientIds and render QueryPictFormats, and
adds GetWindowAttributes (child window), QueryTree (root), an unset WM_NAME
GetProperty (zero-length value) and ListExtensions (variable STR list). These
reply-only requests use opcodes outside the request-golden classifier.
Generated FuzzParse*Reply targets seed from every matching reply golden.
T2.7 adds event and error goldens (<Name>.event.hex, <Name>.error.hex).
The tee client selects SubstructureRedirect/Notify and PropertyChange on the
root plus XFIXES selection input; a second raw client (not teed) creates, maps,
configures, unmaps and destroys a window, writes a root property, sends a
format-32 ClientMessage and takes PRIMARY. ConvertSelection of an unowned
SECONDARY yields a core SelectionNotify. GetAtomName, GetWindowAttributes and
XFIXES DestroyRegion on bad IDs yield BadAtom, BadWindow and BadRegion. Each
batch is fenced by a GetInputFocus reply; unexpected packets fail capture.
KeymapNotify and GeGeneric (XGE framing with a tail) are hand-written
(# hand:): Xvfb produces neither for these clients.
source
1# Wire goldens
2
3`make xserver` captures from a fresh Xvfb and compares every packet with the
4committed golden. Comparison is independent of the server build:
5
6- Server-chosen values (root window, visual, colormap, interned atom,
7 resource IDs from the client's resource base, extension opcodes and
8 event/error bases) are listed per golden by field offset in
9 `serverFields`. `-update` records their capture-time values in
10 `testdata/golden/xvfb-roles.json`. Compare mode checks that the golden holds
11 the recorded value and the live packet holds the live server's value, masks
12 both, then compares the remaining bytes exactly. Server timestamps are
13 masked without a value check.
14- `ListExtensions` and Render `QueryPictFormats` replies depend on how the
15 server was built (extension list, visuals, formats), so live compare
16 checks invariants: framing, counts matching list lengths, the bound
17 extensions present, the root visual mapped to the format CreatePicture uses.
18
19Unit tests still decode the committed goldens byte-exactly. The test is
20skipped when Xvfb is not installed. `XTURBO_XVFB_ARGS` adds Xvfb options to
21simulate another server layout, e.g. `XTURBO_XVFB_ARGS="-extension GLX"`.
22Screen size and depth (800x600x24) and the bound extensions are capture
23inputs and must stay as captured. Rewrite the goldens from the repository
24root with:
25
26```
27PATH="$PATH:/usr/sbin" go test -tags xserver ./internal/xtest -update
28```
29
30The local `/usr/sbin/xtrace` is glibc's program execution tracer, not the X11
31protocol proxy. The permitted fallback uses a raw Unix socketpair tee connected
32to a fresh Xvfb server. A small independent reference encoder (not the generated
33bindings) sends the requests; the tee records their actual bytes. GetGeometry's
34successful response also establishes that the preceding MapWindow was accepted.
35The captured target is the root window; XFIXES's major opcode is negotiated.
36Tests read target/opcode from the fixture, not a hard-coded server assignment.
37No runtime Conn is needed at this phase.
38
39The same run also writes reply goldens (`<Name>.reply.hex`): the server's
40response to each reference request, read back through the tee. Events and
41runtime integration belong to their subsequent tasks.
42
43T2.4 adds InternAtom, ChangeProperty and XRes QueryClientIds. A GetProperty
44read-back validates the property contents. XRes's major opcode is negotiated;
45QueryVersion 1.2 precedes the ClientIdSpec-list query. The capture is independent
46of generated code, including counts, framing, and padding.
47
48T2.5 adds ConfigureWindow with empty, sparse and all-seven-bit masks,
49CreateWindow, ChangeWindowAttributes and Render CreatePicture. The reference
50encoder creates sibling windows, exercises signed coordinates and both BOOL32
51values, and fences void requests with a successful reply (any preceding error
52fails capture). RENDER's opcode and the root visual's picture format are queried
53from Xvfb. Tests reuse only server-assigned resource/format IDs from fixtures;
54mask bits, values and ordering remain independent expected inputs.
55
56T2.6 keeps the replies to QueryExtension, xfixes QueryVersion, GetGeometry,
57InternAtom, GetProperty, res QueryClientIds and render QueryPictFormats, and
58adds GetWindowAttributes (child window), QueryTree (root), an unset WM_NAME
59GetProperty (zero-length value) and ListExtensions (variable STR list). These
60reply-only requests use opcodes outside the request-golden classifier.
61Generated `FuzzParse*Reply` targets seed from every matching reply golden.
62
63T2.7 adds event and error goldens (`<Name>.event.hex`, `<Name>.error.hex`).
64The tee client selects SubstructureRedirect/Notify and PropertyChange on the
65root plus XFIXES selection input; a second raw client (not teed) creates, maps,
66configures, unmaps and destroys a window, writes a root property, sends a
67format-32 ClientMessage and takes PRIMARY. ConvertSelection of an unowned
68SECONDARY yields a core SelectionNotify. GetAtomName, GetWindowAttributes and
69XFIXES DestroyRegion on bad IDs yield BadAtom, BadWindow and BadRegion. Each
70batch is fenced by a GetInputFocus reply; unexpected packets fail capture.
71`KeymapNotify` and `GeGeneric` (XGE framing with a tail) are hand-written
72(`# hand:`): Xvfb produces neither for these clients.