Skip to content

Commit e9cc5fe

Browse files
author
Kostya Kortchinsky
committed
[scudo][standalone] Enable death tests on Fuchsia
zxtest doesn't have `EXPECT_DEATH` and the Scudo unit-tests were defining it as a no-op. This enables death tests on Fuchsia by using `ASSERT_DEATH` instead. I used a lambda to wrap the expressions as this appears to not be working the same way as `EXPECT_DEATH`. Additionnally, a death test using `alarm` was failing with the change, as it's currently not implemented in Fuchsia, so move that test within a `!SCUDO_FUCHSIA` block. Differential Revision: https://reviews.llvm.org/D94362
1 parent e123cd6 commit e9cc5fe

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

compiler-rt/lib/scudo/standalone/tests/scudo_unit_test.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616

1717
// If EXPECT_DEATH isn't defined, make it a no-op.
1818
#ifndef EXPECT_DEATH
19+
// If ASSERT_DEATH is defined, make EXPECT_DEATH a wrapper to it.
20+
#ifdef ASSERT_DEATH
21+
#define EXPECT_DEATH(X, Y) ASSERT_DEATH(([&] { X; }), "")
22+
#else
1923
#define EXPECT_DEATH(X, Y) \
2024
do { \
2125
} while (0)
22-
#endif
26+
#endif // ASSERT_DEATH
27+
#endif // EXPECT_DEATH
2328

2429
// If EXPECT_STREQ isn't defined, define our own simple one.
2530
#ifndef EXPECT_STREQ

compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,10 @@ TEST(ScudoWrappersCTest, MallocIterateBoundary) {
303303
}
304304
}
305305

306-
// We expect heap operations within a disable/enable scope to deadlock.
306+
// Fuchsia doesn't have alarm, fork or malloc_info.
307+
#if !SCUDO_FUCHSIA
307308
TEST(ScudoWrappersCTest, MallocDisableDeadlock) {
309+
// We expect heap operations within a disable/enable scope to deadlock.
308310
EXPECT_DEATH(
309311
{
310312
void *P = malloc(Size);
@@ -318,9 +320,6 @@ TEST(ScudoWrappersCTest, MallocDisableDeadlock) {
318320
"");
319321
}
320322

321-
// Fuchsia doesn't have fork or malloc_info.
322-
#if !SCUDO_FUCHSIA
323-
324323
TEST(ScudoWrappersCTest, MallocInfo) {
325324
// Use volatile so that the allocations don't get optimized away.
326325
void *volatile P1 = malloc(1234);

0 commit comments

Comments
 (0)