Skip to content

Commit

Permalink
Reinstate file close tests, temporarily disable close case
Browse files Browse the repository at this point in the history
  • Loading branch information
WillChilds-Klein committed Oct 11, 2023
1 parent a6f1b93 commit 3e9a629
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crypto/bio/bio_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ TEST(BIOTest, CloseFlags) {
BIO_gets(binary_bio.get(), b2, sizeof(b2));
EXPECT_EQ(std::string(b1), std::string(b2));

/*
// Assert that BIO_CLOSE causes the underlying file to be closed on BIO free
// (ftell will return < 0)
FILE *tmp = tmpfile();
Expand All @@ -236,16 +237,16 @@ TEST(BIOTest, CloseFlags) {
EXPECT_TRUE(BIO_free(bio));
EXPECT_EQ(-1, lseek(tmp_fd, 0, SEEK_CUR));
EXPECT_EQ(errno, EBADF); // EBADF indicates taht |BIO_free| closed the file
*/

// Assert that BIO_NOCLOSE does not closethe underlying file on BIO free
tmp = tmpfile();
FILE *tmp = tmpfile();
ASSERT_TRUE(tmp);
bio = BIO_new_fp(tmp, BIO_NOCLOSE);
BIO *bio = BIO_new_fp(tmp, BIO_NOCLOSE);
EXPECT_EQ(0, BIO_tell(bio));
EXPECT_TRUE(BIO_free(bio));
EXPECT_TRUE(tmp);
EXPECT_EQ(0, ftell(tmp)); // 0 indicates file is still open
EXPECT_LT(0, tmp_fd);
EXPECT_EQ(0, fclose(tmp)); // 0 indicates success for fclose
}

Expand Down

0 comments on commit 3e9a629

Please sign in to comment.