forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPageAccessTrackerTest.cpp
More file actions
44 lines (35 loc) · 1.04 KB
/
PageAccessTrackerTest.cpp
File metadata and controls
44 lines (35 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#if defined(__linux__)
#include "hermes/Support/PageAccessTracker.h"
#include "hermes/Support/OSCompat.h"
#include "gtest/gtest.h"
using namespace hermes;
namespace {
#ifdef HERMES_HAS_REAL_PAGE_TRACKER
TEST(PageAccessTrackerTest, Order) {
const size_t PS = hermes::oscompat::page_size();
const int numPages = 3;
auto result = hermes::oscompat::vm_allocate(PS * numPages);
ASSERT_TRUE(result);
std::unique_ptr<volatile PageAccessTracker> tracker =
PageAccessTracker::create(result.get(), PS * numPages);
auto p = reinterpret_cast<volatile char *>(result.get());
p[1 * PS];
p[2 * PS];
p[0 * PS];
std::string out;
{
llvh::raw_string_ostream OS(out);
tracker->printStats(OS, true);
}
std::string expected = "\"page_ids\":[1,2,0],";
EXPECT_TRUE(out.find(expected) != std::string::npos);
}
#endif
} // namespace
#endif // __linux__