diff options
author | Rahat Mahmood <rahat@google.com> | 2021-04-22 15:50:01 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-04-22 15:52:24 -0700 |
commit | d93907110eebdfb1e51dacd9ccffd0f0c2633a81 (patch) | |
tree | 5941c19d879269244b71031bffa437af895728a6 /test/syscalls/linux/mount.cc | |
parent | dbfdb31e8a014e5e11092de121e825b21c2804c3 (diff) |
Also report mount options through /proc/<pid>/mounts.
PiperOrigin-RevId: 369967629
Diffstat (limited to 'test/syscalls/linux/mount.cc')
-rw-r--r-- | test/syscalls/linux/mount.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/syscalls/linux/mount.cc b/test/syscalls/linux/mount.cc index 15b645fb7..cdc223d07 100644 --- a/test/syscalls/linux/mount.cc +++ b/test/syscalls/linux/mount.cc @@ -26,6 +26,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "absl/time/time.h" #include "test/util/capability_util.h" @@ -44,6 +45,9 @@ namespace testing { namespace { +using ::testing::Contains; +using ::testing::Pair; + TEST(MountTest, MountBadFilesystem) { SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN))); @@ -345,6 +349,35 @@ TEST(MountTest, RenameRemoveMountPoint) { ASSERT_THAT(rmdir(dir.path().c_str()), SyscallFailsWithErrno(EBUSY)); } +TEST(MountTest, MountInfo) { + SKIP_IF(IsRunningWithVFS1()); + SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN))); + + auto const dir = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir()); + auto const mount = ASSERT_NO_ERRNO_AND_VALUE( + Mount("", dir.path(), "tmpfs", MS_NOEXEC, "mode=0123", 0)); + const std::vector<ProcMountsEntry> mounts = + ASSERT_NO_ERRNO_AND_VALUE(ProcSelfMountsEntries()); + for (const auto& e : mounts) { + if (e.mount_point == dir.path()) { + EXPECT_EQ(e.fstype, "tmpfs"); + auto mopts = ParseMountOptions(e.mount_opts); + EXPECT_THAT(mopts, Contains(Pair("mode", "0123"))); + } + } + + const std::vector<ProcMountInfoEntry> mountinfo = + ASSERT_NO_ERRNO_AND_VALUE(ProcSelfMountInfoEntries()); + + for (auto const& e : mountinfo) { + if (e.mount_point == dir.path()) { + EXPECT_EQ(e.fstype, "tmpfs"); + auto mopts = ParseMountOptions(e.super_opts); + EXPECT_THAT(mopts, Contains(Pair("mode", "0123"))); + } + } +} + } // namespace } // namespace testing |