mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-21 18:03:41 +03:00
test-fs-util: Add relative path chase_symlinks() tests
(cherry picked from commit 94799c305acad138ce62e562318fbe7936a50dce) (cherry picked from commit dbc59253ec1a43fd5d1850afa563037df13ca706)
This commit is contained in:
parent
d206b0c925
commit
07b62913a6
@ -28,7 +28,7 @@
|
||||
static const char *arg_test_dir = NULL;
|
||||
|
||||
TEST(chase_symlinks) {
|
||||
_cleanup_free_ char *result = NULL;
|
||||
_cleanup_free_ char *result = NULL, *pwd = NULL;
|
||||
_cleanup_close_ int pfd = -1;
|
||||
char *temp;
|
||||
const char *top, *p, *pslash, *q, *qslash;
|
||||
@ -246,6 +246,30 @@ TEST(chase_symlinks) {
|
||||
assert_se(path_equal(result, p));
|
||||
result = mfree(result);
|
||||
|
||||
/* Relative paths */
|
||||
|
||||
assert_se(safe_getcwd(&pwd) >= 0);
|
||||
|
||||
assert_se(chdir(temp) >= 0);
|
||||
|
||||
p = "this/is/a/relative/path";
|
||||
r = chase_symlinks(p, NULL, CHASE_NONEXISTENT, &result, NULL);
|
||||
assert_se(r == 0);
|
||||
|
||||
p = strjoina(temp, "/", p);
|
||||
assert_se(path_equal(result, p));
|
||||
result = mfree(result);
|
||||
|
||||
p = "this/is/a/relative/path";
|
||||
r = chase_symlinks(p, temp, CHASE_NONEXISTENT, &result, NULL);
|
||||
assert_se(r == 0);
|
||||
|
||||
p = strjoina(temp, "/", p);
|
||||
assert_se(path_equal(result, p));
|
||||
result = mfree(result);
|
||||
|
||||
assert_se(chdir(pwd) >= 0);
|
||||
|
||||
/* Path which doesn't exist, but contains weird stuff */
|
||||
|
||||
p = strjoina(temp, "/idontexist/..");
|
||||
|
Loading…
x
Reference in New Issue
Block a user