internal/pipewire: move test data to files
All checks were successful
Test / Create distribution (push) Successful in 37s
Test / Sandbox (push) Successful in 2m25s
Test / Hakurei (push) Successful in 3m15s
Test / Hpkg (push) Successful in 4m9s
Test / Sandbox (race detector) (push) Successful in 4m21s
Test / Hakurei (race detector) (push) Successful in 5m10s
Test / Flake checks (push) Successful in 1m28s

These get very big later on, and would be painful to represent as the compound literal.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-11-25 08:09:10 +09:00
parent 88d3e46413
commit e77652bf89
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
8 changed files with 29 additions and 433 deletions

View File

@ -8,405 +8,7 @@ import (
func TestClientUpdateProperties(t *testing.T) { func TestClientUpdateProperties(t *testing.T) {
encodingTestCases[pipewire.ClientUpdateProperties, *pipewire.ClientUpdateProperties]{ encodingTestCases[pipewire.ClientUpdateProperties, *pipewire.ClientUpdateProperties]{
{"sample", []byte{ {"sample", []byte(sendmsg00Message01POD), pipewire.ClientUpdateProperties{Props: &pipewire.SPADict{NItems: 0x1e, Items: []pipewire.SPADictItem{
// 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, 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, 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{
{Key: "remote.intention", Value: "manager"}, {Key: "remote.intention", Value: "manager"},
{Key: "application.name", Value: "pw-container"}, {Key: "application.name", Value: "pw-container"},
{Key: "application.process.binary", Value: "pw-container"}, {Key: "application.process.binary", Value: "pw-container"},

View File

@ -8,14 +8,7 @@ import (
func TestCoreHello(t *testing.T) { func TestCoreHello(t *testing.T) {
encodingTestCases[pipewire.CoreHello, *pipewire.CoreHello]{ encodingTestCases[pipewire.CoreHello, *pipewire.CoreHello]{
{"sample", []byte{ {"sample", []byte(sendmsg00Message00POD), pipewire.CoreHello{
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{
Version: pipewire.PW_VERSION_CORE, Version: pipewire.PW_VERSION_CORE,
}, nil}, }, nil},
}.run(t) }.run(t)

View File

@ -11,33 +11,17 @@ func TestHeader(t *testing.T) {
t.Parallel() t.Parallel()
encodingTestCases[pipewire.Header, *pipewire.Header]{ encodingTestCases[pipewire.Header, *pipewire.Header]{
{"PW_CORE_METHOD_HELLO", []byte{ {"PW_CORE_METHOD_HELLO", []byte(sendmsg00Message00Header), pipewire.Header{
// Id ID: pipewire.PW_ID_CORE,
0, 0, 0, 0, Opcode: pipewire.PW_CORE_METHOD_HELLO,
// size Size: 0x18, Sequence: 0, FileCount: 0,
0x18, 0, 0, }, nil},
// 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_CLIENT_METHOD_UPDATE_PROPERTIES", []byte{ {"PW_CLIENT_METHOD_UPDATE_PROPERTIES", []byte(sendmsg00Message01Header), pipewire.Header{
// Id ID: pipewire.PW_ID_CLIENT,
1, 0, 0, 0, Opcode: pipewire.PW_CLIENT_METHOD_UPDATE_PROPERTIES,
// size Size: 0x600, Sequence: 1, FileCount: 0,
0, 6, 0, }, nil},
// 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_SECURITY_CONTEXT_METHOD_CREATE", []byte{ {"PW_SECURITY_CONTEXT_METHOD_CREATE", []byte{
// Id // Id

View File

@ -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
)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.