-
Notifications
You must be signed in to change notification settings - Fork 109
fails when make test twice as non-root user #418
Description
Description of problem
When I execute make test twice, I got an error.
[ningbo@localhost agent]$ export KATA_DEV_MODE=true
[ningbo@localhost agent]$ make test >1.log && (make test >2.log || echo "make test 2nd time failed") || echo "make test 1st time failed"
make: *** [test] Error 1
make test 2nd time failed
Cause
It's easy to reproduce
[ningbo@localhost agent]$ export KATA_DEV_MODE=true
[ningbo@localhost agent]$ sudo touch /tmp/agentserver.sock
[ningbo@localhost agent]$ /usr/bin/go test -timeout 30s github.com/kata-containers/agent/protocols/client -run ^TestNewAgentClient$
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x7e57fd]goroutine 7 [running]:
github.com/kata-containers/agent/vendor/google.golang.org/grpc.(*Server).Serve.func2(0xc0001091e0, 0x0, 0x0)
/home/ningbo/go/src/github.com/kata-containers/agent/vendor/google.golang.org/grpc/server.go:494 +0xad
panic(0x96f440, 0xea7f10)
/usr/lib/go1.11.1/src/runtime/panic.go:513 +0x1b9
github.com/kata-containers/agent/vendor/google.golang.org/grpc.(*Server).Serve(0xc0001091e0, 0x0, 0x0, 0x0, 0x0)
/home/ningbo/go/src/github.com/kata-containers/agent/vendor/google.golang.org/grpc/server.go:503 +0x1bb
github.com/kata-containers/agent/protocols/client.startMockServer.func1(0xc000082660, 0x0, 0x0, 0x0, 0xc00016e100, 0xc0001091e0)
/home/ningbo/go/src/github.com/kata-containers/agent/protocols/client/client_test.go:59 +0x78
created by github.com/kata-containers/agent/protocols/client.startMockServer
/home/ningbo/go/src/github.com/kata-containers/agent/protocols/client/client_test.go:48 +0x1b8
FAIL github.com/kata-containers/agent/protocols/client 0.005s
The test case will be run as current(non-root) user then root user when execute make test.
/tmp/agentserver.agent(owner is root now) will exists in system after the 1st time, it will fail when remove the file as non-root user at 2nd time.
Solution
remove /tmp/agentserver.agent when test case is done and output friendly error message when failed.