summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorTing-Yu Wang <anivia@google.com>2020-03-09 19:57:35 -0700
committergVisor bot <gvisor-bot@google.com>2020-03-09 19:59:09 -0700
commitb36de6e7be0542b410901d3cbcd1b3c0fc493cf5 (patch)
tree403282c17f58f6535136639b19b30a0209913ec1 /test
parent2446161b3faa352bf28dc83e338f10967f0224c2 (diff)
Move /proc/net to /proc/PID/net, and make /proc/net -> /proc/self/net.
Issue #1833 PiperOrigin-RevId: 299998105
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/linux/proc_net.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/syscalls/linux/proc_net.cc b/test/syscalls/linux/proc_net.cc
index 3a611a86f..05c952b99 100644
--- a/test/syscalls/linux/proc_net.cc
+++ b/test/syscalls/linux/proc_net.cc
@@ -33,6 +33,31 @@ namespace gvisor {
namespace testing {
namespace {
+constexpr const char kProcNet[] = "/proc/net";
+
+TEST(ProcNetSymlinkTarget, FileMode) {
+ struct stat s;
+ ASSERT_THAT(stat(kProcNet, &s), SyscallSucceeds());
+ EXPECT_EQ(s.st_mode & S_IFMT, S_IFDIR);
+ EXPECT_EQ(s.st_mode & 0777, 0555);
+}
+
+TEST(ProcNetSymlink, FileMode) {
+ struct stat s;
+ ASSERT_THAT(lstat(kProcNet, &s), SyscallSucceeds());
+ EXPECT_EQ(s.st_mode & S_IFMT, S_IFLNK);
+ EXPECT_EQ(s.st_mode & 0777, 0777);
+}
+
+TEST(ProcNetSymlink, Contents) {
+ char buf[40] = {};
+ int n = readlink(kProcNet, buf, sizeof(buf));
+ ASSERT_THAT(n, SyscallSucceeds());
+
+ buf[n] = 0;
+ EXPECT_STREQ(buf, "self/net");
+}
+
TEST(ProcNetIfInet6, Format) {
auto ifinet6 = ASSERT_NO_ERRNO_AND_VALUE(GetContents("/proc/net/if_inet6"));
EXPECT_THAT(ifinet6,