test-unit-file.c revision f73141d7657b3f60b8669bc8386413d8a8a372c6
/*-*- 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"
static void test_unit_file_get_set(void) {
int r;
Hashmap *h;
Iterator i;
UnitFileList *p;
assert(h);
assert(r >= 0);
HASHMAP_FOREACH(p, h, i)
}
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"
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_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 { \
char _cleanup_free_ \
if (result) { \
printf("%s\n", t); \
} while(false)
}
return 0;
}