From f76489f0afe680f227a67c703f234f6c2d4357e8 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 16 Aug 2024 00:55:48 +0900 Subject: [PATCH] mv contrib/cmd tests/cmd (except memfd-bind) The following commands are moved from `contrib/cmd` to `tests/cmd`: - fs-idmap - pidfd-kill - recvtty - remap-rootfs - sd-helper - seccompagent Signed-off-by: Akihiro Suda --- .gitignore | 12 +++++----- Makefile | 22 +++++++++++-------- docs/terminals.md | 2 +- {contrib => tests}/cmd/fs-idmap/fs-idmap.go | 0 .../cmd/pidfd-kill/pidfd-kill.go | 2 +- {contrib => tests}/cmd/recvtty/recvtty.go | 2 +- .../cmd/remap-rootfs/remap-rootfs.go | 2 +- {contrib => tests}/cmd/sd-helper/helper.go | 2 +- {contrib => tests}/cmd/seccompagent/README.md | 2 +- .../seccompagent/gen-seccomp-example-cfg.sh | 0 .../cmd/seccompagent/seccompagent.go | 0 .../cmd/seccompagent/unsupported.go | 0 tests/integration/helpers.bash | 12 +++++----- tests/integration/seccomp-notify.bats | 2 +- 14 files changed, 32 insertions(+), 28 deletions(-) rename {contrib => tests}/cmd/fs-idmap/fs-idmap.go (100%) rename {contrib => tests}/cmd/pidfd-kill/pidfd-kill.go (97%) rename {contrib => tests}/cmd/recvtty/recvtty.go (98%) rename {contrib => tests}/cmd/remap-rootfs/remap-rootfs.go (98%) rename {contrib => tests}/cmd/sd-helper/helper.go (96%) rename {contrib => tests}/cmd/seccompagent/README.md (97%) rename {contrib => tests}/cmd/seccompagent/gen-seccomp-example-cfg.sh (100%) rename {contrib => tests}/cmd/seccompagent/seccompagent.go (100%) rename {contrib => tests}/cmd/seccompagent/unsupported.go (100%) diff --git a/.gitignore b/.gitignore index 1fcbcfbd379..8cab96cbc75 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,13 @@ vendor/pkg /runc /runc-* -/contrib/cmd/recvtty/recvtty -/contrib/cmd/sd-helper/sd-helper -/contrib/cmd/seccompagent/seccompagent -/contrib/cmd/fs-idmap/fs-idmap /contrib/cmd/memfd-bind/memfd-bind -/contrib/cmd/pidfd-kill/pidfd-kill -/contrib/cmd/remap-rootfs/remap-rootfs +/tests/cmd/recvtty/recvtty +/tests/cmd/sd-helper/sd-helper +/tests/cmd/seccompagent/seccompagent +/tests/cmd/fs-idmap/fs-idmap +/tests/cmd/pidfd-kill/pidfd-kill +/tests/cmd/remap-rootfs/remap-rootfs man/man8 release Vagrantfile diff --git a/Makefile b/Makefile index 94b9a3c341f..ba08b886161 100644 --- a/Makefile +++ b/Makefile @@ -78,22 +78,26 @@ runc-bin: runc-dmz $(GO_BUILD) -o runc . .PHONY: all -all: runc recvtty sd-helper seccompagent fs-idmap memfd-bind pidfd-kill remap-rootfs +all: runc memfd-bind recvtty sd-helper seccompagent fs-idmap pidfd-kill remap-rootfs -.PHONY: recvtty sd-helper seccompagent fs-idmap memfd-bind pidfd-kill remap-rootfs -recvtty sd-helper seccompagent fs-idmap memfd-bind pidfd-kill remap-rootfs: +.PHONY: memfd-bind +memfd-bind: $(GO_BUILD) -o contrib/cmd/$@/$@ ./contrib/cmd/$@ +.PHONY: recvtty sd-helper seccompagent fs-idmap pidfd-kill remap-rootfs +recvtty sd-helper seccompagent fs-idmap pidfd-kill remap-rootfs: + $(GO_BUILD) -o tests/cmd/$@/$@ ./tests/cmd/$@ + .PHONY: clean clean: rm -f runc runc-* libcontainer/dmz/binary/runc-dmz - rm -f contrib/cmd/recvtty/recvtty - rm -f contrib/cmd/sd-helper/sd-helper - rm -f contrib/cmd/seccompagent/seccompagent - rm -f contrib/cmd/fs-idmap/fs-idmap rm -f contrib/cmd/memfd-bind/memfd-bind - rm -f contrib/cmd/pidfd-kill/pidfd-kill - rm -f contrib/cmd/remap-rootfs/remap-rootfs + rm -f tests/cmd/recvtty/recvtty + rm -f tests/cmd/sd-helper/sd-helper + rm -f tests/cmd/seccompagent/seccompagent + rm -f tests/cmd/fs-idmap/fs-idmap + rm -f tests/cmd/pidfd-kill/pidfd-kill + rm -f tests/cmd/remap-rootfs/remap-rootfs sudo rm -rf release rm -rf man/man8 diff --git a/docs/terminals.md b/docs/terminals.md index aa9f71ee059..1e53f5de80a 100644 --- a/docs/terminals.md +++ b/docs/terminals.md @@ -351,4 +351,4 @@ a [Go implementation in the `go-runc` bindings][containerd/go-runc.Socket], as well as [a simple client][recvtty]. [containerd/go-runc.Socket]: https://godoc.org/github.com/containerd/go-runc#Socket -[recvtty]: /contrib/cmd/recvtty +[recvtty]: /tests/cmd/recvtty diff --git a/contrib/cmd/fs-idmap/fs-idmap.go b/tests/cmd/fs-idmap/fs-idmap.go similarity index 100% rename from contrib/cmd/fs-idmap/fs-idmap.go rename to tests/cmd/fs-idmap/fs-idmap.go diff --git a/contrib/cmd/pidfd-kill/pidfd-kill.go b/tests/cmd/pidfd-kill/pidfd-kill.go similarity index 97% rename from contrib/cmd/pidfd-kill/pidfd-kill.go rename to tests/cmd/pidfd-kill/pidfd-kill.go index b5caa4f208d..ea9a9df8d77 100644 --- a/contrib/cmd/pidfd-kill/pidfd-kill.go +++ b/tests/cmd/pidfd-kill/pidfd-kill.go @@ -14,7 +14,7 @@ import ( ) const ( - usage = `Open Container Initiative contrib/cmd/pidfd-kill + usage = `Open Container Initiative tests/cmd/pidfd-kill pidfd-kill is an implementation of a consumer of runC's --pidfd-socket API. After received SIGTERM, pidfd-kill sends the given signal to init process by diff --git a/contrib/cmd/recvtty/recvtty.go b/tests/cmd/recvtty/recvtty.go similarity index 98% rename from contrib/cmd/recvtty/recvtty.go rename to tests/cmd/recvtty/recvtty.go index 532a4c33904..2c82665ab09 100644 --- a/contrib/cmd/recvtty/recvtty.go +++ b/tests/cmd/recvtty/recvtty.go @@ -39,7 +39,7 @@ var version = "" var gitCommit = "" const ( - usage = `Open Container Initiative contrib/cmd/recvtty + usage = `Open Container Initiative tests/cmd/recvtty recvtty is a reference implementation of a consumer of runC's --console-socket API. It has two main modes of operation: diff --git a/contrib/cmd/remap-rootfs/remap-rootfs.go b/tests/cmd/remap-rootfs/remap-rootfs.go similarity index 98% rename from contrib/cmd/remap-rootfs/remap-rootfs.go rename to tests/cmd/remap-rootfs/remap-rootfs.go index b9739ba89c7..0c4eb2021b1 100644 --- a/contrib/cmd/remap-rootfs/remap-rootfs.go +++ b/tests/cmd/remap-rootfs/remap-rootfs.go @@ -13,7 +13,7 @@ import ( "github.com/opencontainers/runtime-spec/specs-go" ) -const usage = `contrib/cmd/remap-rootfs +const usage = `tests/cmd/remap-rootfs remap-rootfs is a helper tool to remap the root filesystem of a Open Container Initiative bundle using user namespaces such that the file owners are remapped diff --git a/contrib/cmd/sd-helper/helper.go b/tests/cmd/sd-helper/helper.go similarity index 96% rename from contrib/cmd/sd-helper/helper.go rename to tests/cmd/sd-helper/helper.go index fc2bf38af67..49b77d004fb 100644 --- a/contrib/cmd/sd-helper/helper.go +++ b/tests/cmd/sd-helper/helper.go @@ -13,7 +13,7 @@ import ( ) func usage() { - fmt.Print(`Open Container Initiative contrib/cmd/sd-helper + fmt.Print(`Open Container Initiative tests/cmd/sd-helper sd-helper is a tool that uses runc/libcontainer/cgroups/systemd package functionality to communicate to systemd in order to perform various operations. diff --git a/contrib/cmd/seccompagent/README.md b/tests/cmd/seccompagent/README.md similarity index 97% rename from contrib/cmd/seccompagent/README.md rename to tests/cmd/seccompagent/README.md index d42d4bda369..80638797adb 100644 --- a/contrib/cmd/seccompagent/README.md +++ b/tests/cmd/seccompagent/README.md @@ -17,7 +17,7 @@ make all Run the seccomp agent in the background: ```bash -sudo ./contrib/cmd/seccompagent/seccompagent & +sudo ./tests/cmd/seccompagent/seccompagent & ``` Prepare a container: diff --git a/contrib/cmd/seccompagent/gen-seccomp-example-cfg.sh b/tests/cmd/seccompagent/gen-seccomp-example-cfg.sh similarity index 100% rename from contrib/cmd/seccompagent/gen-seccomp-example-cfg.sh rename to tests/cmd/seccompagent/gen-seccomp-example-cfg.sh diff --git a/contrib/cmd/seccompagent/seccompagent.go b/tests/cmd/seccompagent/seccompagent.go similarity index 100% rename from contrib/cmd/seccompagent/seccompagent.go rename to tests/cmd/seccompagent/seccompagent.go diff --git a/contrib/cmd/seccompagent/unsupported.go b/tests/cmd/seccompagent/unsupported.go similarity index 100% rename from contrib/cmd/seccompagent/unsupported.go rename to tests/cmd/seccompagent/unsupported.go diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index a644bbadf63..76fbab3f5d1 100755 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -13,12 +13,12 @@ eval "$IMAGES" unset IMAGES : "${RUNC:="${INTEGRATION_ROOT}/../../runc"}" -RECVTTY="${INTEGRATION_ROOT}/../../contrib/cmd/recvtty/recvtty" -SD_HELPER="${INTEGRATION_ROOT}/../../contrib/cmd/sd-helper/sd-helper" -SECCOMP_AGENT="${INTEGRATION_ROOT}/../../contrib/cmd/seccompagent/seccompagent" -FS_IDMAP="${INTEGRATION_ROOT}/../../contrib/cmd/fs-idmap/fs-idmap" -PIDFD_KILL="${INTEGRATION_ROOT}/../../contrib/cmd/pidfd-kill/pidfd-kill" -REMAP_ROOTFS="${INTEGRATION_ROOT}/../../contrib/cmd/remap-rootfs/remap-rootfs" +RECVTTY="${INTEGRATION_ROOT}/../../tests/cmd/recvtty/recvtty" +SD_HELPER="${INTEGRATION_ROOT}/../../tests/cmd/sd-helper/sd-helper" +SECCOMP_AGENT="${INTEGRATION_ROOT}/../../tests/cmd/seccompagent/seccompagent" +FS_IDMAP="${INTEGRATION_ROOT}/../../tests/cmd/fs-idmap/fs-idmap" +PIDFD_KILL="${INTEGRATION_ROOT}/../../tests/cmd/pidfd-kill/pidfd-kill" +REMAP_ROOTFS="${INTEGRATION_ROOT}/../../tests/cmd/remap-rootfs/remap-rootfs" # Some variables may not always be set. Set those to empty value, # if unset, to avoid "unbound variable" error. diff --git a/tests/integration/seccomp-notify.bats b/tests/integration/seccomp-notify.bats index 58492090236..fcbd5664907 100644 --- a/tests/integration/seccomp-notify.bats +++ b/tests/integration/seccomp-notify.bats @@ -214,7 +214,7 @@ function scmp_act_notify_template() { @test "runc run [seccomp] (SCMP_ACT_NOTIFY example config)" { # Run the script used in the seccomp agent example. # This takes a bare config.json and modifies it to run an example. - "${INTEGRATION_ROOT}/../../contrib/cmd/seccompagent/gen-seccomp-example-cfg.sh" + "${INTEGRATION_ROOT}/../../tests/cmd/seccompagent/gen-seccomp-example-cfg.sh" # The listenerPath the previous command uses is the default used by the # seccomp agent. However, inside bats the socket is in a bats tmp dir.