forked from havluj/i386-memory-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest1.cpp
executable file
·54 lines (41 loc) · 1003 Bytes
/
test1.cpp
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
45
46
47
48
49
50
51
52
53
54
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include "common.h"
#include "test_op.h"
using namespace std;
static void seqTest1(CCPU* cpu, void* arg)
{
for(uint32_t i = 0; i <= 2000; i++) {
checkResize(cpu, i);
}
checkResize(cpu, 5000);
for(int i = 2000; i >= 0; i--) {
checkResize(cpu, i);
}
}
static void seqTest2(CCPU* cpu, void* arg)
{
checkResize(cpu, 1000);
rwiTest(cpu, 0, 1000);
checkResize(cpu, 2345);
rwiTest(cpu, 0, 2345);
checkResize(cpu, 789);
rwiTest(cpu, 0, 789);
}
int main(void)
{
const int PAGES = 8 * 1024;
// PAGES + extra 4KiB for alignment
uint8_t* mem = new uint8_t[PAGES * CCPU::PAGE_SIZE + CCPU::PAGE_SIZE];
// align to a mutiple of 4KiB
uint8_t* memAligned = (uint8_t*) ((((uintptr_t) mem) + CCPU::PAGE_SIZE - 1) & ~(uintptr_t) ~CCPU::ADDR_MASK);
testStart();
MemMgr(memAligned, PAGES, NULL, seqTest1);
testEnd("test #1");
testStart();
MemMgr(memAligned, PAGES, NULL, seqTest2);
testEnd("test #2");
delete[] mem;
return 0;
}