]> git.proxmox.com Git - mirror_lxc.git/blame - src/tests/config_jump_table.c
tests: include config.h
[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 */
e49c56d6
CB
19
20#include "config.h"
21
c04f651e
CB
22#include <lxc/lxccontainer.h>
23
24#include <unistd.h>
25#include <signal.h>
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29#include <sys/types.h>
30#include <sys/wait.h>
31#include <stdlib.h>
32#include <errno.h>
33#include <string.h>
34
35#include "confile.h"
36#include "lxc/state.h"
37#include "lxctest.h"
38
39int main(int argc, char *argv[])
40{
41 int fulllen = 0, inlen = 0, ret = EXIT_FAILURE;
42 char *key, *keys, *saveptr = NULL;
43
cfc67626 44 fulllen = lxc_list_config_items(NULL, inlen);
c04f651e
CB
45
46 keys = malloc(sizeof(char) * fulllen + 1);
47 if (!keys) {
48 lxc_error("%s\n", "failed to allocate memory");
49 exit(ret);
50 }
51
cfc67626 52 if (lxc_list_config_items(keys, fulllen) != fulllen) {
c04f651e
CB
53 lxc_error("%s\n", "failed to retrieve configuration keys");
54 goto on_error;
55 }
56
57 for (key = strtok_r(keys, "\n", &saveptr); key != NULL;
58 key = strtok_r(NULL, "\n", &saveptr)) {
59 struct lxc_config_t *config;
f120a741 60
300df83e 61 config = lxc_get_config(key);
c04f651e
CB
62 if (!config) {
63 lxc_error("configuration key \"%s\" not implemented in "
64 "jump table",
65 key);
66 goto on_error;
67 }
68
69 if (!config->set) {
70 lxc_error("configuration key \"%s\" has no set method "
71 "in jump table",
72 key);
73 goto on_error;
74 }
75
76 if (!config->get) {
77 lxc_error("configuration key \"%s\" has no get method "
78 "in jump table",
79 key);
80 goto on_error;
81 }
82
83 if (!config->clr) {
84 lxc_error("configuration key \"%s\" has no clr (clear) "
85 "method in jump table",
86 key);
87 goto on_error;
88 }
89 }
90
91 ret = EXIT_SUCCESS;
92
93on_error:
94 free(keys);
95
96 exit(ret);
c04f651e 97}