Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move syscaller to dist #3269

Merged
merged 1 commit into from Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -26,7 +26,6 @@ compile_commands.json

# binaries and build files
dist
tests/integration/syscaller/cmd/syscaller

# release files
release_notes.txt
10 changes: 4 additions & 6 deletions Makefile
Expand Up @@ -36,7 +36,6 @@ CMD_STATICCHECK ?= staticcheck
CMD_STRIP ?= llvm-strip
CMD_TOUCH ?= touch
CMD_TR ?= tr
CMD_SYSCALLER ?= ./tests/integration/syscaller/cmd/syscaller

.check_%:
#
Expand Down Expand Up @@ -732,18 +731,18 @@ test-types: \
# syscaller (required for integration tests)
#

.PHONY: $(CMD_SYSCALLER)
$(CMD_SYSCALLER): \
.PHONY: $(OUTPUT_DIR)/syscaller
$(OUTPUT_DIR)/syscaller: \
$(OUTPUT_DIR)/libbpf/libbpf.a \
| .check_$(CMD_GO)
#
$(GO_ENV_EBPF) \
$(CMD_GO) build -o $(CMD_SYSCALLER) $(dir $(CMD_SYSCALLER))
$(CMD_GO) build -o $(OUTPUT_DIR)/syscaller ./tests/integration/syscaller/cmd

.PHONY: test-integration
test-integration: \
.checkver_$(CMD_GO) \
$(CMD_SYSCALLER) \
$(OUTPUT_DIR)/syscaller \
tracee-ebpf
#
$(GO_ENV_EBPF) \
Expand Down Expand Up @@ -866,4 +865,3 @@ clean:
$(CMD_RM) -f .*.md5
$(CMD_RM) -f .check*
$(CMD_RM) -f .*-pkgs*
$(CMD_RM) -f $(CMD_SYSCALLER)
7 changes: 6 additions & 1 deletion tests/integration/event_filters_test.go
Expand Up @@ -3,6 +3,7 @@ package integration
import (
"context"
"fmt"
"path/filepath"
"sort"
"strings"
"testing"
Expand All @@ -25,6 +26,8 @@ import (
// Test_EventFilters tests a variety of trace event filters
// with different combinations of policies
func Test_EventFilters(t *testing.T) {
assureIsRoot(t)

// Make sure we don't leak any goroutines since we run Tracee many times in this test.
// If a test case fails, ignore the leak since it's probably caused by the aborted test.
defer goleak.VerifyNone(t)
Expand Down Expand Up @@ -1218,7 +1221,9 @@ func runCmds(t *testing.T, cmdEvents []cmdEvents, actual *eventBuffer, useSyscal

// formatCmdEvents formats given commands to be executed by syscaller helper tool
func formatCmdEvents(cmd *cmdEvents) {
cmd.runCmd = fmt.Sprintf("./syscaller/cmd/syscaller %s", cmd.runCmd)
syscallerAbsPath := filepath.Join("..", "..", "dist", "syscaller")
cmd.runCmd = fmt.Sprintf("%s %s", syscallerAbsPath, cmd.runCmd)

for _, evt := range cmd.evts {
cmd.runCmd = fmt.Sprintf("%s %d", cmd.runCmd, evt.EventID)
}
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/integration_test.go
Expand Up @@ -10,6 +10,8 @@ import (
)

func Test_InitNamespacesEvent(t *testing.T) {
assureIsRoot(t)

procNamespaces := [...]string{"mnt", "cgroup", "pid", "pid_for_children", "time", "time_for_children", "user", "ipc", "net", "uts"}
evts := events.InitNamespacesEvent()
initNamespaces := make(map[string]uint32)
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/tracee.go
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"path/filepath"
"sync"
"syscall"
"testing"
"time"

Expand Down Expand Up @@ -221,3 +222,10 @@ func waitForTraceeOutputEvents(t *testing.T, actual *eventBuffer, now time.Time,
}
}
}

// assureIsRoot skips the test if it is not run as root
func assureIsRoot(t *testing.T) {
if syscall.Geteuid() != 0 {
t.Skipf("***** %s must be run as ROOT *****", t.Name())
}
}