1 |
|
---|
2 | #include "config_xor.h"
|
---|
3 |
|
---|
4 | #include <string.h>
|
---|
5 | #include "CuTest.h"
|
---|
6 | #include "samhain.h"
|
---|
7 | #include "sh_unix.h"
|
---|
8 |
|
---|
9 | void Test_sh_unix_lookup_page (CuTest *tc) {
|
---|
10 |
|
---|
11 | int pagesize = sh_unix_pagesize();
|
---|
12 |
|
---|
13 | unsigned int base;
|
---|
14 | int num_pages;
|
---|
15 |
|
---|
16 | CuAssert (tc, "pagesize > 0", (pagesize > 0));
|
---|
17 |
|
---|
18 | /* base = sh_unix_lookup_page(in_addr, len, *num_pages); */
|
---|
19 |
|
---|
20 | base = sh_unix_lookup_page(0, pagesize, &num_pages);
|
---|
21 | CuAssert (tc, "base == 0", (base == 0));
|
---|
22 | CuAssertIntEquals (tc, num_pages, 1);
|
---|
23 |
|
---|
24 | base = sh_unix_lookup_page(0, pagesize+1, &num_pages);
|
---|
25 | CuAssert (tc, "base == 0", (base == 0));
|
---|
26 | CuAssertIntEquals (tc, num_pages, 2);
|
---|
27 |
|
---|
28 | base = sh_unix_lookup_page((void*)pagesize, pagesize, &num_pages);
|
---|
29 | CuAssert (tc, "base == 0", (base == (unsigned int)pagesize));
|
---|
30 | CuAssertIntEquals (tc, num_pages, 1);
|
---|
31 |
|
---|
32 | base = sh_unix_lookup_page((void*)pagesize, pagesize+1, &num_pages);
|
---|
33 | CuAssert (tc, "base == 0", (base == (unsigned int)pagesize));
|
---|
34 | CuAssertIntEquals (tc, num_pages, 2);
|
---|
35 |
|
---|
36 | base = sh_unix_lookup_page((void*)(pagesize-1), pagesize+1, &num_pages);
|
---|
37 | CuAssert (tc, "base == 0", (base == 0));
|
---|
38 | CuAssertIntEquals (tc, num_pages, 2);
|
---|
39 |
|
---|
40 | base = sh_unix_lookup_page((void*)(pagesize-1), pagesize+2, &num_pages);
|
---|
41 | CuAssert (tc, "base == 0", (base == 0));
|
---|
42 | CuAssertIntEquals (tc, num_pages, 3);
|
---|
43 |
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|