summaryrefslogtreecommitdiff
path: root/libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp
diff options
context:
space:
mode:
authorMikhail R. Gadelha <mikhail@igalia.com>2024-07-22 02:21:05 +0200
committerGitHub <noreply@github.com>2024-07-21 21:21:05 -0300
commiteaa07c00b10b2105fabed61a95d2a5e0971bc02e (patch)
treeb8efb55385feff725db50f556af17d26432a07d9 /libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp
parent74a1ca504bf60f02431140ee72dbe1c158556237 (diff)
[libc] Fix statvfs test case when SYS_statfs64 is used (#99827)
When SYS_statfs64 is used, struct statfs64 is used instead of struct statfs. This patch adds a define to select the appropriate struct, similar to how it's done internally. This patch also enables fstatvfs and statvfs on riscv, which would not be compiled without this change.
Diffstat (limited to 'libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp')
-rw-r--r--libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp b/libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp
index 0895c3316715..8cb5f867453e 100644
--- a/libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp
+++ b/libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp
@@ -9,10 +9,16 @@
#include <linux/magic.h>
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
+#ifdef SYS_statfs64
+using StatFs = statfs64;
+#else
+using StatFs = statfs;
+#endif
+
namespace LIBC_NAMESPACE_DECL {
-static int fstatfs(int fd, struct statfs *buf) {
+static int fstatfs(int fd, StatFs *buf) {
using namespace statfs_utils;
- if (cpp::optional<LinuxStatFs> result = linux_fstatfs(fd)) {
+ if (cpp::optional<StatFs> result = linux_fstatfs(fd)) {
*buf = *result;
return 0;
}
@@ -29,7 +35,7 @@ struct PathFD {
};
TEST(LlvmLibcSysStatvfsTest, FstatfsBasic) {
- struct statfs buf;
+ StatFs buf;
ASSERT_THAT(LIBC_NAMESPACE::fstatfs(PathFD("/"), &buf), Succeeds());
ASSERT_THAT(LIBC_NAMESPACE::fstatfs(PathFD("/proc"), &buf), Succeeds());
ASSERT_EQ(buf.f_type, static_cast<decltype(buf.f_type)>(PROC_SUPER_MAGIC));