Skip to content

Commit

Permalink
tests: add missing APILevelIsSupported() guard
Browse files Browse the repository at this point in the history
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 <rodrigo@kinvolk.io>
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
  • Loading branch information
rata authored and pcmoore committed Apr 29, 2021
1 parent 9339c86 commit 541420d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions seccomp_test.go
Expand Up @@ -464,13 +464,15 @@ func TestFilterAttributeGettersAndSetters(t *testing.T) {
t.Errorf("Log bit was not set correctly")
}

api, err := GetAPI()
if err != nil {
t.Errorf("Error getting API level: %s", err)
} else if api < 4 {
err = SetAPI(4)
if APILevelIsSupported() {
api, err := GetAPI()
if err != nil {
t.Skipf("Skipping test: API level %d is less than 4", api)
t.Errorf("Error getting API level: %s", err)
} else if api < 4 {
err = SetAPI(4)
if err != nil {
t.Skipf("Skipping test: API level %d is less than 4", api)
}
}
}

Expand Down

0 comments on commit 541420d

Please sign in to comment.