diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/syscalls/linux/creat.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/syscalls/linux/creat.cc b/test/syscalls/linux/creat.cc index 72a016b4c..df2cc0d5c 100644 --- a/test/syscalls/linux/creat.cc +++ b/test/syscalls/linux/creat.cc @@ -51,6 +51,17 @@ TEST(CreatTest, CreatTruncatesExistingFile) { EXPECT_EQ("", new_contents); } +TEST(CreatTest, CreatWithNameTooLong) { + // Start with a unique name, and pad it to NAME_MAX + 1; + std::string name = NewTempRelPath(); + int padding = (NAME_MAX + 1) - name.size(); + name.append(padding, 'x'); + const std::string& path = JoinPath(GetAbsoluteTestTmpdir(), name); + + // Creation should return ENAMETOOLONG. + ASSERT_THAT(creat(path.c_str(), kMode), SyscallFailsWithErrno(ENAMETOOLONG)); +} + } // namespace } // namespace testing |