@@ -193,25 +193,24 @@ TEST_F(RtsanFileTest, OpenatDiesWhenRealtime) {
193
193
ExpectNonRealtimeSurvival (func);
194
194
}
195
195
196
- // FIXME: This fails on the build machines, but not locally!
197
- // see https://github.com/llvm/llvm-project/pull/105732#issuecomment-2310286530
198
- // Value of: st.st_mode & 0777
199
- // Expected: is equal to 420
200
- // Actual: 384
201
- // TEST_F(RtsanFileTest, OpenCreatesFileWithProperMode) {
202
- // const int mode = S_IRGRP | S_IROTH | S_IRUSR | S_IWUSR;
203
- //
204
- // const int fd = open(GetTemporaryFilePath(), O_CREAT | O_WRONLY, mode);
205
- // ASSERT_THAT(fd, Ne(-1));
206
- // close(fd);
207
- //
208
- // struct stat st;
209
- // ASSERT_THAT(stat(GetTemporaryFilePath(), &st), Eq(0));
210
- //
211
- // // Mask st_mode to get permission bits only
212
- //
213
- // //ASSERT_THAT(st.st_mode & 0777, Eq(mode)); FAILED ASSERTION
214
- // }
196
+ TEST_F (RtsanFileTest, OpenCreatesFileWithProperMode) {
197
+ const mode_t existing_umask = umask (0 );
198
+ umask (existing_umask);
199
+
200
+ const int mode = S_IRGRP | S_IROTH | S_IRUSR | S_IWUSR;
201
+
202
+ const int fd = open (GetTemporaryFilePath (), O_CREAT | O_WRONLY, mode);
203
+ ASSERT_THAT (fd, Ne (-1 ));
204
+ close (fd);
205
+
206
+ struct stat st;
207
+ ASSERT_THAT (stat (GetTemporaryFilePath (), &st), Eq (0 ));
208
+
209
+ // Mask st_mode to get permission bits only
210
+ const mode_t actual_mode = st.st_mode & 0777 ;
211
+ const mode_t expected_mode = mode & ~existing_umask;
212
+ ASSERT_THAT (actual_mode, Eq (expected_mode));
213
+ }
215
214
216
215
TEST_F (RtsanFileTest, CreatDiesWhenRealtime) {
217
216
auto func = [this ]() { creat (GetTemporaryFilePath (), S_IWOTH | S_IROTH); };
0 commit comments