mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-09 20:55:22 +00:00
criu: add a test case for the criu feature check support
This adds a simple test case which verifies that the new migrate() API command 'MIGRATE_FEATURE_CHECK' works as expected. If a feature does not exist on the currently running architecture/kernel/criu combination it does not report an error as this is a valid scenario. Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
parent
b5b12b9e75
commit
739ef90c82
@ -32,6 +32,7 @@ lxc_test_shortlived_SOURCES = shortlived.c
|
|||||||
lxc_test_livepatch_SOURCES = livepatch.c lxctest.h
|
lxc_test_livepatch_SOURCES = livepatch.c lxctest.h
|
||||||
lxc_test_state_server_SOURCES = state_server.c lxctest.h
|
lxc_test_state_server_SOURCES = state_server.c lxctest.h
|
||||||
lxc_test_share_ns_SOURCES = share_ns.c lxctest.h
|
lxc_test_share_ns_SOURCES = share_ns.c lxctest.h
|
||||||
|
lxc_test_criu_check_feature_SOURCES = criu_check_feature.c lxctest.h
|
||||||
|
|
||||||
AM_CFLAGS=-DLXCROOTFSMOUNT=\"$(LXCROOTFSMOUNT)\" \
|
AM_CFLAGS=-DLXCROOTFSMOUNT=\"$(LXCROOTFSMOUNT)\" \
|
||||||
-DLXCPATH=\"$(LXCPATH)\" \
|
-DLXCPATH=\"$(LXCPATH)\" \
|
||||||
@ -61,7 +62,8 @@ bin_PROGRAMS = lxc-test-containertests lxc-test-locktests lxc-test-startone \
|
|||||||
lxc-test-reboot lxc-test-list lxc-test-attach lxc-test-device-add-remove \
|
lxc-test-reboot lxc-test-list lxc-test-attach lxc-test-device-add-remove \
|
||||||
lxc-test-apparmor lxc-test-utils lxc-test-parse-config-file \
|
lxc-test-apparmor lxc-test-utils lxc-test-parse-config-file \
|
||||||
lxc-test-config-jump-table lxc-test-shortlived lxc-test-livepatch \
|
lxc-test-config-jump-table lxc-test-shortlived lxc-test-livepatch \
|
||||||
lxc-test-api-reboot lxc-test-state-server lxc-test-share-ns
|
lxc-test-api-reboot lxc-test-state-server lxc-test-share-ns \
|
||||||
|
lxc-test-criu-check-feature
|
||||||
|
|
||||||
bin_SCRIPTS = lxc-test-automount \
|
bin_SCRIPTS = lxc-test-automount \
|
||||||
lxc-test-autostart \
|
lxc-test-autostart \
|
||||||
@ -93,6 +95,7 @@ EXTRA_DIST = \
|
|||||||
console_log.c \
|
console_log.c \
|
||||||
containertests.c \
|
containertests.c \
|
||||||
createtest.c \
|
createtest.c \
|
||||||
|
criu_check_feature.c \
|
||||||
destroytest.c \
|
destroytest.c \
|
||||||
device_add_remove.c \
|
device_add_remove.c \
|
||||||
get_item.c \
|
get_item.c \
|
||||||
|
90
src/tests/criu_check_feature.c
Normal file
90
src/tests/criu_check_feature.c
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/* liblxcapi
|
||||||
|
*
|
||||||
|
* Copyright © 2017 Adrian Reber <areber@redhat.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include "lxc/lxccontainer.h"
|
||||||
|
#include "lxctest.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct lxc_container *c;
|
||||||
|
struct migrate_opts m_opts;
|
||||||
|
int ret = EXIT_FAILURE;
|
||||||
|
|
||||||
|
/* Test the feature check interface,
|
||||||
|
* we actually do not need a container. */
|
||||||
|
c = lxc_container_new("check_feature", NULL);
|
||||||
|
if (!c) {
|
||||||
|
lxc_error("%s", "Failed to create container \"check_feature\"");
|
||||||
|
exit(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->is_defined(c)) {
|
||||||
|
lxc_error("%s\n", "Container \"check_feature\" is defined");
|
||||||
|
goto on_error_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check the migrate API call with wrong 'cmd' */
|
||||||
|
if (!c->migrate(c, UINT_MAX, &m_opts, sizeof(struct migrate_opts))) {
|
||||||
|
/* This should failed */
|
||||||
|
lxc_error("%s\n", "Migrate API calls with command UINT_MAX did not fail");
|
||||||
|
goto on_error_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* do the actual fature check for memory tracking */
|
||||||
|
m_opts.features_to_check = FEATURE_MEM_TRACK;
|
||||||
|
if (c->migrate(c, MIGRATE_FEATURE_CHECK, &m_opts, sizeof(struct migrate_opts))) {
|
||||||
|
lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\".");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for lazy pages */
|
||||||
|
m_opts.features_to_check = FEATURE_LAZY_PAGES;
|
||||||
|
if (c->migrate(c, MIGRATE_FEATURE_CHECK, &m_opts, sizeof(struct migrate_opts))) {
|
||||||
|
lxc_debug("%s\n", "System does not support \"FEATURE_LAZY_PAGES\".");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for lazy pages and memory tracking */
|
||||||
|
m_opts.features_to_check = FEATURE_LAZY_PAGES | FEATURE_MEM_TRACK;
|
||||||
|
if (c->migrate(c, MIGRATE_FEATURE_CHECK, &m_opts, sizeof(struct migrate_opts))) {
|
||||||
|
if (m_opts.features_to_check == FEATURE_LAZY_PAGES)
|
||||||
|
lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\"");
|
||||||
|
else if (m_opts.features_to_check == FEATURE_MEM_TRACK)
|
||||||
|
lxc_debug("%s\n", "System does not support \"FEATURE_LAZY_PAGES\"");
|
||||||
|
else
|
||||||
|
lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\" "
|
||||||
|
"and \"FEATURE_LAZY_PAGES\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* test for unknown feature; once there are 64 features to test
|
||||||
|
* this will be valid... */
|
||||||
|
m_opts.features_to_check = -1ULL;
|
||||||
|
if (!c->migrate(c, MIGRATE_FEATURE_CHECK, &m_opts, sizeof(struct migrate_opts))) {
|
||||||
|
lxc_error("%s\n", "Unsupported feature supported, which is strange.");
|
||||||
|
goto on_error_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
on_error_put:
|
||||||
|
lxc_container_put(c);
|
||||||
|
if (ret == EXIT_SUCCESS)
|
||||||
|
lxc_debug("%s\n", "All criu feature check tests passed");
|
||||||
|
exit(ret);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user