From 76db45331ce9cdb868161874f175bc75b570ea43 Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Thu, 23 Apr 2020 14:28:00 +0000 Subject: [PATCH] test/others/libcriu: test version library calls This adds the previously added libcriu version functions to the libcriu tests. Signed-off-by: Adrian Reber --- test/others/libcriu/lib.c | 7 ++++++- test/others/libcriu/lib.h | 1 + test/others/libcriu/test_self.c | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/test/others/libcriu/lib.c b/test/others/libcriu/lib.c index 33aa4090d..0c7929cda 100644 --- a/test/others/libcriu/lib.c +++ b/test/others/libcriu/lib.c @@ -2,6 +2,8 @@ #include #include +#include "criu.h" + void what_err_ret_mean(int ret) { /* NOTE: errno is set by libcriu */ @@ -44,4 +46,7 @@ int chk_exit(int status, int want) return 1; } - +int get_version() +{ + printf("Using a CRIU binary with version %d\n", criu_get_version()); +} diff --git a/test/others/libcriu/lib.h b/test/others/libcriu/lib.h index 67b784bff..6fdf8aef2 100644 --- a/test/others/libcriu/lib.h +++ b/test/others/libcriu/lib.h @@ -1,2 +1,3 @@ void what_err_ret_mean(int ret); int chk_exit(int status, int want); +int get_version(void); diff --git a/test/others/libcriu/test_self.c b/test/others/libcriu/test_self.c index c9d2a2e64..374a4b545 100644 --- a/test/others/libcriu/test_self.c +++ b/test/others/libcriu/test_self.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,18 @@ int main(int argc, char *argv[]) criu_init_opts(); criu_set_service_binary(argv[1]); + + get_version(); + if (!criu_check_version(31400)) { + printf("CRIU version check failed. CRIU too old\n"); + return 1; + } + + if (criu_check_version(INT_MAX)) { + printf("CRIU version check failed. CRIU too new.\n"); + return 1; + } + criu_set_images_dir_fd(fd); criu_set_log_level(4);