| Index: base/files/protect_file_posix_unittest.cc
|
| diff --git a/base/files/protect_file_posix_unittest.cc b/base/files/protect_file_posix_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e8ddeaea636082d7e0ce9e8e21529b7bc9d770d3
|
| --- /dev/null
|
| +++ b/base/files/protect_file_posix_unittest.cc
|
| @@ -0,0 +1,31 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#if defined(OS_POSIX)
|
| +#include <unistd.h>
|
| +#endif
|
| +
|
| +#include "base/files/file.h"
|
| +#include "base/files/scoped_temp_dir.h"
|
| +#include "base/posix/eintr_wrapper.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace {
|
| +
|
| +#if defined(OS_POSIX) && GTEST_HAS_DEATH_TEST
|
| +
|
| +TEST(ProtectFilePosixDeathTest, CloseProtected) {
|
| + base::ScopedTempDir temp_dir;
|
| + ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
|
| + base::FilePath file_path = temp_dir.path().AppendASCII("new_file");
|
| + base::File file(file_path,
|
| + base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ);
|
| + EXPECT_TRUE(file.IsValid());
|
| + int fd = file.GetPlatformFile();
|
| + EXPECT_DEATH(IGNORE_EINTR(close(fd)), "");
|
| +}
|
| +
|
| +#endif // defined(OS_POSIX) && GTEST_HAS_DEATH_TEST
|
| +
|
| +} // namespace
|
|
|