Brian Sheedy | 51f1a2965 | 2022-08-10 01:35:09 | [diff] [blame] | 1 | # WebGPU CTS Harness Message Protocol |
| 2 | |
| 3 | The WebGPU conformance test suite harness makes use of a websocket connection to |
| 4 | pass information between the Python and JavaScript code. This document outlines |
| 5 | all valid message types, when they should be sent, etc. All messages are JSON |
| 6 | objects with at least a `type` field that differentiates message types from each |
| 7 | other. |
| 8 | |
| 9 | ## TEST_STARTED |
| 10 | |
| 11 | ### Description |
| 12 | |
| 13 | A message sent exactly once by the JavaScript code once it starts running the |
| 14 | requested test. In addition to serving as an ack, it also sends information |
| 15 | about how the test will be run. |
| 16 | |
| 17 | Sending 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 | |
| 45 | A message sent periodically zero or more times by the JavaScript code to |
| 46 | prevent the Python test harness from timing out. |
| 47 | |
| 48 | Sending a message of this type before TEST_STARTED or after TEST_STATUS is |
| 49 | considered 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 | |
| 67 | A message sent exactly once when the actual test is completed. Contains |
| 68 | information about the status/result of the test. |
| 69 | |
| 70 | Sending more than one message of this type or sending before TEST_STARTED is |
| 71 | considered 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 | |
| 94 | A message sent one or more times containing test logs. Multiple messages will be |
| 95 | sent if a single message would exceed the max payload size, in which case the |
| 96 | Python test harness will concatenate them together in the order received. |
| 97 | |
| 98 | Sending 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 | |
| 118 | A message sent exactly once after all other messages have been sent. This |
| 119 | signals to the Python test harness that it should stop listening for any |
| 120 | additional messages and proceed with test cleanup. |
| 121 | |
| 122 | Sending a message of this type before TEST_LOG is considered an error. Sending |
| 123 | more than one message of this type is erroneous, but will not be caught until |
| 124 | the 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 | ``` |