]>
Commit | Line | Data |
---|---|---|
afeecbba SH |
1 | /* liblxcapi |
2 | * | |
8cd80b50 SG |
3 | * Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>. |
4 | * Copyright © 2012 Canonical Ltd. | |
afeecbba SH |
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 | */ | |
948955a2 | 19 | #include <lxc/lxccontainer.h> |
afeecbba SH |
20 | |
21 | #include <unistd.h> | |
22 | #include <signal.h> | |
23 | #include <stdio.h> | |
24 | #include <sys/types.h> | |
25 | #include <sys/wait.h> | |
26 | #include <stdlib.h> | |
95ee490b | 27 | #include <string.h> |
afeecbba SH |
28 | #include <errno.h> |
29 | ||
30 | #define MYNAME "lxctest1" | |
31 | ||
32 | #define TSTERR(x) do { \ | |
ae5c8b8e | 33 | fprintf(stderr, "%d: %s\n", __LINE__, x); \ |
afeecbba SH |
34 | } while (0) |
35 | ||
36 | int main() | |
37 | { | |
38 | struct lxc_container *c; | |
39 | const char *p1, *p2; | |
40 | int retval = -1; | |
41 | ||
42 | c = lxc_container_new(MYNAME, NULL); | |
43 | if (!c) { | |
44 | TSTERR("create using default path"); | |
45 | goto err; | |
46 | } | |
915af839 | 47 | |
afeecbba SH |
48 | p1 = c->get_config_path(c); |
49 | p2 = c->config_file_name(c); | |
50 | if (!p1 || !p2 || strncmp(p1, p2, strlen(p1))) { | |
51 | TSTERR("Bad result for path names"); | |
52 | goto err; | |
53 | } | |
54 | ||
55 | #define CPATH "/boo" | |
56 | #define FPATH "/boo/lxctest1/config" | |
57 | if (!c->set_config_path(c, "/boo")) { | |
58 | TSTERR("Error setting custom path"); | |
59 | goto err; | |
60 | } | |
915af839 | 61 | |
afeecbba SH |
62 | p1 = c->get_config_path(c); |
63 | p2 = c->config_file_name(c); | |
64 | if (strcmp(p1, CPATH) || strcmp(p2, FPATH)) { | |
65 | TSTERR("Bad result for path names after set_config_path()"); | |
66 | goto err; | |
67 | } | |
68 | lxc_container_put(c); | |
69 | ||
70 | c = lxc_container_new(MYNAME, CPATH); | |
71 | if (!c) { | |
72 | TSTERR("create using custom path"); | |
73 | goto err; | |
74 | } | |
75 | ||
76 | p1 = c->get_config_path(c); | |
77 | p2 = c->config_file_name(c); | |
78 | if (strcmp(p1, CPATH) || strcmp(p2, FPATH)) { | |
79 | TSTERR("Bad result for path names after create with custom path"); | |
80 | goto err; | |
81 | } | |
82 | ||
83 | retval = 0; | |
84 | ||
85 | err: | |
86 | lxc_container_put(c); | |
87 | return retval; | |
88 | } |