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

source code of compiler-rt/lib/asan/tests/asan_internal_interface_test.cpp