Skip to content

Commit 462f1f1

Browse files
committed
[compiler-rt][rtsan] Fix failing file permissions test
1 parent 4d96eaf commit 462f1f1

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
@@ -194,6 +194,9 @@ TEST_F(RtsanFileTest, OpenatDiesWhenRealtime) {
194194
}
195195

196196
TEST_F(RtsanFileTest, OpenCreatesFileWithProperMode) {
197+
const mode_t existing_umask = umask(0);
198+
umask(existing_umask);
199+
197200
const int mode = S_IRGRP | S_IROTH | S_IRUSR | S_IWUSR;
198201

199202
const int fd = open(GetTemporaryFilePath(), O_CREAT | O_WRONLY, mode);
@@ -204,7 +207,9 @@ TEST_F(RtsanFileTest, OpenCreatesFileWithProperMode) {
204207
ASSERT_THAT(stat(GetTemporaryFilePath(), &st), Eq(0));
205208

206209
// Mask st_mode to get permission bits only
207-
ASSERT_THAT(st.st_mode & 0777, Eq(mode));
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));
208213
}
209214

210215
TEST_F(RtsanFileTest, CreatDiesWhenRealtime) {

0 commit comments

Comments
 (0)