This test was failing with the following error message (at least on X86 Linux,
but I believe other targets should be affected as well):
$ Sanitizer-x86_64-Test --gtest_filter=SanitizerCommon.ChainedOriginDepot* ... [ RUN ] SanitizerCommon.ChainedOriginDepotStats compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp:77: Failure Expected: (stats1.allocated) > (stats0.allocated), actual: 196608 vs 196608 [ FAILED ] SanitizerCommon.ChainedOriginDepotStats (867 ms)
This happens iff to run the test binary directly, w/o using lit.
lit seems to run tests one by one, so they cannot affect each other.
But for cross-compilation & remote test execution using lit might not be convenient.
So, having the tests passed natively is still the case.
Since the ChainedOriginDepot* tests are not doing any cleanup, by the time
SanitizerCommon.ChainedOriginDepotStats test starts executing the depot
may not be empty, so there will be no allocation for the test.
Following example of compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp,
this patch introduces ChainedOriginDepot::TestOnlyUnmap() API that deallocates
memory where requested. This makes sure underlying TwoLevelMap initiates
the expected allocation.