Skip to content

Commit 541420d

Browse files
ratapcmoore
authored andcommitted
tests: add missing APILevelIsSupported() guard
Commit "golang: Add support for SCMP_FLTATR_CTL_SSB" (276b0ea) added a call to GetAPI(), and is not guarded with "APILevelIsSupported()" to only report errors when it is supported. The rest of the added code had that, it is just missing for the GetAPI() part. This patch just adds a "APILevelIsSupported()" guard, as done in the rest of GetAPI() calls, to make sure it runs correctly with old libseccomp versions. Signed-off-by: Rodrigo Campos <[email protected]> Acked-by: Tom Hromatka <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 9339c86 commit 541420d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

seccomp_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,15 @@ func TestFilterAttributeGettersAndSetters(t *testing.T) {
464464
t.Errorf("Log bit was not set correctly")
465465
}
466466

467-
api, err := GetAPI()
468-
if err != nil {
469-
t.Errorf("Error getting API level: %s", err)
470-
} else if api < 4 {
471-
err = SetAPI(4)
467+
if APILevelIsSupported() {
468+
api, err := GetAPI()
472469
if err != nil {
473-
t.Skipf("Skipping test: API level %d is less than 4", api)
470+
t.Errorf("Error getting API level: %s", err)
471+
} else if api < 4 {
472+
err = SetAPI(4)
473+
if err != nil {
474+
t.Skipf("Skipping test: API level %d is less than 4", api)
475+
}
474476
}
475477
}
476478

0 commit comments

Comments
 (0)