]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-stat-util.c
2 This file is part of systemd.
4 Copyright 2010 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include "alloc-util.h"
27 #include "stat-util.h"
29 static void test_files_same(void) {
30 _cleanup_close_
int fd
= -1;
31 char name
[] = "/tmp/test-files_same.XXXXXX";
32 char name_alias
[] = "/tmp/test-files_same.alias";
34 fd
= mkostemp_safe(name
, O_RDWR
|O_CLOEXEC
);
36 assert_se(symlink(name
, name_alias
) >= 0);
38 assert_se(files_same(name
, name
));
39 assert_se(files_same(name
, name_alias
));
45 static void test_is_symlink(void) {
46 char name
[] = "/tmp/test-is_symlink.XXXXXX";
47 char name_link
[] = "/tmp/test-is_symlink.link";
48 _cleanup_close_
int fd
= -1;
50 fd
= mkostemp_safe(name
, O_RDWR
|O_CLOEXEC
);
52 assert_se(symlink(name
, name_link
) >= 0);
54 assert_se(is_symlink(name
) == 0);
55 assert_se(is_symlink(name_link
) == 1);
56 assert_se(is_symlink("/a/file/which/does/not/exist/i/guess") < 0);
63 int main(int argc
, char *argv
[]) {