Skip to content

Commit 5ea9ff3

Browse files
committed
[compiler-rt][rtsan] Fix failing file permissions test
1 parent c04e56a commit 5ea9ff3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler-rt/lib/rtsan/tests/rtsan_test_interceptors.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ TEST_F(RtsanFileTest, OpenatDiesWhenRealtime) {
185185
}
186186

187187
TEST_F(RtsanFileTest, OpenCreatesFileWithProperMode) {
188+
const mode_t existing_umask = umask(0);
189+
umask(existing_umask);
190+
188191
const int mode = S_IRGRP | S_IROTH | S_IRUSR | S_IWUSR;
189192

190193
const int fd = open(GetTemporaryFilePath(), O_CREAT | O_WRONLY, mode);
@@ -195,7 +198,9 @@ TEST_F(RtsanFileTest, OpenCreatesFileWithProperMode) {
195198
ASSERT_THAT(stat(GetTemporaryFilePath(), &st), Eq(0));
196199

197200
// Mask st_mode to get permission bits only
198-
ASSERT_THAT(st.st_mode & 0777, Eq(mode));
201+
const mode_t actual_mode = st.st_mode & 0777;
202+
const mode_t expected_mode = mode & ~existing_umask;
203+
ASSERT_THAT(actual_mode, Eq(expected_mode));
199204
}
200205

201206
TEST_F(RtsanFileTest, CreatDiesWhenRealtime) {

0 commit comments

Comments
 (0)