-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_cmt.c
More file actions
61 lines (47 loc) · 1.23 KB
/
test_cmt.c
File metadata and controls
61 lines (47 loc) · 1.23 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdlib.h>
#include "cmt.h"
#include "misc.h"
int main(void)
{
UINT32 res;
UINT32 lpn, vpn, is_dirty;
cmt_init();
res = cmt_is_full();
BUG_ON("is full", res);
res = cmt_get(0, &vpn);
BUG_ON("get successful", res == 0);
res = cmt_add(0, 100);
res += cmt_add(1, 1);
BUG_ON("add failure", res != 0);
res = cmt_is_full();
BUG_ON("not full", res == 0);
res = cmt_add(200, 400);
res += cmt_add(3890123, 2);
BUG_ON("less failure", res != 2);
cmt_get(0, &vpn);
BUG_ON("wrong vpn", vpn != 100);
cmt_get(1, &vpn);
BUG_ON("wrong vpn", vpn != 1);
res = cmt_add(200, 400);
res += cmt_add(3890123, 2);
BUG_ON("any failure", res != 0);
res = cmt_get(200, &vpn);
BUG_ON("wrong vpn", vpn != 400);
res = cmt_get(3890123, &vpn);
BUG_ON("wrong vpn", vpn != 2);
BUG_ON("get failure", res != 0);
res = cmt_is_full();
BUG_ON("not full", res == 0);
res = cmt_evict(&lpn, &vpn, &is_dirty);
BUG_ON("any error", res != 0);
BUG_ON("lpn not 0", lpn != 0);
BUG_ON("vpn not 100", vpn != 100);
BUG_ON("dirty", is_dirty);
cmt_add(201, 444);
cmt_update(1, 2);
res = cmt_evict(&lpn, &vpn, &is_dirty);
BUG_ON("any error", res != 0);
BUG_ON("lpn not 0", lpn != 1);
BUG_ON("vpn not 100", vpn != 2);
BUG_ON("not dirty", !is_dirty);
}