Skip to content

Commit 7bbf670

Browse files
committed
build: run tests
1 parent 20e15d2 commit 7bbf670

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ COPY go.sum /tmp/src/
55
WORKDIR /tmp/src/
66
RUN go mod download
77
COPY . /tmp/src/
8+
RUN CGO_ENABLED=1 go test ./...
89
ARG VERSION=unknown
910
RUN CGO_ENABLED=1 go install -mod=readonly -ldflags "-X main.version=$VERSION" /tmp/src
1011

ebpftracer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test: test_vm1 test_vm2 test_vm3 test_vm4
88

99
define test_in_vm
1010
@echo ===TESTING IN $(1)===
11-
vagrant ssh $(1) -c "uname -r && cd /tmp/src && sudo go test -p 1 -count 1 -v ./ebpftracer/..."
11+
vagrant ssh $(1) -c "uname -r && cd /tmp/src && VM=$(1) sudo go test -p 1 -count 1 -v ./ebpftracer/..."
1212
@echo
1313
endef
1414

ebpftracer/tracer_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build amd64
2+
13
package ebpftracer
24

35
import (
@@ -20,14 +22,14 @@ import (
2022
"time"
2123
)
2224

23-
func skipIfNotRoot(t *testing.T) {
24-
if os.Getuid() != 0 {
25+
func skipIfNotVM(t *testing.T) {
26+
if os.Getenv("VM") == "" {
2527
t.SkipNow()
2628
}
2729
}
2830

2931
func TestProcessEvents(t *testing.T) {
30-
skipIfNotRoot(t)
32+
skipIfNotVM(t)
3133
src := `
3234
package main
3335
@@ -103,7 +105,7 @@ func TestProcessEvents(t *testing.T) {
103105
}
104106

105107
func TestTcpEvents(t *testing.T) {
106-
skipIfNotRoot(t)
108+
skipIfNotVM(t)
107109
l, err := net.Listen("tcp", "127.0.0.1:8080")
108110
require.NoError(t, err)
109111
listenAddr := l.Addr().String()
@@ -222,7 +224,7 @@ func TestTcpEvents(t *testing.T) {
222224
}
223225

224226
func TestFileEvents(t *testing.T) {
225-
skipIfNotRoot(t)
227+
skipIfNotVM(t)
226228
src := `
227229
package main
228230

0 commit comments

Comments
 (0)