41
41
#include < sys/uio.h>
42
42
43
43
#if _FILE_OFFSET_BITS == 64 && SANITIZER_GLIBC
44
- const char *const kCreatFunctionName = " creat64" ;
45
- const char *const kFcntlFunctionName = " fcntl64" ;
46
- const char *const kFopenFunctionName = " fopen64" ;
47
- const char *const kOpenAtFunctionName = " openat64" ;
48
- const char *const kOpenFunctionName = " open64" ;
49
- const char *const kPreadFunctionName = " pread64" ;
50
- const char *const kPwriteFunctionName = " pwrite64" ;
51
- const char *const kMmapFunctionName = " mmap64" ;
44
+ // Under these conditions, some system calls are `foo64` instead of `foo`
45
+ #define MAYBE_APPEND_64 (func ) func " 64"
52
46
#else
53
- const char *const kCreatFunctionName = " creat" ;
54
- const char *const kFcntlFunctionName = " fcntl" ;
55
- const char *const kFopenFunctionName = " fopen" ;
56
- const char *const kOpenAtFunctionName = " openat" ;
57
- const char *const kOpenFunctionName = " open" ;
58
- const char *const kPreadFunctionName = " pread" ;
59
- const char *const kPwriteFunctionName = " pwrite" ;
60
- const char *const kMmapFunctionName = " mmap" ;
47
+ #define MAYBE_APPEND_64 (func ) func
61
48
#endif
62
49
63
50
using namespace testing ;
@@ -187,7 +174,7 @@ TEST(TestRtsanInterceptors, MmapDiesWhenRealtime) {
187
174
void *_ = mmap (nullptr , 8 , PROT_READ | PROT_WRITE,
188
175
MAP_PRIVATE | MAP_ANONYMOUS, -1 , 0 );
189
176
};
190
- ExpectRealtimeDeath (Func, kMmapFunctionName );
177
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " mmap " ) );
191
178
ExpectNonRealtimeSurvival (Func);
192
179
}
193
180
@@ -244,13 +231,13 @@ TEST(TestRtsanInterceptors, NanosleepDiesWhenRealtime) {
244
231
245
232
TEST_F (RtsanFileTest, OpenDiesWhenRealtime) {
246
233
auto Func = [this ]() { open (GetTemporaryFilePath (), O_RDONLY); };
247
- ExpectRealtimeDeath (Func, kOpenFunctionName );
234
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " open " ) );
248
235
ExpectNonRealtimeSurvival (Func);
249
236
}
250
237
251
238
TEST_F (RtsanFileTest, OpenatDiesWhenRealtime) {
252
239
auto Func = [this ]() { openat (0 , GetTemporaryFilePath (), O_RDONLY); };
253
- ExpectRealtimeDeath (Func, kOpenAtFunctionName );
240
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " openat " ) );
254
241
ExpectNonRealtimeSurvival (Func);
255
242
}
256
243
@@ -275,13 +262,13 @@ TEST_F(RtsanFileTest, OpenCreatesFileWithProperMode) {
275
262
276
263
TEST_F (RtsanFileTest, CreatDiesWhenRealtime) {
277
264
auto Func = [this ]() { creat (GetTemporaryFilePath (), S_IWOTH | S_IROTH); };
278
- ExpectRealtimeDeath (Func, kCreatFunctionName );
265
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " creat " ) );
279
266
ExpectNonRealtimeSurvival (Func);
280
267
}
281
268
282
269
TEST (TestRtsanInterceptors, FcntlDiesWhenRealtime) {
283
270
auto Func = []() { fcntl (0 , F_GETFL); };
284
- ExpectRealtimeDeath (Func, kFcntlFunctionName );
271
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " fcntl " ) );
285
272
ExpectNonRealtimeSurvival (Func);
286
273
}
287
274
@@ -300,7 +287,7 @@ TEST_F(RtsanFileTest, FcntlFlockDiesWhenRealtime) {
300
287
ASSERT_THAT (fcntl (fd, F_GETLK, &lock), Eq (0 ));
301
288
ASSERT_THAT (lock.l_type , F_UNLCK);
302
289
};
303
- ExpectRealtimeDeath (Func, kFcntlFunctionName );
290
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " fcntl " ) );
304
291
ExpectNonRealtimeSurvival (Func);
305
292
306
293
close (fd);
@@ -322,7 +309,7 @@ TEST_F(RtsanFileTest, FcntlSetFdDiesWhenRealtime) {
322
309
ASSERT_THAT (fcntl (fd, F_GETFD), Eq (old_flags));
323
310
};
324
311
325
- ExpectRealtimeDeath (Func, kFcntlFunctionName );
312
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " fcntl " ) );
326
313
ExpectNonRealtimeSurvival (Func);
327
314
328
315
close (fd);
@@ -340,7 +327,7 @@ TEST_F(RtsanFileTest, FopenDiesWhenRealtime) {
340
327
EXPECT_THAT (f, Ne (nullptr ));
341
328
};
342
329
343
- ExpectRealtimeDeath (Func, kFopenFunctionName );
330
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " fopen " ) );
344
331
ExpectNonRealtimeSurvival (Func);
345
332
}
346
333
@@ -428,7 +415,7 @@ TEST_F(RtsanOpenedFileTest, PreadDiesWhenRealtime) {
428
415
char c{};
429
416
pread (GetOpenFd (), &c, 1 , 0 );
430
417
};
431
- ExpectRealtimeDeath (Func, kPreadFunctionName );
418
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " pread " ) );
432
419
ExpectNonRealtimeSurvival (Func);
433
420
}
434
421
@@ -447,7 +434,7 @@ TEST_F(RtsanOpenedFileTest, PwriteDiesWhenRealtime) {
447
434
char c = ' a' ;
448
435
pwrite (GetOpenFd (), &c, 1 , 0 );
449
436
};
450
- ExpectRealtimeDeath (Func, kPwriteFunctionName );
437
+ ExpectRealtimeDeath (Func, MAYBE_APPEND_64 ( " pwrite " ) );
451
438
ExpectNonRealtimeSurvival (Func);
452
439
}
453
440
0 commit comments