@@ -193,25 +193,24 @@ TEST_F(RtsanFileTest, OpenatDiesWhenRealtime) {
193193 ExpectNonRealtimeSurvival (func);
194194}
195195
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+ }
215214
216215TEST_F (RtsanFileTest, CreatDiesWhenRealtime) {
217216 auto func = [this ]() { creat (GetTemporaryFilePath (), S_IWOTH | S_IROTH); };
0 commit comments