tests: add lxc.syslog tests to get_item

parent d479e1f7
......@@ -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;
......
......@@ -28,6 +28,15 @@
#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)) { \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment