mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Emulate ENOTDIR better
This commit is contained in:
parent
b76b2be2d0
commit
8d1c81ac9f
35 changed files with 80 additions and 50 deletions
|
@ -47,6 +47,9 @@ TEST(open, enoent) {
|
|||
|
||||
TEST(open, enotdir) {
|
||||
ASSERT_SYS(0, 0, touch("o", 0644));
|
||||
ASSERT_SYS(ENOTDIR, -1, open("o/", O_RDONLY));
|
||||
ASSERT_SYS(ENOTDIR, -1, open("o/.", O_RDONLY));
|
||||
ASSERT_SYS(ENOTDIR, -1, open("o/./", O_RDONLY));
|
||||
ASSERT_SYS(ENOTDIR, -1, open("o/doesnotexist", O_RDONLY));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/mem/gc.h"
|
||||
|
@ -82,3 +83,12 @@ TEST(zipos_O_DIRECTORY, blocksOpeningOfNormalFiles) {
|
|||
ASSERT_SYS(ENOTDIR, -1,
|
||||
open("/zip/libc/testlib/hyperion.txt", O_RDONLY | O_DIRECTORY));
|
||||
}
|
||||
|
||||
TEST(zipos, trailingComponents_willEnodirFile) {
|
||||
struct stat st;
|
||||
ASSERT_SYS(ENOTDIR, -1, open("/zip/libc/testlib/hyperion.txt/", O_RDONLY));
|
||||
ASSERT_SYS(ENOTDIR, -1, open("/zip/libc/testlib/hyperion.txt/.", O_RDONLY));
|
||||
ASSERT_SYS(ENOTDIR, -1, open("/zip/libc/testlib/hyperion.txt/./", O_RDONLY));
|
||||
ASSERT_SYS(ENOTDIR, -1, open("/zip/libc/testlib/hyperion.txt/a/b", O_RDONLY));
|
||||
ASSERT_SYS(ENOTDIR, -1, stat("/zip/libc/testlib/hyperion.txt/", &st));
|
||||
}
|
||||
|
|
|
@ -93,9 +93,10 @@ TEST(__zipos_normpath, vectors) {
|
|||
{"./", ""},
|
||||
{"..", ""},
|
||||
{"../", ""},
|
||||
{"foo/", "foo/"},
|
||||
{"../abc/def", "abc/def"},
|
||||
{"../abc/def/..", "abc"},
|
||||
{"../abc/././././def/..", "abc"},
|
||||
{"../abc/def/..", "abc/"},
|
||||
{"../abc/././././def/..", "abc/"},
|
||||
{"////../abc/def", "abc/def"},
|
||||
{"/../def", "def"},
|
||||
{"../def", "def"},
|
||||
|
@ -121,11 +122,11 @@ TEST(__zipos_normpath, vectors) {
|
|||
{"../../../a", "a"},
|
||||
{"../a../../a", "a"},
|
||||
{"cccc/abc////..////.//../", ""},
|
||||
{"aaaa/cccc/abc////..////.//../", "aaaa"},
|
||||
{"..//////.///..////..////.//////abc////.////..////def//abc/..", "def"},
|
||||
{"aaaa/cccc/abc////..////.//../", "aaaa/"},
|
||||
{"..//////.///..////..////.//////abc////.////..////def//abc/..", "def/"},
|
||||
{"////////////..//////.///..////..////.//////abc////.////..////def//abc/"
|
||||
"..",
|
||||
"def"},
|
||||
"def/"},
|
||||
};
|
||||
int fails = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue