Test retry on EINTR in close.
This commit is contained in:
parent
41895fdf42
commit
232e5c3a3b
@ -56,7 +56,6 @@ namespace {
|
||||
#ifdef _WIN32
|
||||
// On Windows the count argument to read and write is unsigned, so convert
|
||||
// it from size_t preventing integer overflow.
|
||||
// TODO: test
|
||||
inline unsigned ConvertRWCount(std::size_t count) {
|
||||
return count <= UINT_MAX ? static_cast<unsigned>(count) : UINT_MAX;
|
||||
}
|
||||
|
@ -119,4 +119,28 @@ TEST(FileTest, OpenRetry) {
|
||||
open, "cannot open file CMakeLists.txt");
|
||||
}
|
||||
|
||||
TEST(FileTest, CloseNoRetryInDtor) {
|
||||
File read_end, write_end;
|
||||
File::pipe(read_end, write_end);
|
||||
File *f = new File(std::move(read_end));
|
||||
int saved_close_count = 0;
|
||||
EXPECT_WRITE(stderr, {
|
||||
close_count = 1;
|
||||
delete f;
|
||||
saved_close_count = close_count;
|
||||
close_count = 0;
|
||||
}, FormatSystemErrorMessage(EINTR, "cannot close file") + "\n");
|
||||
EXPECT_EQ(2, saved_close_count);
|
||||
}
|
||||
|
||||
TEST(FileTest, CloseNoRetry) {
|
||||
File read_end, write_end;
|
||||
File::pipe(read_end, write_end);
|
||||
close_count = 1;
|
||||
EXPECT_SYSTEM_ERROR(read_end.close(), EINTR, "cannot close file");
|
||||
EXPECT_EQ(2, close_count);
|
||||
close_count = 0;
|
||||
}
|
||||
|
||||
// TODO: test retry on EINTR
|
||||
// TODO: test ConvertRWCount
|
||||
|
Loading…
Reference in New Issue
Block a user