]> git.proxmox.com Git - mirror_lxc.git/blame - src/tests/criu_check_feature.c
spelling: timeout
[mirror_lxc.git] / src / tests / criu_check_feature.c
CommitLineData
739ef90c
AR
1/* liblxcapi
2 *
3 * Copyright © 2017 Adrian Reber <areber@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#include <string.h>
20#include <limits.h>
21
22#include "lxc/lxccontainer.h"
23#include "lxctest.h"
24
25int main(int argc, char *argv[])
26{
27 struct lxc_container *c;
28 struct migrate_opts m_opts;
29 int ret = EXIT_FAILURE;
30
31 /* Test the feature check interface,
32 * we actually do not need a container. */
33 c = lxc_container_new("check_feature", NULL);
34 if (!c) {
35 lxc_error("%s", "Failed to create container \"check_feature\"");
36 exit(ret);
37 }
38
39 if (c->is_defined(c)) {
40 lxc_error("%s\n", "Container \"check_feature\" is defined");
41 goto on_error_put;
42 }
43
44 /* check the migrate API call with wrong 'cmd' */
45 if (!c->migrate(c, UINT_MAX, &m_opts, sizeof(struct migrate_opts))) {
46 /* This should failed */
47 lxc_error("%s\n", "Migrate API calls with command UINT_MAX did not fail");
48 goto on_error_put;
49 }
50
e451a2a8 51 /* do the actual feature check for memory tracking */
739ef90c
AR
52 m_opts.features_to_check = FEATURE_MEM_TRACK;
53 if (c->migrate(c, MIGRATE_FEATURE_CHECK, &m_opts, sizeof(struct migrate_opts))) {
54 lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\".");
55 }
56
57 /* check for lazy pages */
58 m_opts.features_to_check = FEATURE_LAZY_PAGES;
59 if (c->migrate(c, MIGRATE_FEATURE_CHECK, &m_opts, sizeof(struct migrate_opts))) {
60 lxc_debug("%s\n", "System does not support \"FEATURE_LAZY_PAGES\".");
61 }
62
63 /* check for lazy pages and memory tracking */
64 m_opts.features_to_check = FEATURE_LAZY_PAGES | FEATURE_MEM_TRACK;
65 if (c->migrate(c, MIGRATE_FEATURE_CHECK, &m_opts, sizeof(struct migrate_opts))) {
66 if (m_opts.features_to_check == FEATURE_LAZY_PAGES)
67 lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\"");
68 else if (m_opts.features_to_check == FEATURE_MEM_TRACK)
69 lxc_debug("%s\n", "System does not support \"FEATURE_LAZY_PAGES\"");
70 else
71 lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\" "
72 "and \"FEATURE_LAZY_PAGES\"");
73 }
74
75 /* test for unknown feature; once there are 64 features to test
76 * this will be valid... */
77 m_opts.features_to_check = -1ULL;
78 if (!c->migrate(c, MIGRATE_FEATURE_CHECK, &m_opts, sizeof(struct migrate_opts))) {
79 lxc_error("%s\n", "Unsupported feature supported, which is strange.");
80 goto on_error_put;
81 }
82
83 ret = EXIT_SUCCESS;
84
85on_error_put:
86 lxc_container_put(c);
87 if (ret == EXIT_SUCCESS)
88 lxc_debug("%s\n", "All criu feature check tests passed");
17d11ff7 89
739ef90c
AR
90 exit(ret);
91}