Skip to content

Commit

Permalink
golang: Add filterAttrLog getter/setters test
Browse files Browse the repository at this point in the history
Update TestFilterAttributeGettersAndSetters() to set the log filter flag
and then verify its value.

The log filter flag is not tested when libseccomp is not new enough to
support API level operations.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Matthew Heon <mheon@redhat.com>
  • Loading branch information
tyhicks authored and mheon committed Apr 9, 2019
1 parent 4b17538 commit 23edf06
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions seccomp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,38 @@ func TestFilterAttributeGettersAndSetters(t *testing.T) {
t.Errorf("No new privileges bit was not set correctly")
}

if ApiLevelIsSupported() {
api, err := GetApi()
if err != nil {
t.Errorf("Error getting API level: %s", err)
} else if api < 3 {
err = SetApi(3)
if err != nil {
t.Errorf("Error setting API level: %s", err)
}
}
}

err = filter.SetLogBit(true)
if err != nil {
if !ApiLevelIsSupported() {
t.Logf("Ignoring failure: %s\n", err)
} else {
t.Errorf("Error setting log bit")
}
}

log, err := filter.GetLogBit()
if err != nil {
if !ApiLevelIsSupported() {
t.Logf("Ignoring failure: %s\n", err)
} else {
t.Errorf("Error getting log bit")
}
} else if log != true {
t.Errorf("Log bit was not set correctly")
}

err = filter.SetBadArchAction(ActInvalid)
if err == nil {
t.Errorf("Setting bad arch action to an invalid action should error")
Expand Down

0 comments on commit 23edf06

Please sign in to comment.