Add SKIP_WITH_HWASAN macro. am: 1055a295b0 am: f052050c10 am: 75d66dd7de am: fff80ceee2

Original change: https://android-review.googlesource.com/c/platform/system/libbase/+/2064640

Change-Id: I514a8935e7078cd3204d6596d4ef228f24e41af6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/include/android-base/test_utils.h b/include/android-base/test_utils.h
index 4086b83..29dc394 100644
--- a/include/android-base/test_utils.h
+++ b/include/android-base/test_utils.h
@@ -88,3 +88,10 @@
       ADD_FAILURE() << "regex mismatch: expected to not find " << (__pattern) << " in:\n" << __s; \
     }                                                                                             \
   } while (0)
+
+extern "C" void __hwasan_init() __attribute__((weak));
+static inline bool running_with_hwasan() {
+  return &__hwasan_init != 0;
+}
+
+#define SKIP_WITH_HWASAN if (running_with_hwasan()) GTEST_SKIP()