1 //===-- asan_internal_interface_test.cpp ----------------------------------===//
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 //===----------------------------------------------------------------------===//
9 // This file is a part of AddressSanitizer, an address sanity checker.
11 //===----------------------------------------------------------------------===//
12 #include "asan_interface_internal.h"
13 #include "asan_test_utils.h"
16 TEST(AddressSanitizerInternalInterface
, SetShadow
) {
17 std::vector
<char> buffer(17, 0xff);
19 __asan_set_shadow_00((uptr
)buffer
.data(), buffer
.size());
20 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0x00), buffer
);
22 __asan_set_shadow_01((uptr
)buffer
.data(), buffer
.size());
23 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0x01), buffer
);
25 __asan_set_shadow_02((uptr
)buffer
.data(), buffer
.size());
26 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0x02), buffer
);
28 __asan_set_shadow_03((uptr
)buffer
.data(), buffer
.size());
29 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0x03), buffer
);
31 __asan_set_shadow_04((uptr
)buffer
.data(), buffer
.size());
32 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0x04), buffer
);
34 __asan_set_shadow_05((uptr
)buffer
.data(), buffer
.size());
35 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0x05), buffer
);
37 __asan_set_shadow_06((uptr
)buffer
.data(), buffer
.size());
38 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0x06), buffer
);
40 __asan_set_shadow_07((uptr
)buffer
.data(), buffer
.size());
41 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0x07), buffer
);
43 __asan_set_shadow_f1((uptr
)buffer
.data(), buffer
.size());
44 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0xf1), buffer
);
46 __asan_set_shadow_f2((uptr
)buffer
.data(), buffer
.size());
47 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0xf2), buffer
);
49 __asan_set_shadow_f3((uptr
)buffer
.data(), buffer
.size());
50 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0xf3), buffer
);
52 __asan_set_shadow_f5((uptr
)buffer
.data(), buffer
.size());
53 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0xf5), buffer
);
55 __asan_set_shadow_f8((uptr
)buffer
.data(), buffer
.size());
56 EXPECT_EQ(std::vector
<char>(buffer
.size(), 0xf8), buffer
);