test-unit-name.c revision 1682ff60114b7a57972a03aa99f9864064593f72
/*-*- 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
#include "manager.h"
#include "unit.h"
#include "unit-name.h"
#include "unit-printf.h"
#include "install.h"
#include "specifier.h"
#include "util.h"
#include "macro.h"
static void test_replacements(void) {
{ \
char _cleanup_free_ *t = \
puts(t); \
}
puts("-------------------------------------------------");
{ \
char _cleanup_free_ *k, *t = \
puts(t); \
k = unit_name_to_path(t); \
puts(k); \
}
puts("-------------------------------------------------");
{ \
char _cleanup_free_ *t = \
puts(t); \
}
puts("-------------------------------------------------");
{ \
char _cleanup_free_ *k, *t; \
assert_se(k = unit_name_mangle(t)); \
puts(t); \
}
expect("/home");
expect("foobar-meh...waldi.service");
expect("_____####----.....service");
expect("_____##@;;;,,,##----.....service");
}
static void test_unit_printf(void) {
Manager *m;
{ \
char _cleanup_free_ *t = \
printf("result: %s\n", t); \
}
/* general tests */
/* normal unit */
/* templated */
}
return 0;
}