diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-25 08:09:10 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-25 08:09:10 +0900 |
| commit | e77652bf89bf1f1e55174cd61a745cf13ca31e48 (patch) | |
| tree | b538f1f1422a7384f5a89a6fbecb9e3bcd8c6ce3 /internal/pipewire | |
| parent | 88d3e464136db5192e311e4be077aa3db218e5f2 (diff) | |
internal/pipewire: move test data to files
These get very big later on, and would be painful to represent as the compound literal.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire')
| -rw-r--r-- | internal/pipewire/client_test.go | 400 | ||||
| -rw-r--r-- | internal/pipewire/core_test.go | 9 | ||||
| -rw-r--r-- | internal/pipewire/header_test.go | 36 | ||||
| -rw-r--r-- | internal/pipewire/pipewire_test.go | 17 | ||||
| -rw-r--r-- | internal/pipewire/testdata/00-sendmsg00-message00-header | bin | 0 -> 16 bytes | |||
| -rw-r--r-- | internal/pipewire/testdata/01-sendmsg00-message00-POD | bin | 0 -> 24 bytes | |||
| -rw-r--r-- | internal/pipewire/testdata/02-sendmsg00-message01-header | bin | 0 -> 16 bytes | |||
| -rw-r--r-- | internal/pipewire/testdata/03-sendmsg00-message01-POD | bin | 0 -> 1536 bytes |
8 files changed, 29 insertions, 433 deletions
diff --git a/internal/pipewire/client_test.go b/internal/pipewire/client_test.go index 744c5187..d7f723eb 100644 --- a/internal/pipewire/client_test.go +++ b/internal/pipewire/client_test.go @@ -8,405 +8,7 @@ import ( func TestClientUpdateProperties(t *testing.T) { encodingTestCases[pipewire.ClientUpdateProperties, *pipewire.ClientUpdateProperties]{ - {"sample", []byte{ - // ClientUpdateProperties: size - 0xf8, 5, 0, 0, - // ClientUpdateProperties: struct - 0xe, 0, 0, 0, - - // ClientUpdateProperties.Props: size - 0xf0, 5, 0, 0, - // ClientUpdateProperties.Props: struct - 0xe, 0, 0, 0, - - // ClientUpdateProperties.Props.NItems: size - 4, 0, 0, 0, - // ClientUpdateProperties.Props.NItems: int - 4, 0, 0, 0, - 0x1e, 0, 0, 0, - 0, 0, 0, 0, - - // ClientUpdateProperties.Props.Items - - 0x11, 0, 0, 0, - 8, 0, 0, 0, - 0x72, 0x65, 0x6d, 0x6f, - 0x74, 0x65, 0x2e, 0x69, - 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x69, 0x6f, 0x6e, - 0, 0, 0, 0, - 0, 0, 0, 0, - - 8, 0, 0, 0, - 8, 0, 0, 0, - 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0, - - 0x11, 0, 0, 0, - 8, 0, 0, 0, - 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, - 0x6e, 0x61, 0x6d, 0x65, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0xd, 0, 0, 0, - 8, 0, 0, 0, - 0x70, 0x77, 0x2d, 0x63, - 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, - 0, 0, 0, 0, - 0x1b, 0, 0, 0, - 8, 0, 0, 0, - 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x63, - 0x65, 0x73, 0x73, 0x2e, - 0x62, 0x69, 0x6e, 0x61, - 0x72, 0x79, 0, 0, - 0, 0, 0, 0, - 0xd, 0, 0, 0, - 8, 0, 0, 0, - 0x70, 0x77, 0x2d, 0x63, - 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, - 0, 0, 0, 0, - 0x15, 0, 0, 0, - 8, 0, 0, 0, - 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, - 0x6c, 0x61, 0x6e, 0x67, - 0x75, 0x61, 0x67, 0x65, - 0, 0, 0, 0, - 0xc, 0, 0, 0, - 8, 0, 0, 0, - 0x65, 0x6e, 0x5f, 0x55, - 0x53, 0x2e, 0x55, 0x54, - 0x46, 0x2d, 0x38, 0, - 0, 0, 0, 0, - 0x17, 0, 0, 0, - 8, 0, 0, 0, - 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x63, - 0x65, 0x73, 0x73, 0x2e, - 0x69, 0x64, 0, 0, - 5, 0, 0, 0, - 8, 0, 0, 0, - 0x31, 0x34, 0x34, 0x33, - 0, 0, 0, 0, - 0x19, 0, 0, 0, - 8, 0, 0, 0, - 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x63, - 0x65, 0x73, 0x73, 0x2e, - 0x75, 0x73, 0x65, 0x72, - 0, 0, 0, 0, - 0, 0, 0, 0, - 6, 0, 0, 0, - 8, 0, 0, 0, - 0x61, 0x6c, 0x69, 0x63, - 0x65, 0, 0, 0, - 0x19, 0, 0, 0, - 8, 0, 0, 0, - 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x63, - 0x65, 0x73, 0x73, 0x2e, - 0x68, 0x6f, 0x73, 0x74, - 0, 0, 0, 0, - 0, 0, 0, 0, - 6, 0, 0, 0, - 8, 0, 0, 0, - 0x6e, 0x69, 0x78, 0x6f, - 0x73, 0, 0, 0, - 0x1f, 0, 0, 0, - 8, 0, 0, 0, - 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x63, - 0x65, 0x73, 0x73, 0x2e, - 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x2d, - 0x69, 0x64, 0, 0, - 2, 0, 0, 0, - 8, 0, 0, 0, - 0x31, 0, 0, 0, - 0, 0, 0, 0, - 0x13, 0, 0, 0, - 8, 0, 0, 0, - 0x77, 0x69, 0x6e, 0x64, - 0x6f, 0x77, 0x2e, 0x78, - 0x31, 0x31, 0x2e, 0x64, - 0x69, 0x73, 0x70, 0x6c, - 0x61, 0x79, 0, 0, - 0, 0, 0, 0, - 3, 0, 0, 0, - 8, 0, 0, 0, - 0x3a, 0x30, 0, 0, - 0, 0, 0, 0, - 0xc, 0, 0, 0, - 8, 0, 0, 0, - 0x63, 0x70, 0x75, 0x2e, - 0x76, 0x6d, 0x2e, 0x6e, - 0x61, 0x6d, 0x65, 0, - 0, 0, 0, 0, - 5, 0, 0, 0, - 8, 0, 0, 0, - 0x71, 0x65, 0x6d, 0x75, - 0, 0, 0, 0, - 0xa, 0, 0, 0, - 8, 0, 0, 0, - 0x6c, 0x6f, 0x67, 0x2e, - 0x6c, 0x65, 0x76, 0x65, - 0x6c, 0, 0, 0, - 0, 0, 0, 0, - 2, 0, 0, 0, - 8, 0, 0, 0, - 0x30, 0, 0, 0, - 0, 0, 0, 0, - 0xe, 0, 0, 0, - 8, 0, 0, 0, - 0x63, 0x70, 0x75, 0x2e, - 0x6d, 0x61, 0x78, 0x2d, - 0x61, 0x6c, 0x69, 0x67, - 0x6e, 0, 0, 0, - 3, 0, 0, 0, - 8, 0, 0, 0, - 0x33, 0x32, 0, 0, - 0, 0, 0, 0, - 0x13, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x63, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x72, 0x61, - 0x74, 0x65, 0, 0, - 0, 0, 0, 0, - 6, 0, 0, 0, - 8, 0, 0, 0, - 0x34, 0x38, 0x30, 0x30, - 0x30, 0, 0, 0, - 0x16, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x63, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x71, 0x75, - 0x61, 0x6e, 0x74, 0x75, - 0x6d, 0, 0, 0, - 5, 0, 0, 0, - 8, 0, 0, 0, - 0x31, 0x30, 0x32, 0x34, - 0, 0, 0, 0, - 0x1a, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x63, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x6d, 0x69, - 0x6e, 0x2d, 0x71, 0x75, - 0x61, 0x6e, 0x74, 0x75, - 0x6d, 0, 0, 0, - 0, 0, 0, 0, - 3, 0, 0, 0, - 8, 0, 0, 0, - 0x33, 0x32, 0, 0, - 0, 0, 0, 0, - 0x1a, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x63, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x6d, 0x61, - 0x78, 0x2d, 0x71, 0x75, - 0x61, 0x6e, 0x74, 0x75, - 0x6d, 0, 0, 0, - 0, 0, 0, 0, - 5, 0, 0, 0, - 8, 0, 0, 0, - 0x32, 0x30, 0x34, 0x38, - 0, 0, 0, 0, - 0x1c, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x63, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x71, 0x75, - 0x61, 0x6e, 0x74, 0x75, - 0x6d, 0x2d, 0x6c, 0x69, - 0x6d, 0x69, 0x74, 0, - 0, 0, 0, 0, - 5, 0, 0, 0, - 8, 0, 0, 0, - 0x38, 0x31, 0x39, 0x32, - 0, 0, 0, 0, - 0x1c, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x63, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x71, 0x75, - 0x61, 0x6e, 0x74, 0x75, - 0x6d, 0x2d, 0x66, 0x6c, - 0x6f, 0x6f, 0x72, 0, - 0, 0, 0, 0, - 2, 0, 0, 0, - 8, 0, 0, 0, - 0x34, 0, 0, 0, - 0, 0, 0, 0, - 0x14, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x76, 0x69, 0x64, 0x65, - 0x6f, 0x2e, 0x77, 0x69, - 0x64, 0x74, 0x68, 0, - 0, 0, 0, 0, - 4, 0, 0, 0, - 8, 0, 0, 0, - 0x36, 0x34, 0x30, 0, - 0, 0, 0, 0, - 0x15, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x76, 0x69, 0x64, 0x65, - 0x6f, 0x2e, 0x68, 0x65, - 0x69, 0x67, 0x68, 0x74, - 0, 0, 0, 0, - 4, 0, 0, 0, - 8, 0, 0, 0, - 0x34, 0x38, 0x30, 0, - 0, 0, 0, 0, - 0x17, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x76, 0x69, 0x64, 0x65, - 0x6f, 0x2e, 0x72, 0x61, - 0x74, 0x65, 0x2e, 0x6e, - 0x75, 0x6d, 0, 0, - 3, 0, 0, 0, - 8, 0, 0, 0, - 0x32, 0x35, 0, 0, - 0, 0, 0, 0, - 0x19, 0, 0, 0, - 8, 0, 0, 0, - 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x2e, - 0x76, 0x69, 0x64, 0x65, - 0x6f, 0x2e, 0x72, 0x61, - 0x74, 0x65, 0x2e, 0x64, - 0x65, 0x6e, 0x6f, 0x6d, - 0, 0, 0, 0, - 0, 0, 0, 0, - 2, 0, 0, 0, - 8, 0, 0, 0, - 0x31, 0, 0, 0, - 0, 0, 0, 0, - 0x1b, 0, 0, 0, - 8, 0, 0, 0, - 0x63, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x70, 0x6f, - 0x77, 0x65, 0x72, 0x2d, - 0x6f, 0x66, 0x2d, 0x74, - 0x77, 0x6f, 0x2d, 0x71, - 0x75, 0x61, 0x6e, 0x74, - 0x75, 0x6d, 0, 0, - 0, 0, 0, 0, - 5, 0, 0, 0, - 8, 0, 0, 0, - 0x74, 0x72, 0x75, 0x65, - 0, 0, 0, 0, - 0x11, 0, 0, 0, - 8, 0, 0, 0, - 0x6c, 0x69, 0x6e, 0x6b, - 0x2e, 0x6d, 0x61, 0x78, - 0x2d, 0x62, 0x75, 0x66, - 0x66, 0x65, 0x72, 0x73, - 0, 0, 0, 0, - 0, 0, 0, 0, - 3, 0, 0, 0, - 8, 0, 0, 0, - 0x36, 0x34, 0, 0, - 0, 0, 0, 0, - 0xf, 0, 0, 0, - 8, 0, 0, 0, - 0x6d, 0x65, 0x6d, 0x2e, - 0x77, 0x61, 0x72, 0x6e, - 0x2d, 0x6d, 0x6c, 0x6f, - 0x63, 0x6b, 0, 0, - 6, 0, 0, 0, - 8, 0, 0, 0, - 0x66, 0x61, 0x6c, 0x73, - 0x65, 0, 0, 0, - 0x10, 0, 0, 0, - 8, 0, 0, 0, - 0x6d, 0x65, 0x6d, 0x2e, - 0x61, 0x6c, 0x6c, 0x6f, - 0x77, 0x2d, 0x6d, 0x6c, - 0x6f, 0x63, 0x6b, 0, - 5, 0, 0, 0, - 8, 0, 0, 0, - 0x74, 0x72, 0x75, 0x65, - 0, 0, 0, 0, - 0x17, 0, 0, 0, - 8, 0, 0, 0, - 0x73, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, - 0x2e, 0x63, 0x68, 0x65, - 0x63, 0x6b, 0x2d, 0x71, - 0x75, 0x61, 0x6e, 0x74, - 0x75, 0x6d, 0, 0, - 6, 0, 0, 0, - 8, 0, 0, 0, - 0x66, 0x61, 0x6c, 0x73, - 0x65, 0, 0, 0, - 0x14, 0, 0, 0, - 8, 0, 0, 0, - 0x73, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, - 0x2e, 0x63, 0x68, 0x65, - 0x63, 0x6b, 0x2d, 0x72, - 0x61, 0x74, 0x65, 0, - 0, 0, 0, 0, - 6, 0, 0, 0, - 8, 0, 0, 0, - 0x66, 0x61, 0x6c, 0x73, - 0x65, 0, 0, 0, - 0xd, 0, 0, 0, - 8, 0, 0, 0, - 0x63, 0x6f, 0x72, 0x65, - 0x2e, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, - 0, 0, 0, 0, - 6, 0, 0, 0, - 8, 0, 0, 0, - 0x31, 0x2e, 0x34, 0x2e, - 0x37, 0, 0, 0, - 0xa, 0, 0, 0, - 8, 0, 0, 0, - 0x63, 0x6f, 0x72, 0x65, - 0x2e, 0x6e, 0x61, 0x6d, - 0x65, 0, 0, 0, - 0, 0, 0, 0, - 0x14, 0, 0, 0, - 8, 0, 0, 0, - 0x70, 0x69, 0x70, 0x65, - 0x77, 0x69, 0x72, 0x65, - 0x2d, 0x61, 0x6c, 0x69, - 0x63, 0x65, 0x2d, 0x31, - 0x34, 0x34, 0x33, 0, - 0, 0, 0, 0, - }, pipewire.ClientUpdateProperties{Props: &pipewire.SPADict{NItems: 0x1e, Items: []pipewire.SPADictItem{ + {"sample", []byte(sendmsg00Message01POD), pipewire.ClientUpdateProperties{Props: &pipewire.SPADict{NItems: 0x1e, Items: []pipewire.SPADictItem{ {Key: "remote.intention", Value: "manager"}, {Key: "application.name", Value: "pw-container"}, {Key: "application.process.binary", Value: "pw-container"}, diff --git a/internal/pipewire/core_test.go b/internal/pipewire/core_test.go index c271feaf..d8c7cf90 100644 --- a/internal/pipewire/core_test.go +++ b/internal/pipewire/core_test.go @@ -8,14 +8,7 @@ import ( func TestCoreHello(t *testing.T) { encodingTestCases[pipewire.CoreHello, *pipewire.CoreHello]{ - {"sample", []byte{ - 0x10, 0, 0, 0, - 0xe, 0, 0, 0, - 4, 0, 0, 0, - 4, 0, 0, 0, - 4, 0, 0, 0, - 0, 0, 0, 0, - }, pipewire.CoreHello{ + {"sample", []byte(sendmsg00Message00POD), pipewire.CoreHello{ Version: pipewire.PW_VERSION_CORE, }, nil}, }.run(t) diff --git a/internal/pipewire/header_test.go b/internal/pipewire/header_test.go index efcea71f..95f6ce13 100644 --- a/internal/pipewire/header_test.go +++ b/internal/pipewire/header_test.go @@ -11,33 +11,17 @@ func TestHeader(t *testing.T) { t.Parallel() encodingTestCases[pipewire.Header, *pipewire.Header]{ - {"PW_CORE_METHOD_HELLO", []byte{ - // Id - 0, 0, 0, 0, - // size - 0x18, 0, 0, - // opcode - 1, - // seq - 0, 0, 0, 0, - // n_fds - 0, 0, 0, 0, - }, pipewire.Header{ID: pipewire.PW_ID_CORE, Opcode: pipewire.PW_CORE_METHOD_HELLO, - Size: 0x18, Sequence: 0, FileCount: 0}, nil}, + {"PW_CORE_METHOD_HELLO", []byte(sendmsg00Message00Header), pipewire.Header{ + ID: pipewire.PW_ID_CORE, + Opcode: pipewire.PW_CORE_METHOD_HELLO, + Size: 0x18, Sequence: 0, FileCount: 0, + }, nil}, - {"PW_CLIENT_METHOD_UPDATE_PROPERTIES", []byte{ - // Id - 1, 0, 0, 0, - // size - 0, 6, 0, - // opcode - 2, - // seq - 1, 0, 0, 0, - // n_fds - 0, 0, 0, 0, - }, pipewire.Header{ID: pipewire.PW_ID_CLIENT, Opcode: pipewire.PW_CLIENT_METHOD_UPDATE_PROPERTIES, - Size: 0x600, Sequence: 1, FileCount: 0}, nil}, + {"PW_CLIENT_METHOD_UPDATE_PROPERTIES", []byte(sendmsg00Message01Header), pipewire.Header{ + ID: pipewire.PW_ID_CLIENT, + Opcode: pipewire.PW_CLIENT_METHOD_UPDATE_PROPERTIES, + Size: 0x600, Sequence: 1, FileCount: 0, + }, nil}, {"PW_SECURITY_CONTEXT_METHOD_CREATE", []byte{ // Id diff --git a/internal/pipewire/pipewire_test.go b/internal/pipewire/pipewire_test.go new file mode 100644 index 00000000..49f128fc --- /dev/null +++ b/internal/pipewire/pipewire_test.go @@ -0,0 +1,17 @@ +package pipewire_test + +import ( + _ "embed" +) + +var ( + //go:embed testdata/00-sendmsg00-message00-header + sendmsg00Message00Header string + //go:embed testdata/01-sendmsg00-message00-POD + sendmsg00Message00POD string + + //go:embed testdata/02-sendmsg00-message01-header + sendmsg00Message01Header string + //go:embed testdata/03-sendmsg00-message01-POD + sendmsg00Message01POD string +) diff --git a/internal/pipewire/testdata/00-sendmsg00-message00-header b/internal/pipewire/testdata/00-sendmsg00-message00-header Binary files differnew file mode 100644 index 00000000..601b8fe6 --- /dev/null +++ b/internal/pipewire/testdata/00-sendmsg00-message00-header diff --git a/internal/pipewire/testdata/01-sendmsg00-message00-POD b/internal/pipewire/testdata/01-sendmsg00-message00-POD Binary files differnew file mode 100644 index 00000000..c02874bb --- /dev/null +++ b/internal/pipewire/testdata/01-sendmsg00-message00-POD diff --git a/internal/pipewire/testdata/02-sendmsg00-message01-header b/internal/pipewire/testdata/02-sendmsg00-message01-header Binary files differnew file mode 100644 index 00000000..0a298db4 --- /dev/null +++ b/internal/pipewire/testdata/02-sendmsg00-message01-header diff --git a/internal/pipewire/testdata/03-sendmsg00-message01-POD b/internal/pipewire/testdata/03-sendmsg00-message01-POD Binary files differnew file mode 100644 index 00000000..f98da218 --- /dev/null +++ b/internal/pipewire/testdata/03-sendmsg00-message01-POD |
