-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_action.c
74 lines (61 loc) · 2.48 KB
/
test_action.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
// 2013 - Ryan Leonard <[email protected]>
#include "util.h"
#include "action.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv){
struct Action
nice_mem_action,
nice_usr_action,
nice_pth_action,
kill_mem_action,
kill_usr_action,
kill_pth_action,
susp_mem_action,
susp_usr_action,
susp_pth_action;
printf("===\nRunning Test Set for Action.\n===\n\n");
printf("Testing initialization of actions...\n");
// test initAction
initAction(at_nice, pt_mem, "4000", &nice_mem_action);
initAction(at_nice, pt_user, "ryan", &nice_usr_action);
initAction(at_nice, pt_path, "/tmp/testing", &nice_pth_action);
initAction(at_kill, pt_mem, "400", &kill_mem_action);
initAction(at_kill, pt_user, "ryan", &kill_usr_action);
initAction(at_kill, pt_path, "/tmp/testing", &kill_pth_action);
initAction(at_susp, pt_mem, "300", &susp_mem_action);
initAction(at_susp, pt_user, "ryan", &susp_usr_action);
initAction(at_susp, pt_path, "/tmp/testing", &susp_pth_action);
// print one of each action for sanity check
printf("actionType: %d paramType: %d param: %d\n", kill_usr_action.actionType, kill_usr_action.paramType, kill_usr_action.param.uid);
printf("actionType: %d paramType: %d param: %s\n", susp_pth_action.actionType, susp_pth_action.paramType, susp_pth_action.param.pathName);
printf("actionType: %d paramType: %d param: %d\n", nice_mem_action.actionType, nice_mem_action.paramType, nice_mem_action.param.memoryCap);
printf("Done with initialization of actions...\n");
// test take action
printf("Testing taking of actions...\n");
takeAction(&nice_mem_action);
/*
takeAction(&nice_usr_action);
takeAction(&nice_pth_action);
takeAction(&kill_mem_action);
takeAction(&kill_usr_action);
takeAction(&kill_pth_action);
takeAction(&susp_mem_action);
takeAction(&susp_usr_action);
takeAction(&susp_pth_action);
*/
printf("Done taking of actions...\n");
// test freeAction
printf("Testing freeing of actions...\n");
freeAction(&nice_mem_action);
freeAction(&nice_usr_action);
freeAction(&nice_pth_action);
freeAction(&kill_mem_action);
freeAction(&kill_usr_action);
freeAction(&kill_pth_action);
freeAction(&susp_mem_action);
freeAction(&susp_usr_action);
freeAction(&susp_pth_action);
printf("Done freeing actions...\n");
return 0;
}