Skip to content

Commit

Permalink
zdtm: add inventory test plugins
Browse files Browse the repository at this point in the history
This patch adds two test plugins to verify that CRIU plugins listed
in the inventory image are enabled, while those that are not listed
can be disabled.

Signed-off-by: Radostin Stoyanov <[email protected]>
  • Loading branch information
rst0git authored and avagin committed Oct 21, 2024
1 parent 18f7207 commit f5d59ec
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions scripts/ci/run-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,6 @@ make -C plugins/amdgpu/ test_topology_remap
./test/zdtm.py run -t zdtm/static/maps00 -t zdtm/static/maps02 --criu-plugin cuda
./test/zdtm.py run -t zdtm/static/maps00 -t zdtm/static/maps02 --criu-plugin amdgpu
./test/zdtm.py run -t zdtm/static/maps00 -t zdtm/static/maps02 --criu-plugin amdgpu cuda
./test/zdtm.py run -t zdtm/static/busyloop00 --criu-plugin inventory_test_enabled inventory_test_disabled

./test/zdtm.py run -t zdtm/static/sigpending -t zdtm/static/pthread00 --mocked-cuda-checkpoint --fault 138
16 changes: 15 additions & 1 deletion test/plugins/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
SRC_DIR := ../../plugins
PLUGIN_TARGETS := amdgpu_plugin.so cuda_plugin.so
PLUGIN_TARGETS := inventory_test_enabled_plugin.so inventory_test_disabled_plugin.so amdgpu_plugin.so cuda_plugin.so

ARCH := x86

PLUGIN_INCLUDE := -iquote../../include
PLUGIN_INCLUDE += -iquote../../criu/include
PLUGIN_INCLUDE += -iquote../../criu/arch/$(ARCH)/include/
PLUGIN_INCLUDE += -iquote../../
PLUGIN_CFLAGS := -g -Wall -Werror -shared -nostartfiles -fPIC

# Silent make rules.
Q := @
Expand All @@ -12,6 +20,12 @@ amdgpu_plugin.so: $(SRC_DIR)/amdgpu/amdgpu_plugin.so
cuda_plugin.so: $(SRC_DIR)/cuda/cuda_plugin.so
$(Q) cp $< $@

inventory_test_enabled_plugin.so: inventory_test_enabled_plugin.c
$(Q) $(CC) $(PLUGIN_CFLAGS) $< -o $@ $(PLUGIN_INCLUDE)

inventory_test_disabled_plugin.so: inventory_test_disabled_plugin.c
$(Q) $(CC) $(PLUGIN_CFLAGS) $< -o $@ $(PLUGIN_INCLUDE)

clean:
$(Q) $(RM) $(PLUGIN_TARGETS)

Expand Down
17 changes: 17 additions & 0 deletions test/plugins/inventory_test_disabled_plugin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "criu-plugin.h"
#include "image.h"

int inventory_test_disabled_plugin_init(int stage)
{
if (stage == CR_PLUGIN_STAGE__RESTORE)
return check_and_remove_inventory_plugin(CR_PLUGIN_DESC.name, strlen(CR_PLUGIN_DESC.name));

return 0;
}

void inventory_test_disabled_plugin_fini(int stage, int ret)
{
return;
}

CR_PLUGIN_REGISTER("inventory_test_disabled_plugin", inventory_test_disabled_plugin_init, inventory_test_disabled_plugin_fini)
17 changes: 17 additions & 0 deletions test/plugins/inventory_test_enabled_plugin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "criu-plugin.h"
#include "image.h"

int inventory_test_enabled_plugin_init(int stage)
{
if (stage == CR_PLUGIN_STAGE__RESTORE)
return !check_and_remove_inventory_plugin(CR_PLUGIN_DESC.name, strlen(CR_PLUGIN_DESC.name));

return add_inventory_plugin(CR_PLUGIN_DESC.name);
}

void inventory_test_enabled_plugin_fini(int stage, int ret)
{
return;
}

CR_PLUGIN_REGISTER("inventory_test_enabled_plugin", inventory_test_enabled_plugin_init, inventory_test_enabled_plugin_fini)
2 changes: 1 addition & 1 deletion test/zdtm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2877,7 +2877,7 @@ def get_cli_args():
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'],
choices=['amdgpu', 'cuda', 'inventory_test_enabled', 'inventory_test_disabled'],
nargs='+',
default=None)
rp.add_argument("--mocked-cuda-checkpoint",
Expand Down

0 comments on commit f5d59ec

Please sign in to comment.