Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / scudo / standalone / tests / bytemap_test.cpp
blob4034b108fab97fbf657c73116639115111fc8cd9
1 //===-- bytemap_test.cpp ----------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "tests/scudo_unit_test.h"
11 #include "bytemap.h"
13 #include <pthread.h>
14 #include <string.h>
16 template <typename T> void testMap(T &Map, scudo::uptr Size) {
17 Map.init();
18 for (scudo::uptr I = 0; I < Size; I += 7)
19 Map.set(I, (I % 100) + 1);
20 for (scudo::uptr J = 0; J < Size; J++) {
21 if (J % 7)
22 EXPECT_EQ(Map[J], 0);
23 else
24 EXPECT_EQ(Map[J], (J % 100) + 1);
28 TEST(ScudoByteMapTest, FlatByteMap) {
29 const scudo::uptr Size = 1U << 10;
30 scudo::FlatByteMap<Size> Map;
31 testMap(Map, Size);
32 Map.unmapTestOnly();