1 //===-- scudo_unit_test_main.cpp --------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #include "tests/scudo_unit_test.h"
12 // Match Android's default configuration, which disables Scudo's mismatch
13 // allocation check, as it is being triggered by some third party code.
15 #define DEALLOC_TYPE_MISMATCH "false"
17 #define DEALLOC_TYPE_MISMATCH "true"
20 static void EnableMemoryTaggingIfSupported() {
21 if (!scudo::archSupportsMemoryTagging())
23 static bool Done
= []() {
24 if (!scudo::systemDetectsMemoryTagFaultsTestOnly())
25 scudo::enableSystemMemoryTaggingTestOnly();
31 // This allows us to turn on/off a Quarantine for specific tests. The Quarantine
32 // parameters are on the low end, to avoid having to loop excessively in some
34 bool UseQuarantine
= true;
35 extern "C" __attribute__((visibility("default"))) const char *
36 __scudo_default_options() {
37 // The wrapper tests initialize the global allocator early, before main(). We
38 // need to have Memory Tagging enabled before that happens or the allocator
39 // will disable the feature entirely.
40 EnableMemoryTaggingIfSupported();
42 return "dealloc_type_mismatch=" DEALLOC_TYPE_MISMATCH
;
43 return "quarantine_size_kb=256:thread_local_quarantine_size_kb=128:"
44 "quarantine_max_chunk_size=512:"
45 "dealloc_type_mismatch=" DEALLOC_TYPE_MISMATCH
;
48 #if !defined(SCUDO_NO_TEST_MAIN)
49 int main(int argc
, char **argv
) {
50 EnableMemoryTaggingIfSupported();
51 testing::InitGoogleTest(&argc
, argv
);
52 return RUN_ALL_TESTS();