File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed
Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ COPY go.sum /tmp/src/
55WORKDIR /tmp/src/
66RUN go mod download
77COPY . /tmp/src/
8+ RUN CGO_ENABLED=1 go test ./...
89ARG VERSION=unknown
910RUN CGO_ENABLED=1 go install -mod=readonly -ldflags "-X main.version=$VERSION" /tmp/src
1011
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ test: test_vm1 test_vm2 test_vm3 test_vm4
88
99define 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
1313endef
1414
Original file line number Diff line number Diff line change 1+ //go:build amd64
2+
13package ebpftracer
24
35import (
@@ -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
2931func 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
105107func 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
224226func TestFileEvents (t * testing.T ) {
225- skipIfNotRoot (t )
227+ skipIfNotVM (t )
226228 src := `
227229 package main
228230
You can’t perform that action at this time.
0 commit comments