-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit_tests.c
78 lines (62 loc) · 1.46 KB
/
unit_tests.c
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "config.h"
//#ifdef UNIT_TESTING
#include <linux/slab.h>
#include <linux/ktime.h>
#include <linux/limits.h>
#include "table_port.h"
#define INITIAL_PORT 1
#define FINAL_PORT 1024
#define MAX_DATA 1024
static struct packetInfo *ports;
int populate(void)
{
int i=0;
int iteration = 0;
s64 delta;
ktime_t initial, end;
struct packetInfo *sentinel = NULL;
ports = kmalloc(MAX_DATA*sizeof(*ports),GFP_KERNEL);
pr_info("Populate\n");
//initial = ktime_get();
for(i=INITIAL_PORT,iteration=0;i < FINAL_PORT ; i++,iteration++)
{
sentinel = (ports)+iteration;
sentinel->port = (u16)i;
sentinel->address = 0x7f000001;
sentinel->protocol = 0x06;
insertPort(sentinel);
}
/*end = ktime_get();
delta = ktime_to_ns(ktime_sub(end,initial));
pr_info("%lld ns to execute a insert\n",(long long)delta);
initial = ktime_get();
searchPort(sentinel);
end = ktime_get();
delta = ktime_to_ns(ktime_sub(end,initial));
pr_info("%lld ns to execute one search\n",(long long)delta);
*/
printTree();
return 0;
}
int depopulate(void)
{
int i = INITIAL_PORT;
int iteration = 0;
s64 delta;
ktime_t initial, end;
pr_info("DePopulate\n");
// initial = ktime_get();
for(i=INITIAL_PORT, iteration=0;i < FINAL_PORT; i++,iteration++)
{
deletePort((ports+iteration));
}
/* end = ktime_get();
delta = ktime_to_ns(ktime_sub(end,initial));
pr_info("%lld ns to execute a remove\n",(long long)delta);
*/
printTree();
kfree(ports);
ports = NULL;
return 0;
}
//#endif