diff options
Diffstat (limited to 'tests/unistd_test.cpp')
-rw-r--r-- | tests/unistd_test.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp index 9b811ed4a..cd51e1bfb 100644 --- a/tests/unistd_test.cpp +++ b/tests/unistd_test.cpp @@ -375,7 +375,7 @@ TEST(UNISTD_TEST, clearenv) { EXPECT_EQ(0, unsetenv("test-variable")); } -static void TestFsyncFunction(int (*fn)(int)) { +static void TestSyncFunction(int (*fn)(int)) { int fd; // Can't sync an invalid fd. @@ -401,10 +401,15 @@ static void TestFsyncFunction(int (*fn)(int)) { ASSERT_NE(-1, fd = open("/data/local/tmp", O_RDONLY)); EXPECT_EQ(0, fn(fd)); close(fd); +} + +static void TestFsyncFunction(int (*fn)(int)) { + TestSyncFunction(fn); - // But some file systems may choose to be fussy... + // But some file systems are fussy about fsync/fdatasync... errno = 0; - ASSERT_NE(-1, fd = open("/proc/version", O_RDONLY)); + int fd = open("/proc/version", O_RDONLY); + ASSERT_NE(-1, fd); EXPECT_EQ(-1, fn(fd)); EXPECT_EQ(EINVAL, errno); close(fd); @@ -418,6 +423,10 @@ TEST(UNISTD_TEST, fsync) { TestFsyncFunction(fsync); } +TEST(UNISTD_TEST, syncfs) { + TestSyncFunction(syncfs); +} + static void AssertGetPidCorrect() { // The loop is just to make manual testing/debugging with strace easier. pid_t getpid_syscall_result = syscall(__NR_getpid); |