blob: 836f25f381e3ca9c226170cc44972a007d80525b [file] [log] [blame] [view]
Brian Sheedy51f1a29652022-08-10 01:35:091# WebGPU CTS Harness Message Protocol
2
3The WebGPU conformance test suite harness makes use of a websocket connection to
4pass information between the Python and JavaScript code. This document outlines
5all valid message types, when they should be sent, etc. All messages are JSON
6objects with at least a `type` field that differentiates message types from each
7other.
8
9## TEST_STARTED
10
11### Description
12
13A message sent exactly once by the JavaScript code once it starts running the
14requested test. In addition to serving as an ack, it also sends information
15about how the test will be run.
16
17Sending more than one message of this type during a test is considered an error.
18
19### Fields
20
21* `type` - A string denoting the message type
22* `adapter_info` - An optional object containing the same information as the
23 [GpuAdapterInfo] the test will be using
24
25[GpuAdapterInfo]: https://gpuweb.github.io/gpuweb/#gpu-adapterinfo
26
27### Example
28
29```
30{
31 'type': 'TEST_STARTED',
32 'adapter_info': {
33 'vendor': 'NVIDIA',
34 'architecture': 'Turing',
35 'device': '2184',
36 'description': 'GTX 1660',
37 },
38}
39```
40
41## TEST_HEARTBEAT
42
43### Description
44
45A message sent periodically zero or more times by the JavaScript code to
46prevent the Python test harness from timing out.
47
48Sending a message of this type before TEST_STARTED or after TEST_STATUS is
49considered an error.
50
51### Fields
52
53* `type` - A string denoting the message type
54
55### Example
56
57```
58{
59 'type': 'TEST_HEARTBEAT',
60}
61```
62
63## TEST_STATUS
64
65### Description
66
67A message sent exactly once when the actual test is completed. Contains
68information about the status/result of the test.
69
70Sending more than one message of this type or sending before TEST_STARTED is
71considered an error.
72
73### Fields
74
75* `type` - As string denoting the message type
76* `status` - A string containing the status of the test, e.g. `skip` or `fail`
77* `js_duration_ms` - An int containing the number of milliseconds the
78 JavaScript code took to run the test
79
80### Example
81
82```
83{
84 'type': 'TEST_STATUS',
85 'status': 'fail',
86 'js_duration_ms': 243,
87}
88```
89
90## TEST_LOG
91
92### Description
93
94A message sent one or more times containing test logs. Multiple messages will be
95sent if a single message would exceed the max payload size, in which case the
96Python test harness will concatenate them together in the order received.
97
98Sending a message of this type before TEST_STATUS is considered an error.
99
100### Fields
101
102* `type` - A string denoting the message type
103* `log` - A string containing log content output by the test
104
105### Example
106
107```
108{
109 'type': 'TEST_LOG',
110 'log': 'Logging is fun',
111}
112```
113
114## TEST_FINISHED
115
116### Description
117
118A message sent exactly once after all other messages have been sent. This
119signals to the Python test harness that it should stop listening for any
120additional messages and proceed with test cleanup.
121
122Sending a message of this type before TEST_LOG is considered an error. Sending
123more than one message of this type is erroneous, but will not be caught until
124the following test is run.
125
126### Fields
127
128* `type` - A string denoting the message type
129
130### Example
131
132```
133{
134 'type': 'TEST_FINISHED',
135}
136```