]> git.proxmox.com Git - mirror_lxc.git/blame - src/tests/config_jump_table.c
spelling: userns
[mirror_lxc.git] / src / tests / config_jump_table.c
CommitLineData
c04f651e
CB
1/* liblxcapi
2 *
3 * Copyright © 2017 Christian Brauner <christian.brauner@ubuntu.com>.
4 * Copyright © 2017 Canonical Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19#include <lxc/lxccontainer.h>
20
21#include <unistd.h>
22#include <signal.h>
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#include <sys/types.h>
27#include <sys/wait.h>
28#include <stdlib.h>
29#include <errno.h>
30#include <string.h>
31
32#include "confile.h"
33#include "lxc/state.h"
34#include "lxctest.h"
35
36int main(int argc, char *argv[])
37{
38 int fulllen = 0, inlen = 0, ret = EXIT_FAILURE;
39 char *key, *keys, *saveptr = NULL;
40
cfc67626 41 fulllen = lxc_list_config_items(NULL, inlen);
c04f651e
CB
42
43 keys = malloc(sizeof(char) * fulllen + 1);
44 if (!keys) {
45 lxc_error("%s\n", "failed to allocate memory");
46 exit(ret);
47 }
48
cfc67626 49 if (lxc_list_config_items(keys, fulllen) != fulllen) {
c04f651e
CB
50 lxc_error("%s\n", "failed to retrieve configuration keys");
51 goto on_error;
52 }
53
54 for (key = strtok_r(keys, "\n", &saveptr); key != NULL;
55 key = strtok_r(NULL, "\n", &saveptr)) {
56 struct lxc_config_t *config;
f120a741 57
300df83e 58 config = lxc_get_config(key);
c04f651e
CB
59 if (!config) {
60 lxc_error("configuration key \"%s\" not implemented in "
61 "jump table",
62 key);
63 goto on_error;
64 }
65
66 if (!config->set) {
67 lxc_error("configuration key \"%s\" has no set method "
68 "in jump table",
69 key);
70 goto on_error;
71 }
72
73 if (!config->get) {
74 lxc_error("configuration key \"%s\" has no get method "
75 "in jump table",
76 key);
77 goto on_error;
78 }
79
80 if (!config->clr) {
81 lxc_error("configuration key \"%s\" has no clr (clear) "
82 "method in jump table",
83 key);
84 goto on_error;
85 }
86 }
87
88 ret = EXIT_SUCCESS;
89
90on_error:
91 free(keys);
92
93 exit(ret);
c04f651e 94}