Fix some issues and do some code cleanup

This commit is contained in:
Justine Tunney 2022-05-23 10:15:53 -07:00
parent 1f229e4efc
commit 312ed5c67c
72 changed files with 880 additions and 982 deletions

View file

@ -55,6 +55,18 @@ TEST(open, enametoolong) {
ASSERT_SYS(ENAMETOOLONG, -1, creat(s, 0644));
}
TEST(open, testSpaceInFilename) {
char buf[8] = {0};
ASSERT_SYS(0, 0, xbarf("hello txt", "hello", -1));
ASSERT_SYS(0, 3, open("hello txt", O_WRONLY));
EXPECT_SYS(0, 1, write(3, "H", 1));
EXPECT_SYS(0, 0, close(3));
ASSERT_SYS(0, 3, open("hello txt", O_RDONLY));
EXPECT_SYS(0, 5, read(3, buf, 7));
EXPECT_STREQ("Hello", buf);
EXPECT_SYS(0, 0, close(3));
}
TEST(open, testOpenExistingForWriteOnly_seeksToStart) {
char buf[8] = {0};
ASSERT_SYS(0, 0, xbarf("hello.txt", "hello", -1));