Skip to content

Commit ce7ceff

Browse files
committed
test: fix TestNotif*
TestNotif should check not only for API level >= 6, but also for libseccomp >= 2.5.0. Use notifSupported() to fix. Same applies to TestNotifUnsupported. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent c86754b commit ce7ceff

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

seccomp_test.go

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -777,23 +777,8 @@ func TestNotif(t *testing.T) {
777777
}
778778

779779
func subprocessNotif(t *testing.T) {
780-
// seccomp notification requires API level >= 6
781-
api, err := GetAPI()
782-
if err != nil {
783-
if !APILevelIsSupported() {
784-
t.Skipf("Skipping test: %s", err)
785-
}
786-
787-
t.Errorf("Error getting API level: %s", err)
788-
} else {
789-
t.Logf("Got API level %v", api)
790-
if api < 6 {
791-
err = SetAPI(6)
792-
if err != nil {
793-
t.Skipf("Skipping test: API level %d is less than 6 and could not set it to 6", api)
794-
return
795-
}
796-
}
780+
if err := notifSupported(); err != nil {
781+
t.Skip(err)
797782
}
798783

799784
arch, err := GetNativeArch()
@@ -945,15 +930,8 @@ func TestNotifUnsupported(t *testing.T) {
945930
}
946931

947932
func subprocessNotifUnsupported(t *testing.T) {
948-
// seccomp notification requires API level >= 6
949-
api := 0
950-
if APILevelIsSupported() {
951-
api, err := GetAPI()
952-
if err != nil {
953-
t.Errorf("Error getting API level: %s", err)
954-
} else if api >= 6 {
955-
t.Skipf("Skipping test for old libseccomp support: API level %d is >= 6", api)
956-
}
933+
if err := notifSupported(); err == nil {
934+
t.Skip("seccomp notification is supported")
957935
}
958936

959937
filter, err := NewFilter(ActAllow)
@@ -964,6 +942,6 @@ func subprocessNotifUnsupported(t *testing.T) {
964942

965943
_, err = filter.GetNotifFd()
966944
if err == nil {
967-
t.Errorf("Error: GetNotifFd was supposed to fail with API level %d", api)
945+
t.Error("GetNotifFd: got nil, want error")
968946
}
969947
}

0 commit comments

Comments
 (0)