test-unit-file.c revision 143bfdaf0b890fa7acadf02d1eafacaef1b696bd
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2012 Lennart Poettering
Copyright 2013 Zbigniew Jędrzejewski-Szmek
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include "install.h"
#include "install-printf.h"
#include "specifier.h"
#include "util.h"
#include "macro.h"
#include "hashmap.h"
#include "load-fragment.h"
#include "strv.h"
#include "fileio.h"
#include "test-helper.h"
static int test_unit_file_get_set(void) {
int r;
Hashmap *h;
Iterator i;
UnitFileList *p;
assert(h);
"unit_file_get_list: %s", strerror(-r));
if (r < 0)
return EXIT_FAILURE;
HASHMAP_FOREACH(p, h, i)
return 0;
}
static void check_execcommand(ExecCommand *c,
const char* path,
const char* argv0,
const char* argv1,
bool ignore) {
assert_se(c);
log_info("%s %s %s %s",
}
static void test_config_parse_exec(void) {
/* int config_parse_exec( */
/* const char *filename, */
/* unsigned line, */
/* const char *section, */
/* const char *lvalue, */
/* int ltype, */
/* const char *rvalue, */
/* void *data, */
/* void *userdata) */
int r;
/* basic test */
"LValue", 0, "/RValue r1",
&c, NULL);
assert_se(r >= 0);
"LValue", 0, "/RValue///slashes/// r1",
&c, NULL);
/* test slashes */
assert_se(r >= 0);
c1 = c->command_next;
"r1", false);
/* honour_argv0 */
"LValue", 0, "@/RValue///slashes2/// argv0 r1",
&c, NULL);
assert_se(r >= 0);
/* ignore && honour_argv0 */
"LValue", 0, "-@/RValue///slashes3/// argv0a r1",
&c, NULL);
assert_se(r >= 0);
/* ignore && honour_argv0 */
"LValue", 0, "@-/RValue///slashes4/// argv0b r1",
&c, NULL);
assert_se(r >= 0);
/* ignore && ignore */
"LValue", 0, "--/RValue argv0 r1",
&c, NULL);
assert_se(r == 0);
/* ignore && ignore */
"LValue", 0, "-@-/RValue argv0 r1",
&c, NULL);
assert_se(r == 0);
/* semicolon */
"LValue", 0,
"-@/RValue argv0 r1 ; "
&c, NULL);
assert_se(r >= 0);
"/RValue", "argv0", "r1", true);
/* trailing semicolon */
"LValue", 0,
"-@/RValue argv0 r1 ; ",
&c, NULL);
assert_se(r >= 0);
"/RValue", "argv0", "r1", true);
/* escaped semicolon */
"LValue", 0,
&c, NULL);
assert_se(r >= 0);
}
#define env_file_1 \
"a=a\n" \
"b=b\\\n" \
"c\n" \
"d=d\\\n" \
"e\\\n" \
"f\n" \
"g=g\\ \n" \
"h=h\n" \
"i=i\\"
#define env_file_2 \
"a=a\\\n"
#define env_file_3 \
"#--nouser-config \\\n" \
"normal=line"
#define env_file_4 \
"# Generated\n" \
"\n" \
"HWMON_MODULES=\"coretemp f71882fg\"\n" \
"\n" \
"# For compatibility reasons\n" \
"\n" \
"MODULE_0=coretemp\n" \
"MODULE_1=f71882fg"
static void test_load_env_file_1(void) {
int r;
char name[] = "/tmp/test-load-env-file.XXXXXX";
assert(r == 0);
}
static void test_load_env_file_2(void) {
int r;
char name[] = "/tmp/test-load-env-file.XXXXXX";
assert(r == 0);
}
static void test_load_env_file_3(void) {
int r;
char name[] = "/tmp/test-load-env-file.XXXXXX";
assert(r == 0);
}
static void test_load_env_file_4(void) {
int r;
char name[] = "/tmp/test-load-env-file.XXXXXX";
assert(r == 0);
}
static void test_install_printf(void) {
path[] = "/run/systemd/system/name.service",
user[] = "xxxx-no-such-user";
char name3[] = "name@inst.service",
path3[] = "/run/systemd/system/name.service";
do { \
_cleanup_free_ char \
if (result) { \
printf("%s\n", t); \
} while(false)
}
int r;
log_open();
r = test_unit_file_get_set();
return r;
}