forked from mit-pdos/xv6-riscv
-
Notifications
You must be signed in to change notification settings - Fork 5
/
dumptests.c
121 lines (111 loc) · 3.06 KB
/
dumptests.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "kernel/types.h"
#include "kernel/syscall.h"
#include "user/user.h"
#ifdef SYS_dump
void test1();
void test2();
void test3();
void test4();
#endif
int main(void)
{
printf("dump tests started\n");
#ifndef SYS_dump
printf("no dump syscall found. Stop testing\n");
goto no_dump;
#endif
#ifdef SYS_dump
printf("dump syscall found. Start testing\n");
test1();
test2();
test3();
test4();
printf("4 tests were ran\n");
#endif
#ifndef SYS_dump
no_dump:
#endif
exit(0);
}
#ifdef SYS_dump
void test1() {
printf("#####################\n");
printf("# #\n");
printf("# initial state #\n");
printf("# #\n");
printf("#####################\n");
dump();
}
int dump_test2_asm();
void test2() {
printf("#####################\n");
printf("# #\n");
printf("# test 1 #\n");
printf("# #\n");
printf("#####################\n");
printf("# #\n");
printf("# expected values #\n");
printf("# #\n");
printf("#####################\n");
printf("# s2 = 2 #\n");
printf("# s3 = 3 #\n");
printf("# s4 = 4 #\n");
printf("# s5 = 5 #\n");
printf("# s6 = 6 #\n");
printf("# s7 = 7 #\n");
printf("# s8 = 8 #\n");
printf("# s9 = 9 #\n");
printf("# s10 = 10 #\n");
printf("# s11 = 11 #\n");
printf("#####################\n");
dump_test2_asm();
}
int dump_test3_asm();
void test3() {
printf("#####################\n");
printf("# #\n");
printf("# test 2 #\n");
printf("# #\n");
printf("#####################\n");
printf("# #\n");
printf("# expected values #\n");
printf("# #\n");
printf("#####################\n");
printf("# s2 = 1 #\n");
printf("# s3 = -12 #\n");
printf("# s4 = 123 #\n");
printf("# s5 = -1234 #\n");
printf("# s6 = 12345 #\n");
printf("# s7 = -123456 #\n");
printf("# s8 = 1234567 #\n");
printf("# s9 = -12345678 #\n");
printf("# s10 = 123456789 #\n");
printf("# s11 = -1234567890 #\n");
printf("#####################\n");
dump_test3_asm();
}
int dump_test4_asm();
void test4() {
printf("#####################\n");
printf("# #\n");
printf("# test 3 #\n");
printf("# #\n");
printf("#####################\n");
printf("# #\n");
printf("# expected values #\n");
printf("# #\n");
printf("#####################\n");
printf("# s2 = 2147483647 #\n");
printf("# s3 = -2147483648 #\n");
printf("# s4 = 1337 #\n");
printf("# s5 = 2020 #\n");
printf("# s6 = 3234 #\n");
printf("# s7 = 3235 #\n");
printf("# s8 = 3236 #\n");
printf("# s9 = 3237 #\n");
printf("# s10 = 3238 #\n");
printf("# s11 = 3239 #\n");
printf("#####################\n");
dump_test4_asm();
}
#endif