@@ -449,12 +449,6 @@ TEST_F(RtsanFileTest, FcntlSetFdDiesWhenRealtime) {
449
449
close (fd);
450
450
}
451
451
452
- TEST (TestRtsanInterceptors, CloseDiesWhenRealtime) {
453
- auto Func = []() { close (0 ); };
454
- ExpectRealtimeDeath (Func, " close" );
455
- ExpectNonRealtimeSurvival (Func);
456
- }
457
-
458
452
TEST (TestRtsanInterceptors, ChdirDiesWhenRealtime) {
459
453
auto Func = []() { chdir (" ." ); };
460
454
ExpectRealtimeDeath (Func, " chdir" );
@@ -606,8 +600,10 @@ class RtsanOpenedFileTest : public RtsanFileTest {
606
600
}
607
601
608
602
void TearDown () override {
609
- if (file != nullptr )
603
+ const bool is_open = fcntl (fd, F_GETFD) != -1 ;
604
+ if (is_open && file != nullptr )
610
605
fclose (file);
606
+
611
607
RtsanFileTest::TearDown ();
612
608
}
613
609
@@ -620,6 +616,16 @@ class RtsanOpenedFileTest : public RtsanFileTest {
620
616
int fd = -1 ;
621
617
};
622
618
619
+ TEST_F (RtsanOpenedFileTest, CloseDiesWhenRealtime) {
620
+ auto Func = [this ]() { close (GetOpenFd ()); };
621
+ ExpectRealtimeDeath (Func, " close" );
622
+ }
623
+
624
+ TEST_F (RtsanOpenedFileTest, CloseSurvivesWhenNotRealtime) {
625
+ auto Func = [this ]() { close (GetOpenFd ()); };
626
+ ExpectNonRealtimeSurvival (Func);
627
+ }
628
+
623
629
#if SANITIZER_INTERCEPT_FSEEK
624
630
TEST_F (RtsanOpenedFileTest, FgetposDieWhenRealtime) {
625
631
auto Func = [this ]() {
0 commit comments