chromium/third_party/crashpad/crashpad/util/posix/scoped_mmap_test.cc

// Copyright 2017 The Crashpad Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "util/posix/scoped_mmap.h"

#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>

#include <iterator>

#include "base/numerics/safe_conversions.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "test/gtest_death.h"

namespace crashpad {
namespace test {
namespace {

bool ScopedMmapResetMmap(ScopedMmap* mapping, size_t len) {}

void* BareMmap(size_t len) {}

// A weird class. This is used to test that memory-mapped regions are freed
// as expected by calling munmap(). This is difficult to test well because once
// a region has been unmapped, the address space it formerly occupied becomes
// eligible for reuse.
//
// The strategy taken here is that a random 64-bit cookie value is written into
// a mapped region by SetUp(). While the mapping is active, Check() should not
// crash, or for a Google Test expectation, Expected() and Observed() should not
// crash and should be equal. After the region is unmapped, Check() should
// crash, either because the region has been unmapped and the address not
// reused, the address has been reused but is protected against reading
// (unlikely), or because the address has been reused but the cookie value is no
// longer present there.
class TestCookie {};

TEST(ScopedMmap, Mmap) {}

TEST(ScopedMmapDeathTest, Destructor) {}

TEST(ScopedMmapDeathTest, Reset) {}

TEST(ScopedMmapDeathTest, ResetAddrLen_Shrink) {}

TEST(ScopedMmap, ResetAddrLen_Grow) {}

TEST(ScopedMmapDeathTest, ResetAddrLen_MoveDownAndGrow) {}

TEST(ScopedMmapDeathTest, ResetAddrLen_MoveUpAndShrink) {}

TEST(ScopedMmapDeathTest, ResetMmap) {}

TEST(ScopedMmapDeathTest, NotIntegralNumberOfPages) {}

TEST(ScopedMmapDeathTest, Mprotect) {}

TEST(ScopedMmapTest, Release) {}

}  // namespace
}  // namespace test
}  // namespace crashpad