From e0ddaaa6290f74fcce6e067c1e5f1c9c87974f4c Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 3 Nov 2021 07:54:29 +0000 Subject: kernel/vfs: tidy up path_simplify, fix a bug and add regression tests the bug related to paths ending with /.. and not resolving to / --- src/kernel/tests/vfs.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/kernel/tests') diff --git a/src/kernel/tests/vfs.c b/src/kernel/tests/vfs.c index 8b450e5..339c6bd 100644 --- a/src/kernel/tests/vfs.c +++ b/src/kernel/tests/vfs.c @@ -38,6 +38,12 @@ TEST(path_simplify) { TEST_WRAPPER("/asdf/.", "/asdf/"); TEST_WRAPPER("/asdf//.", "/asdf/"); + TEST_WRAPPER("/foo/bar/..", "/foo/"); + TEST_WRAPPER("/foo/bar/../bar", "/foo/bar"); + TEST_WRAPPER("/foo/bar/../bar/", "/foo/bar/"); + TEST_WRAPPER("/foo/bar/xyz/..", "/foo/bar/"); + TEST_WRAPPER("/foo/bar/xyz/../", "/foo/bar/"); + // going under the root or close to it TEST_WRAPPER("/..", NULL); TEST_WRAPPER("/../asdf", NULL); -- cgit v1.2.3