test-path-util.c revision e26d6ce517a49c246141ed20528614823c2f5799
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
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 <unistd.h>
#include "path-util.h"
#include "util.h"
#include "macro.h"
#include "strv.h"
#include "rm-rf.h"
#define test_path_compare(a, b, result) { \
}
static void test_path(void) {
#define test_parent(x, y) { \
_cleanup_free_ char *z = NULL; \
int r = path_get_parent(x, &z); \
}
{
char p2[] = "//aaa/.////ccc";
char p3[] = "/./";
}
}
char *p;
puts(p);
free(p);
puts(p);
free(p);
puts(p);
free(p);
if (!local)
free(p);
}
static void test_prefixes(void) {
unsigned i;
char s[PATH_MAX];
bool b;
i = 0;
PATH_FOREACH_PREFIX_MORE(s, "/a/b/c/d") {
log_error("---%s---", s);
}
i = 1;
PATH_FOREACH_PREFIX(s, "/a/b/c/d") {
log_error("---%s---", s);
}
i = 0;
PATH_FOREACH_PREFIX_MORE(s, "////a////b////c///d///////")
i = 1;
PATH_FOREACH_PREFIX(s, "////a////b////c///d///////")
PATH_FOREACH_PREFIX(s, "////")
assert_not_reached("Wut?");
b = false;
PATH_FOREACH_PREFIX_MORE(s, "////") {
assert_se(!b);
b = true;
}
assert_se(b);
PATH_FOREACH_PREFIX(s, "")
assert_not_reached("wut?");
b = false;
PATH_FOREACH_PREFIX_MORE(s, "") {
assert_se(!b);
b = true;
}
}
static void test_path_join(void) {
_cleanup_free_ char *z = NULL; \
}
}
static void test_fsck_exists(void) {
/* Ensure we use a sane default for PATH. */
unsetenv("PATH");
/* fsck.minix is provided by util-linux and will probably exist. */
}
static void test_make_relative(void) {
char *result;
_cleanup_free_ char *z = NULL; \
}
test("//extra/////slashes///won't////fool///anybody//", "////extra///slashes////are/just///fine///", "../../../are/just/fine");
}
static void test_strv_resolve(void) {
char tmp_dir[] = "/tmp/test-path-util-XXXXXX";
char **d;
STRV_FOREACH(d, search_dirs) {
assert_se(p);
}
}
static void test_path_startswith(void) {
}
static void test_prefix_root_one(const char *r, const char *p, const char *expected) {
_cleanup_free_ char *s = NULL;
const char *t;
assert_se(s = prefix_root(r, p));
t = prefix_roota(r, p);
assert_se(t);
}
static void test_prefix_root(void) {
}
static void test_path_is_mount_point(void) {
char tmp_dir[] = "/tmp/test-path-is-mount-point-XXXXXX";
/* file mountpoints */
/* this test will only work as root */
} else
printf("Skipping bind mount file test: %m\n");
}
test_path();
test_find_binary(argv[0], true);
test_find_binary(argv[0], false);
return 0;
}