diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-13 04:38:48 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-13 04:38:48 +0900 |
| commit | 7638a44fa613f23434318bdf136723aa010e8638 (patch) | |
| tree | 7b5270ed4e9b6d7f1ee0f28c58d8077aa1d18005 /hst | |
| parent | a14b6535a66cb7ac0fc4827f767ffaee0ce04b57 (diff) | |
treewide: parallel tests
Most tests already had no global state, however parallel was never enabled. This change enables it for all applicable tests.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'hst')
| -rw-r--r-- | hst/config_test.go | 6 | ||||
| -rw-r--r-- | hst/dbus_test.go | 9 | ||||
| -rw-r--r-- | hst/enablement_test.go | 14 | ||||
| -rw-r--r-- | hst/fs_test.go | 22 | ||||
| -rw-r--r-- | hst/fsbind_test.go | 2 | ||||
| -rw-r--r-- | hst/fsephemeral_test.go | 2 | ||||
| -rw-r--r-- | hst/fslink_test.go | 2 | ||||
| -rw-r--r-- | hst/fsoverlay_test.go | 2 | ||||
| -rw-r--r-- | hst/hst_test.go | 9 |
9 files changed, 68 insertions, 0 deletions
diff --git a/hst/config_test.go b/hst/config_test.go index 211bd1c1..f3690eb8 100644 --- a/hst/config_test.go +++ b/hst/config_test.go @@ -9,6 +9,8 @@ import ( ) func TestConfigValidate(t *testing.T) { + t.Parallel() + testCases := []struct { name string config *hst.Config @@ -45,6 +47,7 @@ func TestConfigValidate(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() if err := tc.config.Validate(); !reflect.DeepEqual(err, tc.wantErr) { t.Errorf("Validate: error = %#v, want %#v", err, tc.wantErr) } @@ -53,6 +56,8 @@ func TestConfigValidate(t *testing.T) { } func TestExtraPermConfig(t *testing.T) { + t.Parallel() + testCases := []struct { name string config *hst.ExtraPermConfig @@ -72,6 +77,7 @@ func TestExtraPermConfig(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() if got := tc.config.String(); got != tc.want { t.Errorf("String: %q, want %q", got, tc.want) } diff --git a/hst/dbus_test.go b/hst/dbus_test.go index d575f7d4..413767ec 100644 --- a/hst/dbus_test.go +++ b/hst/dbus_test.go @@ -10,6 +10,8 @@ import ( ) func TestBadInterfaceError(t *testing.T) { + t.Parallel() + testCases := []struct { name string err error @@ -23,6 +25,7 @@ func TestBadInterfaceError(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() if gotError := tc.err.Error(); gotError != tc.want { t.Errorf("Error: %s, want %s", gotError, tc.want) } @@ -36,6 +39,8 @@ func TestBadInterfaceError(t *testing.T) { } func TestBusConfigInterfaces(t *testing.T) { + t.Parallel() + testCases := []struct { name string c *hst.BusConfig @@ -63,6 +68,7 @@ func TestBusConfigInterfaces(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() var got []string if tc.cutoff > 0 { var i int @@ -86,6 +92,8 @@ func TestBusConfigInterfaces(t *testing.T) { } func TestBusConfigCheckInterfaces(t *testing.T) { + t.Parallel() + testCases := []struct { name string c *hst.BusConfig @@ -101,6 +109,7 @@ func TestBusConfigCheckInterfaces(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() if err := tc.c.CheckInterfaces(tc.name); !reflect.DeepEqual(err, tc.err) { t.Errorf("CheckInterfaces: error = %#v, want %#v", err, tc.err) } diff --git a/hst/enablement_test.go b/hst/enablement_test.go index 82059aa9..ac8810f3 100644 --- a/hst/enablement_test.go +++ b/hst/enablement_test.go @@ -10,6 +10,8 @@ import ( ) func TestEnablementString(t *testing.T) { + t.Parallel() + testCases := []struct { flags hst.Enablement want string @@ -38,6 +40,7 @@ func TestEnablementString(t *testing.T) { for _, tc := range testCases { t.Run(tc.want, func(t *testing.T) { + t.Parallel() if got := tc.flags.String(); got != tc.want { t.Errorf("String: %q, want %q", got, tc.want) } @@ -46,6 +49,8 @@ func TestEnablementString(t *testing.T) { } func TestEnablements(t *testing.T) { + t.Parallel() + testCases := []struct { name string e *hst.Enablements @@ -63,7 +68,10 @@ func TestEnablements(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() + t.Run("marshal", func(t *testing.T) { + t.Parallel() if got, err := json.Marshal(tc.e); err != nil { t.Fatalf("Marshal: error = %v", err) } else if string(got) != tc.data { @@ -81,6 +89,8 @@ func TestEnablements(t *testing.T) { }) t.Run("unmarshal", func(t *testing.T) { + t.Parallel() + { got := new(hst.Enablements) if err := json.Unmarshal([]byte(tc.data), &got); err != nil { @@ -116,6 +126,8 @@ func TestEnablements(t *testing.T) { } t.Run("unwrap", func(t *testing.T) { + t.Parallel() + t.Run("nil", func(t *testing.T) { if got := (*hst.Enablements)(nil).Unwrap(); got != 0 { t.Errorf("Unwrap: %v", got) @@ -130,6 +142,8 @@ func TestEnablements(t *testing.T) { }) t.Run("passthrough", func(t *testing.T) { + t.Parallel() + if _, err := (*hst.Enablements)(nil).MarshalJSON(); !errors.Is(err, syscall.EINVAL) { t.Errorf("MarshalJSON: error = %v", err) } diff --git a/hst/fs_test.go b/hst/fs_test.go index 8350be54..10e075be 100644 --- a/hst/fs_test.go +++ b/hst/fs_test.go @@ -15,6 +15,8 @@ import ( ) func TestFilesystemConfigJSON(t *testing.T) { + t.Parallel() + testCases := []struct { name string want hst.FilesystemConfigJSON @@ -86,7 +88,10 @@ func TestFilesystemConfigJSON(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() + t.Run("marshal", func(t *testing.T) { + t.Parallel() wantErr := tc.wantErr if errors.As(wantErr, new(hst.FSTypeError)) { // for unsupported implementation tc @@ -122,6 +127,7 @@ func TestFilesystemConfigJSON(t *testing.T) { }) t.Run("unmarshal", func(t *testing.T) { + t.Parallel() if tc.data == "\x00" && tc.sData == "\x00" { if errors.As(tc.wantErr, new(hst.FSImplError)) { // this error is only returned on marshal @@ -163,6 +169,8 @@ func TestFilesystemConfigJSON(t *testing.T) { } t.Run("valid", func(t *testing.T) { + t.Parallel() + if got := (*hst.FilesystemConfigJSON).Valid(nil); got { t.Errorf("Valid: %v, want false", got) } @@ -177,6 +185,7 @@ func TestFilesystemConfigJSON(t *testing.T) { }) t.Run("passthrough", func(t *testing.T) { + t.Parallel() if err := new(hst.FilesystemConfigJSON).UnmarshalJSON(make([]byte, 0)); err == nil { t.Errorf("UnmarshalJSON: error = %v", err) } @@ -184,7 +193,10 @@ func TestFilesystemConfigJSON(t *testing.T) { } func TestFSErrors(t *testing.T) { + t.Parallel() + t.Run("type", func(t *testing.T) { + t.Parallel() want := `invalid filesystem type "cat"` if got := hst.FSTypeError("cat").Error(); got != want { t.Errorf("Error: %q, want %q", got, want) @@ -192,6 +204,8 @@ func TestFSErrors(t *testing.T) { }) t.Run("impl", func(t *testing.T) { + t.Parallel() + testCases := []struct { name string val hst.FilesystemConfig @@ -205,6 +219,7 @@ func TestFSErrors(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() err := hst.FSImplError{Value: tc.val} if got := err.Error(); got != tc.want { t.Errorf("Error: %q, want %q", got, tc.want) @@ -242,13 +257,17 @@ type fsTestCase struct { func checkFs(t *testing.T, testCases []fsTestCase) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() + t.Run("valid", func(t *testing.T) { + t.Parallel() if got := tc.fs.Valid(); got != tc.valid { t.Errorf("Valid: %v, want %v", got, tc.valid) } }) t.Run("ops", func(t *testing.T) { + t.Parallel() ops := new(container.Ops) tc.fs.Apply(&hst.ApplyState{AutoEtcPrefix: ":3", Ops: opsAdapter{ops}}) if !reflect.DeepEqual(ops, &tc.ops) { @@ -265,18 +284,21 @@ func checkFs(t *testing.T, testCases []fsTestCase) { }) t.Run("path", func(t *testing.T) { + t.Parallel() if got := tc.fs.Path(); !reflect.DeepEqual(got, tc.path) { t.Errorf("Target: %q, want %q", got, tc.path) } }) t.Run("host", func(t *testing.T) { + t.Parallel() if got := tc.fs.Host(); !reflect.DeepEqual(got, tc.host) { t.Errorf("Host: %q, want %q", got, tc.host) } }) t.Run("string", func(t *testing.T) { + t.Parallel() if tc.str == "\x00" { return } diff --git a/hst/fsbind_test.go b/hst/fsbind_test.go index 62de240e..d5cf102a 100644 --- a/hst/fsbind_test.go +++ b/hst/fsbind_test.go @@ -9,6 +9,8 @@ import ( ) func TestFSBind(t *testing.T) { + t.Parallel() + checkFs(t, []fsTestCase{ {"nil", (*hst.FSBind)(nil), false, nil, nil, nil, "<invalid>"}, {"ensure optional", &hst.FSBind{Source: m("/"), Ensure: true, Optional: true}, diff --git a/hst/fsephemeral_test.go b/hst/fsephemeral_test.go index 4bda3165..23399ac6 100644 --- a/hst/fsephemeral_test.go +++ b/hst/fsephemeral_test.go @@ -9,6 +9,8 @@ import ( ) func TestFSEphemeral(t *testing.T) { + t.Parallel() + checkFs(t, []fsTestCase{ {"nil", (*hst.FSEphemeral)(nil), false, nil, nil, nil, "<invalid>"}, diff --git a/hst/fslink_test.go b/hst/fslink_test.go index b3e196e6..758ae421 100644 --- a/hst/fslink_test.go +++ b/hst/fslink_test.go @@ -8,6 +8,8 @@ import ( ) func TestFSLink(t *testing.T) { + t.Parallel() + checkFs(t, []fsTestCase{ {"nil", (*hst.FSLink)(nil), false, nil, nil, nil, "<invalid>"}, {"zero", new(hst.FSLink), false, nil, nil, nil, "<invalid>"}, diff --git a/hst/fsoverlay_test.go b/hst/fsoverlay_test.go index 15875bb6..df6ec082 100644 --- a/hst/fsoverlay_test.go +++ b/hst/fsoverlay_test.go @@ -9,6 +9,8 @@ import ( ) func TestFSOverlay(t *testing.T) { + t.Parallel() + checkFs(t, []fsTestCase{ {"nil", (*hst.FSOverlay)(nil), false, nil, nil, nil, "<invalid>"}, {"nil lower", &hst.FSOverlay{Target: m("/etc"), Lower: []*check.Absolute{nil}}, false, nil, nil, nil, "<invalid>"}, diff --git a/hst/hst_test.go b/hst/hst_test.go index 247df2c1..8bca8d6e 100644 --- a/hst/hst_test.go +++ b/hst/hst_test.go @@ -14,6 +14,8 @@ import ( ) func TestAppError(t *testing.T) { + t.Parallel() + testCases := []struct { name string err error @@ -58,13 +60,17 @@ func TestAppError(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() + t.Run("error", func(t *testing.T) { + t.Parallel() if got := tc.err.Error(); got != tc.s { t.Errorf("Error: %s, want %s", got, tc.s) } }) t.Run("message", func(t *testing.T) { + t.Parallel() gotMessage, gotMessageOk := message.GetMessage(tc.err) if want := tc.message != "\x00"; gotMessageOk != want { t.Errorf("GetMessage: ok = %v, want %v", gotMessage, want) @@ -78,6 +84,7 @@ func TestAppError(t *testing.T) { }) t.Run("is", func(t *testing.T) { + t.Parallel() if !errors.Is(tc.err, tc.is) { t.Errorf("Is: unexpected false for %v", tc.is) } @@ -90,6 +97,8 @@ func TestAppError(t *testing.T) { } func TestTemplate(t *testing.T) { + t.Parallel() + const want = `{ "id": "org.chromium.Chromium", "enablements": { |
