aboutsummaryrefslogtreecommitdiff
path: root/tests/malloc_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/malloc_test.cpp')
-rw-r--r--tests/malloc_test.cpp40
1 files changed, 18 insertions, 22 deletions
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index f157ec497..69f8506fd 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -41,6 +41,7 @@
#include <tinyxml2.h>
#include <android-base/file.h>
+#include <android-base/test_utils.h>
#include "utils.h"
@@ -1010,18 +1011,6 @@ TEST(malloc, align_check) {
AlignCheck();
}
-// Force GWP-ASan on and verify all alignment checks still pass.
-TEST(malloc, align_check_gwp_asan) {
-#if defined(__BIONIC__)
- bool force_init = true;
- ASSERT_TRUE(android_mallopt(M_INITIALIZE_GWP_ASAN, &force_init, sizeof(force_init)));
-
- AlignCheck();
-#else
- GTEST_SKIP() << "bionic-only test";
-#endif
-}
-
// Jemalloc doesn't pass this test right now, so leave it as disabled.
TEST(malloc, DISABLED_alloc_after_fork) {
// Both of these need to be a power of 2.
@@ -1371,17 +1360,24 @@ TEST(android_mallopt, set_allocation_limit_multiple_threads) {
#endif
}
-TEST(android_mallopt, force_init_gwp_asan) {
#if defined(__BIONIC__)
- bool force_init = true;
- ASSERT_TRUE(android_mallopt(M_INITIALIZE_GWP_ASAN, &force_init, sizeof(force_init)));
-
- // Verify that trying to do the call again also passes no matter the
- // value of force_init.
- force_init = false;
- ASSERT_TRUE(android_mallopt(M_INITIALIZE_GWP_ASAN, &force_init, sizeof(force_init)));
- force_init = true;
- ASSERT_TRUE(android_mallopt(M_INITIALIZE_GWP_ASAN, &force_init, sizeof(force_init)));
+using Action = android_mallopt_gwp_asan_options_t::Action;
+TEST(android_mallopt, DISABLED_multiple_enable_gwp_asan) {
+ android_mallopt_gwp_asan_options_t options;
+ options.program_name = ""; // Don't infer GWP-ASan options from sysprops.
+ options.desire = Action::DONT_TURN_ON_UNLESS_OVERRIDDEN;
+ // GWP-ASan should already be enabled. Trying to enable or disable it should
+ // always pass.
+ ASSERT_TRUE(android_mallopt(M_INITIALIZE_GWP_ASAN, &options, sizeof(options)));
+ options.desire = Action::TURN_ON_WITH_SAMPLING;
+ ASSERT_TRUE(android_mallopt(M_INITIALIZE_GWP_ASAN, &options, sizeof(options)));
+}
+#endif // defined(__BIONIC__)
+
+TEST(android_mallopt, multiple_enable_gwp_asan) {
+#if defined(__BIONIC__)
+ // Always enable GWP-Asan, with default options.
+ RunGwpAsanTest("*.DISABLED_multiple_enable_gwp_asan");
#else
GTEST_SKIP() << "bionic extension";
#endif