Skip to content

Commit

Permalink
zdtm: add option to run tests with criu plugins
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rst0git committed Aug 12, 2024
1 parent 4151239 commit dd1c9c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.so
18 changes: 18 additions & 0 deletions test/plugins/Makefile
Original file line number Diff line number Diff line change
@@ -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
21 changes: 20 additions & 1 deletion test/zdtm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dd1c9c8

Please sign in to comment.