/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of systemd.
-
- Copyright 2015 Ronny Chevalier
-***/
#include "conf-parser.h"
#include "fd-util.h"
#include "fileio.h"
+#include "fs-util.h"
#include "log.h"
#include "macro.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
-/// Additional includes needed by elogind
-#include "fd-util.h"
-#include "fileio.h"
-
+#if 0 /// UNNEEDED by elogind
static void test_config_parse_path_one(const char *rvalue, const char *expected) {
_cleanup_free_ char *path = NULL;
assert_se(expected == log_level);
}
-#if 0 /// UNNEEDED by elogind
static void test_config_parse_log_facility_one(const char *rvalue, int expected) {
int log_facility = 0;
assert_se(config_parse_log_facility("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &log_facility, NULL) >= 0);
assert_se(expected == log_facility);
}
-#endif // 0
static void test_config_parse_iec_size_one(const char *rvalue, size_t expected) {
size_t iec_size = 0;
assert_se(expected == iec_size);
}
-#if 0 /// UNNEEDED by elogind
static void test_config_parse_si_size_one(const char *rvalue, size_t expected) {
size_t si_size = 0;
assert_se(strv_equal(expected, strv));
}
+#if 0 /// UNNEEDED by elogind
static void test_config_parse_mode_one(const char *rvalue, mode_t expected) {
mode_t v = 0;
assert_se(config_parse_mode("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL) >= 0);
assert_se(expected == v);
}
+#endif // 0
static void test_config_parse_sec_one(const char *rvalue, usec_t expected) {
usec_t v = 0;
assert_se(config_parse_nsec("unit", "filename", 1, "nsection", 1, "lvalue", 0, rvalue, &v, NULL) >= 0);
assert_se(expected == v);
}
-#endif // 0
static void test_config_parse_path(void) {
test_config_parse_path_one("/path", "/path");
test_config_parse_path_one("/path//////////", "/path");
test_config_parse_path_one("///path/foo///bar////bar//", "/path/foo/bar/bar");
+ test_config_parse_path_one("/path//./////hogehoge///.", "/path/hogehoge");
test_config_parse_path_one("/path/\xc3\x80", "/path/\xc3\x80");
test_config_parse_path_one("not_absolute/path", NULL);
test_config_parse_log_level_one("garbage", 0);
}
-#if 0 /// UNNEEDED by elogind
static void test_config_parse_log_facility(void) {
test_config_parse_log_facility_one("mail", LOG_MAIL);
test_config_parse_log_facility_one("user", LOG_USER);
test_config_parse_log_facility_one("garbage", 0);
}
-#endif // 0
static void test_config_parse_iec_size(void) {
test_config_parse_iec_size_one("1024", 1024);
test_config_parse_iec_size_one("garbage", 0);
}
-#if 0 /// UNNEEDED by elogind
static void test_config_parse_si_size(void) {
test_config_parse_si_size_one("1024", 1024);
test_config_parse_si_size_one("2K", 2000);
test_config_parse_strv_one("foo bar foo", STRV_MAKE("foo", "bar", "foo"));
test_config_parse_strv_one("\"foo bar\" foo", STRV_MAKE("foo bar", "foo"));
test_config_parse_strv_one("\xc3\x80", STRV_MAKE("\xc3\x80"));
- test_config_parse_strv_one("\xc3\x7f", STRV_MAKE_EMPTY);
+ test_config_parse_strv_one("\xc3\x7f", STRV_MAKE("\xc3\x7f"));
}
+#if 0 /// UNNEEDED by elogind
static void test_config_parse_mode(void) {
test_config_parse_mode_one("777", 0777);
test_config_parse_mode_one("644", 0644);
test_config_parse_mode_one("777garbage", 0);
test_config_parse_mode_one("777 garbage", 0);
}
+#endif // 0
static void test_config_parse_sec(void) {
test_config_parse_sec_one("1", 1 * USEC_PER_SEC);
};
static void test_config_parse(unsigned i, const char *s) {
- char name[] = "/tmp/test-conf-parser.XXXXXX";
+ _cleanup_(unlink_tempfilep) char name[] = "/tmp/test-conf-parser.XXXXXX";
int fd, r;
_cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ char *setting1 = NULL;
log_parse_environment();
log_open();
+#if 0 /// UNNEEDED by elogind
test_config_parse_path();
test_config_parse_log_level();
-#if 0 /// UNNEEDED by elogind
test_config_parse_log_facility();
-#endif // 0
test_config_parse_iec_size();
-#if 0 /// UNNEEDED by elogind
test_config_parse_si_size();
#endif // 0
test_config_parse_int();
test_config_parse_unsigned();
test_config_parse_strv();
+#if 0 /// UNNEEDED by elogind
test_config_parse_mode();
+#endif // 0
test_config_parse_sec();
#if 0 /// UNNEEDED by elogind
test_config_parse_nsec();