#include "base/files/scoped_file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace {
class ScopedFDOwnershipTrackingTest : public testing::Test { … };
TEST_F(ScopedFDOwnershipTrackingTest, BasicTracking) { … }
#if defined(GTEST_HAS_DEATH_TEST) && !defined(COMPONENT_BUILD)
TEST_F(ScopedFDOwnershipTrackingTest, NoDoubleOwnership) {
ScopedFD fd = OpenFD();
subtle::EnableFDOwnershipEnforcement(true);
EXPECT_DEATH(ScopedFD(fd.get()), "");
}
TEST_F(ScopedFDOwnershipTrackingTest, CrashOnUnownedClose) {
ScopedFD fd = OpenFD();
subtle::EnableFDOwnershipEnforcement(true);
EXPECT_DEATH(close(fd.get()), "");
}
#endif
}
}