Skip to content

Commit

Permalink
Merge pull request kata-containers#1555 from liubin/fix/1554-install-…
Browse files Browse the repository at this point in the history
…hook-before-test

test: install mock hook binary before test
  • Loading branch information
Tim-Zhang authored Mar 30, 2021
2 parents 05680b8 + 48e5e4f commit b58fb25
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 10 additions & 2 deletions src/runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,14 @@ generate-config: $(CONFIGS)

check: check-go-static

test: go-test
test: install-hook go-test

install-hook:
make -C virtcontainers hook
ifeq ($(shell id -u), 0)
echo "installing mock hook"
make -C virtcontainers install
endif

go-test: $(GENERATED_FILES)
go test -v -mod=vendor ./...
Expand Down Expand Up @@ -659,7 +666,8 @@ show-usage: show-header
@printf "• Additional targets:\n"
@printf "\n"
@printf "\tbuild : standard build (build everything).\n"
@printf "\tcheck : run tests.\n"
@printf "\ttest : run tests.\n"
@printf "\tcheck : run code checks.\n"
@printf "\tclean : remove built files.\n"
@printf "\tcontainerd-shim-v2 : only build containerd shim v2.\n"
@printf "\tcoverage : run coverage tests.\n"
Expand Down
7 changes: 1 addition & 6 deletions src/runtime/pkg/katautils/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"testing"

ktu "github.com/kata-containers/kata-containers/src/runtime/pkg/katatestutils"
. "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/mock"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/assert"
)
Expand All @@ -25,11 +24,7 @@ var testBinHookPath = "/usr/bin/virtcontainers/bin/test/hook"
var testBundlePath = "/test/bundle"

func getMockHookBinPath() string {
if DefaultMockHookBinPath == "" {
return testBinHookPath
}

return DefaultMockHookBinPath
return testBinHookPath
}

func createHook(timeout int) specs.Hook {
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/virtcontainers/pkg/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import (
pb "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols/grpc"
)

// DefaultMockHookBinPath is populated at link time.
var DefaultMockHookBinPath string

var testKataMockHybridVSockURLTempl = "mock://%s/kata-mock-hybrid-vsock.sock"

func GenerateKataMockHybridVSock() (string, error) {
Expand Down

0 comments on commit b58fb25

Please sign in to comment.