From dd1c9c8e87e338cb7d441ba937e0c97641082cc6 Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Sun, 7 Jul 2024 23:52:42 +0100 Subject: [PATCH] zdtm: add option to run tests with criu plugins By default, if the "CRIU_LIBS_DIR" environment variable is not set, CRIU will load all plugins installed in `/usr/lib/criu`. This may result in running the ZDTM tests with plugins for a different version of CRIU (e.g., installed from a package). This patch updates ZDTM to always set the "CRIU_LIBS_DIR" environment variable and use a local "plugins" directory. This directory contains copies of the plugin files built from source. In addition, this patch adds the `--criu-plugin` option to the `zdtm.py run` command, allowing tests to be run with specified CRIU plugins. Example: - Run test only with AMDGPU plugin ./zdtm.py run -t zdtm/static/busyloop00 --criu-plugin amdgpu - Run test only with CUDA plugin ./zdtm.py run -t zdtm/static/busyloop00 --criu-plugin cuda - Run test with both AMDGPU and CUDA plugins ./zdtm.py run -t zdtm/static/busyloop00 --criu-plugin amdgpu cuda Signed-off-by: Radostin Stoyanov --- test/plugins/.gitignore | 1 + test/plugins/Makefile | 18 ++++++++++++++++++ test/zdtm.py | 21 ++++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 test/plugins/.gitignore create mode 100644 test/plugins/Makefile diff --git a/test/plugins/.gitignore b/test/plugins/.gitignore new file mode 100644 index 0000000000..140f8cf80f --- /dev/null +++ b/test/plugins/.gitignore @@ -0,0 +1 @@ +*.so diff --git a/test/plugins/Makefile b/test/plugins/Makefile new file mode 100644 index 0000000000..7827b655c4 --- /dev/null +++ b/test/plugins/Makefile @@ -0,0 +1,18 @@ +SRC_DIR := ../../plugins +PLUGIN_TARGETS := amdgpu_plugin.so cuda_plugin.so + +# Silent make rules. +Q := @ + +all: $(PLUGIN_TARGETS) + +amdgpu_plugin.so: $(SRC_DIR)/amdgpu/amdgpu_plugin.so + $(Q) cp $< $@ + +cuda_plugin.so: $(SRC_DIR)/cuda/cuda_plugin.so + $(Q) cp $< $@ + +clean: + $(Q) $(RM) $(PLUGIN_TARGETS) + +.PHONY: all clean diff --git a/test/zdtm.py b/test/zdtm.py index 102f384c08..87914f740b 100755 --- a/test/zdtm.py +++ b/test/zdtm.py @@ -40,6 +40,12 @@ "libfault.so" ) +# A directory that contains the CRIU plugins. +PLUGINS_DIR = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "plugins" +) + prev_line = None uuid = uuid.uuid4() @@ -672,6 +678,12 @@ def available(): subprocess.check_call(["make", "-C", "zdtm/"]) if 'preload_libfault' in opts and opts['preload_libfault']: subprocess.check_call(["make", "-C", "libfault/"]) + + subprocess.check_call(["make", '--no-print-directory', "-C", "plugins/", "clean"]) + if 'criu_plugin' in opts and opts['criu_plugin']: + for name in opts['criu_plugin']: + subprocess.check_call(["make", '--no-print-directory', "-C", "plugins/", f"{name}_plugin.so"]) + if 'rootless' in opts and opts['rootless']: return subprocess.check_call( @@ -929,7 +941,9 @@ def run(action, timeout=60): env = dict( os.environ, - ASAN_OPTIONS="log_path=asan.log:disable_coredump=0:detect_leaks=0") + ASAN_OPTIONS="log_path=asan.log:disable_coredump=0:detect_leaks=0", + CRIU_LIBS_DIR=PLUGINS_DIR + ) if fault: print("Forcing %s fault" % fault) @@ -2852,6 +2866,11 @@ def get_cli_args(): rp.add_argument("--test-shard-count", type=int, default=0, help="Specify how many shards are being run (0=sharding disabled; must be the same for all shards)") rp.add_argument("--preload-libfault", action="store_true", help="Run criu with library preload to simulate special cases") + rp.add_argument("--criu-plugin", + help="Run tests with CRIU plugin", + choices=['amdgpu', 'cuda'], + nargs='+', + default=None) lp = sp.add_parser("list", help="List tests") lp.set_defaults(action=list_tests)