summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/socket.cc
diff options
context:
space:
mode:
authorRahat Mahmood <rahat@google.com>2020-08-28 14:29:16 -0700
committergVisor bot <gvisor-bot@google.com>2020-08-28 14:31:11 -0700
commitb4820e598681c61fbf0e8a7f4d3436d2599ce53c (patch)
tree9e7c5770ba0edba0ae77f35300803c13d6914970 /test/syscalls/linux/socket.cc
parentbdd5996a73b14d6f6600ab7aa00cdaed459cab16 (diff)
Implement StatFS for various VFS2 filesystems.
This mainly involved enabling kernfs' client filesystems to provide a StatFS implementation. Fixes #3411, #3515. PiperOrigin-RevId: 329009864
Diffstat (limited to 'test/syscalls/linux/socket.cc')
-rw-r--r--test/syscalls/linux/socket.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket.cc b/test/syscalls/linux/socket.cc
index c20cd3fcc..e680d3dd7 100644
--- a/test/syscalls/linux/socket.cc
+++ b/test/syscalls/linux/socket.cc
@@ -14,6 +14,7 @@
#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/statfs.h>
#include <sys/types.h>
#include <unistd.h>
@@ -26,6 +27,9 @@
namespace gvisor {
namespace testing {
+// From linux/magic.h, but we can't depend on linux headers here.
+#define SOCKFS_MAGIC 0x534F434B
+
TEST(SocketTest, UnixSocketPairProtocol) {
int socks[2];
ASSERT_THAT(socketpair(AF_UNIX, SOCK_STREAM, PF_UNIX, socks),
@@ -94,6 +98,19 @@ TEST(SocketTest, UnixSocketStat) {
}
}
+TEST(SocketTest, UnixSocketStatFS) {
+ SKIP_IF(IsRunningWithVFS1());
+
+ FileDescriptor bound =
+ ASSERT_NO_ERRNO_AND_VALUE(Socket(AF_UNIX, SOCK_STREAM, PF_UNIX));
+
+ struct statfs st;
+ EXPECT_THAT(fstatfs(bound.get(), &st), SyscallSucceeds());
+ EXPECT_EQ(st.f_type, SOCKFS_MAGIC);
+ EXPECT_EQ(st.f_bsize, getpagesize());
+ EXPECT_EQ(st.f_namelen, NAME_MAX);
+}
+
using SocketOpenTest = ::testing::TestWithParam<int>;
// UDS cannot be opened.