diff --git a/pkg/run/runner.go b/pkg/run/runner.go index efef353..05b817e 100644 --- a/pkg/run/runner.go +++ b/pkg/run/runner.go @@ -58,12 +58,12 @@ func WithArgs(args ...string) RunnerOption { return func(ro *runOpts) { ro.args = append(ro.args, args...) } } -// WithArgs is an option for running Falco by writing stdout on a given writer +// WithStdout is an option for running Falco by writing stdout on a given writer func WithStdout(writer io.Writer) RunnerOption { return func(ro *runOpts) { ro.stdout = writer } } -// WithArgs is an option for running Falco by writing stderr on a given writer +// WithStderr is an option for running Falco by writing stderr on a given writer func WithStderr(writer io.Writer) RunnerOption { return func(ro *runOpts) { ro.stderr = writer } } diff --git a/tests/data/outputs/event.go b/tests/data/outputs/event.go new file mode 100644 index 0000000..7d9aeb5 --- /dev/null +++ b/tests/data/outputs/event.go @@ -0,0 +1,11 @@ +package outputs + +import ( + _ "embed" + + "github.com/falcosecurity/testing/pkg/run" +) + +//go:embed events.txt +var s string +var EventData = run.NewStringFileAccessor("eventData", s) diff --git a/tests/data/outputs/events.txt b/tests/data/outputs/events.txt new file mode 100644 index 0000000..c0e593f --- /dev/null +++ b/tests/data/outputs/events.txt @@ -0,0 +1 @@ +sendfile,recvfrom,readv,sendto,send,read,recvmmsg,write,recvmsg,pwrite,sendmmsg,sendmsg,pread,writev,recv,pwritev,preadv \ No newline at end of file diff --git a/tests/falco/commands_test.go b/tests/falco/commands_test.go index 42a3580..8911cdd 100644 --- a/tests/falco/commands_test.go +++ b/tests/falco/commands_test.go @@ -19,10 +19,12 @@ package testfalco import ( "regexp" + "strings" "testing" "github.com/falcosecurity/testing/pkg/falco" "github.com/falcosecurity/testing/tests" + "github.com/falcosecurity/testing/tests/data/outputs" "github.com/stretchr/testify/assert" ) @@ -132,3 +134,24 @@ func TestFalco_Cmd_PluginInfo(t *testing.T) { `No suggested open params available.*`), res.Stdout()) } + +func TestFalco_Print_IgnoredEvents(t *testing.T) { + t.Parallel() + checkDefaultConfig(t) + bytearr, err := outputs.EventData.Content() + if err != nil { + panic(err) + } + events := strings.Split(string(bytearr), ",") + runner := tests.NewFalcoExecutableRunner(t) + res := falco.Test( + runner, + falco.WithArgs("-i"), + ) + assert.Contains(t, res.Stdout(), "Ignored I/O syscall(s)") + for _, event := range events { + assert.Contains(t, res.Stdout(), event) + } + assert.NoError(t, res.Err(), "%s", res.Stderr()) + assert.Equal(t, res.ExitCode(), 0) +}