2 * Copyright (C) 2013 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <gtest/gtest.h>
19 #include <sys/statvfs.h>
21 #include <sys/types.h>
27 template <typename StatVfsT> void Check(StatVfsT& sb) {
28 EXPECT_EQ(4096U, sb.f_bsize);
29 EXPECT_EQ(0U, sb.f_bfree);
30 EXPECT_EQ(0U, sb.f_ffree);
31 EXPECT_EQ(0U, sb.f_fsid);
32 EXPECT_EQ(255U, sb.f_namemax);
34 // The kernel sets a private bit to indicate that f_flags is valid.
35 // This flag is not supposed to be exposed to libc clients.
36 static const uint32_t ST_VALID = 0x0020;
37 EXPECT_TRUE((sb.f_flag & ST_VALID) == 0) << sb.f_flag;
40 TEST(sys_statvfs, statvfs) {
42 ASSERT_EQ(0, statvfs("/proc", &sb));
46 TEST(sys_statvfs, statvfs64) {
48 ASSERT_EQ(0, statvfs64("/proc", &sb));
52 TEST(sys_statvfs, fstatvfs) {
54 int fd = open("/proc", O_RDONLY);
55 ASSERT_EQ(0, fstatvfs(fd, &sb));
60 TEST(sys_statvfs, fstatvfs64) {
62 int fd = open("/proc", O_RDONLY);
63 ASSERT_EQ(0, fstatvfs64(fd, &sb));