]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tests: add lxc.syslog tests to get_item 1169/head
authorChristian Brauner <christian.brauner@mailbox.org>
Sun, 4 Sep 2016 22:24:24 +0000 (00:24 +0200)
committerChristian Brauner <christian.brauner@mailbox.org>
Sun, 4 Sep 2016 22:36:35 +0000 (00:36 +0200)
Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
src/tests/get_item.c
src/tests/lxctest.h

index 9750f312383e2a010187b25232ef914eb1e1d771..eb2274eef3d99673634ced2cb31258b9d0c3cbb5 100644 (file)
@@ -26,7 +26,9 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
+
 #include "lxc/state.h"
+#include "lxctest.h"
 
 #define MYNAME "lxctest1"
 
@@ -41,6 +43,29 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
+       /* EXPECT SUCCESS: lxc.syslog with valid value. */
+       if (!c->set_config_item(c, "lxc.syslog", "local0")) {
+               lxc_error("%s\n", "Failed to set lxc.syslog.\n");
+               goto out;
+       }
+       ret = c->get_config_item(c, "lxc.syslog", v2, 255);
+       if (ret < 0) {
+               lxc_error("Failed to retrieve lxc.syslog: %d.\n", ret);
+               goto out;
+       }
+       if (strcmp(v2, "local0") != 0) {
+               lxc_error("Expected: local0 == %s.\n", v2);
+               goto out;
+       }
+       lxc_debug("Retrieving value for lxc.syslog correctly returned: %s.\n", v2);
+
+       /* EXPECT FAILURE: lxc.syslog with invalid value. */
+       if (c->set_config_item(c, "lxc.syslog", "NONSENSE")) {
+               lxc_error("%s\n", "Succeeded int setting lxc.syslog to invalid value \"NONSENSE\".\n");
+               goto out;
+       }
+       lxc_debug("%s\n", "Successfully failed to set lxc.syslog to invalid value.\n");
+
        if (!c->set_config_item(c, "lxc.hook.pre-start", "hi there")) {
                fprintf(stderr, "%d: failed to set hook.pre-start\n", __LINE__);
                goto out;
index 2793ca2260461af095a028ff16a7c6472cd68cf7..c28d9c24f413f113632111cbdde4134ac3e28a63 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
+#define lxc_debug_stream(stream, format, ...)                                  \
+       do {                                                                   \
+               fprintf(stream, "%s: %d: %s: " format, __FILE__, __LINE__,     \
+                       __func__, __VA_ARGS__);                                \
+       } while (false)
+
+#define lxc_error(format, ...) lxc_debug_stream(stderr, format, __VA_ARGS__)
+#define lxc_debug(format, ...) lxc_debug_stream(stdout, format, __VA_ARGS__)
+
 #define lxc_test_assert_stringify(expression, stringify_expression)            \
        do {                                                                   \
                if (!(expression)) {                                           \