OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #if defined(OS_POSIX) |
| 6 #include <unistd.h> |
| 7 #endif |
| 8 |
| 9 #include "base/files/file.h" |
| 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/posix/eintr_wrapper.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 namespace { |
| 15 |
| 16 #if defined(OS_POSIX) && GTEST_HAS_DEATH_TEST |
| 17 |
| 18 TEST(ProtectFilePosixDeathTest, CloseProtected) { |
| 19 base::ScopedTempDir temp_dir; |
| 20 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 21 base::FilePath file_path = temp_dir.path().AppendASCII("new_file"); |
| 22 base::File file(file_path, |
| 23 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ); |
| 24 EXPECT_TRUE(file.IsValid()); |
| 25 int fd = file.GetPlatformFile(); |
| 26 EXPECT_DEATH(IGNORE_EINTR(close(fd)), ""); |
| 27 } |
| 28 |
| 29 #endif // defined(OS_POSIX) && GTEST_HAS_DEATH_TEST |
| 30 |
| 31 } // namespace |
OLD | NEW |