chromium/base/debug/proc_maps_linux_unittest.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "base/debug/proc_maps_linux.h"

#include <stddef.h>
#include <stdint.h>

#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {
namespace debug {

TEST(ProcMapsTest, Empty) {}

TEST(ProcMapsTest, NoSpaces) {}

TEST(ProcMapsTest, Spaces) {}

TEST(ProcMapsTest, NoNewline) {}

TEST(ProcMapsTest, NoPath) {}

TEST(ProcMapsTest, Heap) {}

#if defined(ARCH_CPU_32_BITS)
TEST(ProcMapsTest, Stack32) {
  static const char kStack[] =
      "beb04000-beb25000 rw-p 00000000 00:00 0 [stack]\n";

  std::vector<MappedMemoryRegion> regions;
  ASSERT_TRUE(ParseProcMaps(kStack, &regions));
  ASSERT_EQ(1u, regions.size());

  EXPECT_EQ(0xbeb04000u, regions[0].start);
  EXPECT_EQ(0xbeb25000u, regions[0].end);
  EXPECT_EQ(0x00000000u, regions[0].offset);
  EXPECT_EQ("[stack]", regions[0].path);
}
#elif defined(ARCH_CPU_64_BITS)
TEST(ProcMapsTest, Stack64) {}
#endif

TEST(ProcMapsTest, Multiple) {}

TEST(ProcMapsTest, Permissions) {}

// AddressSanitizer may move local variables to a dedicated "fake stack" which
// is outside the stack region listed in /proc/self/maps. We disable ASan
// instrumentation for this function to force the variable to be local.
//
// Similarly, HWAddressSanitizer may add a tag to all stack pointers which may
// move it outside of the stack regions in /proc/self/maps.
__attribute__((no_sanitize("address", "hwaddress"))) void CheckProcMapsRegions(
    const std::vector<MappedMemoryRegion>& regions) {}

TEST(ProcMapsTest, ReadProcMaps) {}

TEST(ProcMapsTest, ReadProcMapsNonEmptyString) {}

TEST(ProcMapsTest, MissingFields) {}

TEST(ProcMapsTest, InvalidInput) {}

TEST(ProcMapsTest, ParseProcMapsEmptyString) {}

// Testing a couple of remotely possible weird things in the input:
// - Line ending with \r\n or \n\r.
// - File name contains quotes.
// - File name has whitespaces.
TEST(ProcMapsTest, ParseProcMapsWeirdCorrectInput) {}

}  // namespace debug
}  // namespace base