1 //===-- sanitizer_procmaps_test.cc ----------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of ThreadSanitizer/AddressSanitizer runtime.
12 //===----------------------------------------------------------------------===//
13 #if !defined(_WIN32) // There are no /proc/maps on Windows.
15 #include "sanitizer_common/sanitizer_procmaps.h"
16 #include "gtest/gtest.h"
21 extern const char *argv0;
23 namespace __sanitizer {
25 #if SANITIZER_LINUX && !SANITIZER_ANDROID
26 TEST(MemoryMappingLayout, CodeRange) {
28 bool res = GetCodeRangeForFile("[vdso]", &start, &end);
31 EXPECT_LT(start, end);
35 TEST(MemoryMappingLayout, DumpListOfModules) {
36 const char *last_slash = strrchr(argv0, '/');
37 const char *binary_name = last_slash ? last_slash + 1 : argv0;
38 MemoryMappingLayout memory_mapping(false);
39 const uptr kMaxModules = 100;
40 LoadedModule *modules =
41 (LoadedModule *)malloc(kMaxModules * sizeof(LoadedModule));
42 uptr n_modules = memory_mapping.DumpListOfModules(modules, kMaxModules, 0);
43 EXPECT_GT(n_modules, 0U);
45 for (uptr i = 0; i < n_modules; ++i) {
46 if (modules[i].containsAddress((uptr)&noop)) {
47 // Verify that the module name is sane.
48 if (strstr(modules[i].full_name(), binary_name) != 0)
56 } // namespace __sanitizer
57 #endif // !defined(_WIN32)