Merge "Stop exporting certain deprecated unwinder symbols from libc.so and libm.so."
diff --git a/TEST_MAPPING b/TEST_MAPPING
index e4d3d5e..1d652f7 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -2,6 +2,12 @@
   "presubmit": [
     {
       "name": "CtsBionicTestCases"
+    },
+    {
+      "name": "malloc_debug_system_tests"
+    },
+    {
+      "name": "malloc_hooks_system_tests"
     }
   ]
 }
diff --git a/libc/bionic/scudo_wrapper.cpp b/libc/bionic/scudo_wrapper.cpp
index debd8d9..de6969fd 100644
--- a/libc/bionic/scudo_wrapper.cpp
+++ b/libc/bionic/scudo_wrapper.cpp
@@ -35,6 +35,11 @@
 
 __LIBC_HIDDEN__ WriteProtected<libc_globals> __libc_globals;
 
+// Call the libc malloc initialisers.
+__attribute__((constructor(1))) static void __scudo_preinit() {
+  __libc_globals.mutate(__libc_init_malloc);
+}
+
 #if defined(__i386__)
 __LIBC_HIDDEN__ void* __libc_sysinfo = reinterpret_cast<void*>(__libc_int0x80);
 #endif
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp
index 7340f95..4256cc4 100644
--- a/libc/malloc_debug/Android.bp
+++ b/libc/malloc_debug/Android.bp
@@ -165,6 +165,7 @@
 // ==============================================================
 cc_test {
     name: "malloc_debug_system_tests",
+    isolated: true,
 
     include_dirs: [
         "bionic/libc",
@@ -189,4 +190,5 @@
         "-Werror",
         "-O0",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
index 67bb8d9..9e612f0 100644
--- a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
@@ -50,6 +50,14 @@
 
 static constexpr time_t kTimeoutSeconds = 10;
 
+extern "C" bool GetInitialArgs(const char*** args, size_t* num_args) {
+  static const char* initial_args[] = {"--slow_threshold_ms=30000",
+                                       "--deadline_threshold_ms=1200000"};
+  *args = initial_args;
+  *num_args = 2;
+  return true;
+}
+
 static void Exec(const char* test_name, const char* debug_options, pid_t* pid, int exit_code = 0,
                  time_t timeout_seconds = kTimeoutSeconds) {
   int fds[2];
@@ -71,6 +79,9 @@
     args.push_back("--gtest_also_run_disabled_tests");
     std::string filter_arg = std::string("--gtest_filter=") + test_name;
     args.push_back(filter_arg.c_str());
+    // Need this because some code depends on exit codes from the test run
+    // but the isolation runner does not support that.
+    args.push_back("--no_isolate");
     args.push_back(nullptr);
     execv(args[0], reinterpret_cast<char* const*>(const_cast<char**>(args.data())));
     exit(20);
@@ -179,14 +190,14 @@
                         time_t timeout_seconds = kTimeoutSeconds) {
   std::string log_str;
   time_t start = time(nullptr);
-  bool found_all;
+  std::string missing_match;
   while (true) {
     GetLogStr(pid, &log_str);
-    found_all = true;
+    missing_match.clear();
     // Look for the expected strings.
     for (auto str : match_strings) {
       if (log_str.find(str) == std::string::npos) {
-        found_all = false;
+        missing_match = str;
         break;
       }
     }
@@ -195,14 +206,14 @@
     for (auto str : no_match_strings) {
       ASSERT_TRUE(log_str.find(str) == std::string::npos) << "Unexpectedly found '" << str << "' in log output:\n" << log_str;
     }
-    if (found_all) {
+    if (missing_match.empty()) {
       return;
     }
     if ((time(nullptr) - start) > timeout_seconds) {
       break;
     }
   }
-  ASSERT_TRUE(found_all) << "Didn't find expected log output:\n" << log_str;
+  ASSERT_EQ("", missing_match) << "Didn't find expected log output:\n" << log_str;
 }
 
 TEST(MallocTests, DISABLED_smoke) {}
@@ -413,7 +424,7 @@
     pid_t pid;
     SCOPED_TRACE(testing::Message() << functions[i].name << " expected size " << functions[i].size);
     std::string test = std::string("MallocTests.DISABLED_") + test_prefix + functions[i].name;
-    EXPECT_NO_FATAL_FAILURE(Exec(test.c_str(), "verbose backtrace leak_track", &pid));
+    ASSERT_NO_FATAL_FAILURE(Exec(test.c_str(), "verbose backtrace leak_track", &pid));
 
     std::string expected_leak = android::base::StringPrintf("leaked block of size %zu at", functions[i].size);
     EXPECT_NO_FATAL_FAILURE(FindStrings(
diff --git a/libc/malloc_hooks/Android.bp b/libc/malloc_hooks/Android.bp
index 861c371..77b523e 100644
--- a/libc/malloc_hooks/Android.bp
+++ b/libc/malloc_hooks/Android.bp
@@ -47,7 +47,8 @@
 // Unit Tests
 // ==============================================================
 cc_test {
-    name: "malloc_hooks_unit_tests",
+    name: "malloc_hooks_system_tests",
+    isolated: true,
 
     srcs: [
         "tests/malloc_hooks_tests.cpp",
@@ -70,4 +71,5 @@
         "-Wall",
         "-Werror",
     ],
+    test_suites: ["general-tests"],
 }