From 3d305f1d62107d5261bad1c45a0a441d98dc4d41 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 21 Oct 2013 19:27:19 -0700 Subject: [PATCH] Fix statvfs tests for the host. Using /proc seems like a better idea because it's more similar across devices. I've switched to ensuring we check the initial and final elements in the struct too, so we have more reason to believe the whole struct is converted correctly. Change-Id: Ia23403369485747c1452292f6c9df2bb233c04fb --- tests/statvfs_test.cpp | 46 +++++++++++++----------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/tests/statvfs_test.cpp b/tests/statvfs_test.cpp index 31ce66aee..1afb9c673 100644 --- a/tests/statvfs_test.cpp +++ b/tests/statvfs_test.cpp @@ -22,50 +22,32 @@ #include #include +#include + TEST(statvfs, statvfs) { struct statvfs sb; memset(&sb, 0, sizeof(sb)); - ASSERT_EQ(0, statvfs("/", &sb)); -#if __BIONIC__ - ASSERT_EQ(0U, sb.f_bfree); - ASSERT_EQ(0U, sb.f_ffree); - ASSERT_EQ(0U, sb.f_fsid); - ASSERT_TRUE((sb.f_flag & ST_RDONLY) != 0); -#endif + ASSERT_EQ(0, statvfs("/proc", &sb)); -#if __BIONIC__ - ASSERT_EQ(0, statvfs("/data/local/tmp", &sb)); - ASSERT_NE(0U, sb.f_bfree); - ASSERT_NE(0U, sb.f_ffree); - ASSERT_NE(0U, sb.f_fsid); - ASSERT_FALSE((sb.f_flag & ST_RDONLY) != 0); - ASSERT_TRUE((sb.f_flag & ST_NOSUID) != 0); -#endif + EXPECT_EQ(4096U, sb.f_bsize); + EXPECT_EQ(0U, sb.f_bfree); + EXPECT_EQ(0U, sb.f_ffree); + EXPECT_EQ(0U, sb.f_fsid); + EXPECT_EQ(255U, sb.f_namemax); } TEST(statvfs, fstatvfs) { struct statvfs sb; memset(&sb, 0, sizeof(sb)); - int fd = open("/", O_RDONLY); + int fd = open("/proc", O_RDONLY); ASSERT_EQ(0, fstatvfs(fd, &sb)); close(fd); -#if __BIONIC__ - ASSERT_EQ(0U, sb.f_bfree); - ASSERT_EQ(0U, sb.f_ffree); - ASSERT_EQ(0U, sb.f_fsid); - ASSERT_TRUE((sb.f_flag & ST_RDONLY) != 0); -#endif -#if __BIONIC__ - fd = open("/data/local/tmp", O_RDONLY); - ASSERT_EQ(0, fstatvfs(fd, &sb)); - close(fd); - ASSERT_NE(0U, sb.f_bfree); - ASSERT_NE(0U, sb.f_ffree); - ASSERT_NE(0U, sb.f_fsid); - ASSERT_FALSE((sb.f_flag & ST_RDONLY) != 0); - ASSERT_TRUE((sb.f_flag & ST_NOSUID) != 0); -#endif + EXPECT_EQ(4096U, sb.f_bsize); + EXPECT_EQ(0U, sb.f_bfree); + EXPECT_EQ(0U, sb.f_ffree); + EXPECT_EQ(0U, sb.f_fsid); + EXPECT_EQ(255U, sb.f_namemax); }