runtime: Move mock hook source

src/runtime/virtcontainers/hook/mock contains a simple example hook in Go.
The only thing this is used for is for some tests in
src/runtime/pkg/katautils/hook_test.go.  It doesn't really have anything
to do with the rest of the virtcontainers package.

So, move it next to the test code that uses it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2022-03-22 17:14:40 +11:00
parent 86723b51ae
commit c77e34de33
6 changed files with 26 additions and 13 deletions

View File

@ -592,7 +592,7 @@ generate-config: $(CONFIGS)
test: hook go-test
hook:
make -C virtcontainers hook
make -C pkg/katautils/mockhook
go-test: $(GENERATED_FILES)
go clean -testcache

View File

@ -20,7 +20,7 @@ import (
var testKeyHook = "test-key"
var testContainerIDHook = "test-container-id"
var testControllerIDHook = "test-controller-id"
var testBinHookPath = "../../virtcontainers/hook/mock/hook"
var testBinHookPath = "mockhook/hook"
var testBundlePath = "/test/bundle"
func getMockHookBinPath() string {

View File

@ -0,0 +1 @@
hook

View File

@ -0,0 +1,21 @@
# Copyright Red Hat.
#
# SPDX-License-Identifier: Apache-2.0
#
BIN = hook
SRC = hook.go
V = @
Q = $(V:1=)
QUIET_BUILD = $(Q:@=@echo ' BUILD '$@;)
BUILDFLAGS =
all: $(BIN)
$(BIN): $(SRC)
$(QUIET_BUILD)go build $(BUILDFLAGS) -o $@ $^
clean:
rm -f $(BIN)

View File

@ -5,8 +5,6 @@
#
PREFIX := /usr
HOOK_DIR := hook/mock
HOOK_BIN := hook
MK_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GOBUILD_FLAGS := -mod=vendor
@ -22,16 +20,11 @@ QUIET_GOBUILD = $(Q:@=@echo ' GOBUILD '$@;)
# Build
#
all: build binaries
all: build
build:
$(QUIET_GOBUILD)go build $(GOBUILD_FLAGS) $(go list ./... | grep -v /vendor/)
hook:
$(QUIET_GOBUILD)go build $(GOBUILD_FLAGS) -o $(HOOK_DIR)/$@ $(HOOK_DIR)/*.go
binaries: hook
#
# Tests
#
@ -54,7 +47,7 @@ define FILE_SAFE_TO_REMOVE =
$(shell test -e "$(1)" && test "$(1)" != "/" && echo "$(1)")
endef
CLEAN_FILES += $(HOOK_DIR)/$(HOOK_BIN)
CLEAN_FILES +=
clean:
rm -f $(foreach f,$(CLEAN_FILES),$(call FILE_SAFE_TO_REMOVE,$(f)))
@ -62,8 +55,6 @@ clean:
.PHONY: \
all \
build \
hook \
binaries \
check \
check-go-static \
check-go-test \