diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-09-27 15:18:09 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-09-27 15:18:09 -0700 |
commit | 8539abc0df3f4b092f83c856be1d04387e5158cc (patch) | |
tree | 8ad468c5e7d72a5c3348cae9181125e12ed0a290 /test/syscalls | |
parent | abbee5615f4480d8a41b4cf63839d2ab13b19abf (diff) | |
parent | 223481e92743f305ada22689f4ba41b36119d5fc (diff) |
Merge pull request #864 from tanjianfeng:fix-861
PiperOrigin-RevId: 271649711
Diffstat (limited to 'test/syscalls')
-rw-r--r-- | test/syscalls/linux/uname.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/syscalls/linux/uname.cc b/test/syscalls/linux/uname.cc index 0a5d91017..d8824b171 100644 --- a/test/syscalls/linux/uname.cc +++ b/test/syscalls/linux/uname.cc @@ -41,6 +41,19 @@ TEST(UnameTest, Sanity) { TEST(UnameTest, SetNames) { SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN))); + char hostname[65]; + ASSERT_THAT(sethostname("0123456789", 3), SyscallSucceeds()); + EXPECT_THAT(gethostname(hostname, sizeof(hostname)), SyscallSucceeds()); + EXPECT_EQ(absl::string_view(hostname), "012"); + + ASSERT_THAT(sethostname("0123456789\0xxx", 11), SyscallSucceeds()); + EXPECT_THAT(gethostname(hostname, sizeof(hostname)), SyscallSucceeds()); + EXPECT_EQ(absl::string_view(hostname), "0123456789"); + + ASSERT_THAT(sethostname("0123456789\0xxx", 12), SyscallSucceeds()); + EXPECT_THAT(gethostname(hostname, sizeof(hostname)), SyscallSucceeds()); + EXPECT_EQ(absl::string_view(hostname), "0123456789"); + constexpr char kHostname[] = "wubbalubba"; ASSERT_THAT(sethostname(kHostname, sizeof(kHostname)), SyscallSucceeds()); @@ -54,7 +67,6 @@ TEST(UnameTest, SetNames) { EXPECT_EQ(absl::string_view(buf.domainname), kDomainname); // These should just be glibc wrappers that also call uname(2). - char hostname[65]; EXPECT_THAT(gethostname(hostname, sizeof(hostname)), SyscallSucceeds()); EXPECT_EQ(absl::string_view(hostname), kHostname); |