This source file includes following definitions.
- dscr_explicit
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include "dscr.h"
19
20 int dscr_explicit(void)
21 {
22 unsigned long i, dscr = 0;
23
24 srand(getpid());
25 set_dscr(dscr);
26
27 for (i = 0; i < COUNT; i++) {
28 unsigned long cur_dscr, cur_dscr_usr;
29 double ret = uniform_deviate(rand());
30
31 if (ret < 0.001) {
32 dscr++;
33 if (dscr > DSCR_MAX)
34 dscr = 0;
35
36 set_dscr(dscr);
37 }
38
39 cur_dscr = get_dscr();
40 if (cur_dscr != dscr) {
41 fprintf(stderr, "Kernel DSCR should be %ld but "
42 "is %ld\n", dscr, cur_dscr);
43 return 1;
44 }
45
46 ret = uniform_deviate(rand());
47 if (ret < 0.001) {
48 dscr++;
49 if (dscr > DSCR_MAX)
50 dscr = 0;
51
52 set_dscr_usr(dscr);
53 }
54
55 cur_dscr_usr = get_dscr_usr();
56 if (cur_dscr_usr != dscr) {
57 fprintf(stderr, "User DSCR should be %ld but "
58 "is %ld\n", dscr, cur_dscr_usr);
59 return 1;
60 }
61 }
62 return 0;
63 }
64
65 int main(int argc, char *argv[])
66 {
67 return test_harness(dscr_explicit, "dscr_explicit_test");
68 }