Debian Codegraph @

testsuite/systemtap.syscall/swap.c

raw
1 /* COVERAGE: swapon swapoff */
2 #include <unistd.h>
3 #include <sys/swap.h>
4 #include <sys/mman.h>
5
6
7 int main()
8 {
9 /* Actually creating a real swap file here is problematic. It won't
10 * work if we're not root or we're on a filesystem that doesn't
11 * support swap files (like tmpfs or nfs). So, we'll specify a file
12 * that doesn't exist. So, all of the following calls will fail (for
13 * various reasons). */
14
15 mlockall(MCL_CURRENT);
16
17 swapon("foobar_swap", 0);
18 //staptest// swapon ("foobar_swap", 0x0) = -NNNN
19
20 swapon("foobar_swap", ((1 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK) | SWAP_FLAG_PREFER);
21 //staptest// swapon ("foobar_swap", SWAP_FLAG_PREFER|1) = -NNNN
22
23 swapon("foobar_swap", ((7 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK) | SWAP_FLAG_PREFER);
24 //staptest// swapon ("foobar_swap", SWAP_FLAG_PREFER|7) = -NNNN
25
26 swapon(0, 0);
27 //staptest// swapon ( *0x0, 0x0) =
28
29 #ifdef SWAP_FLAG_DISCARD
30 swapon("foobar_swap", SWAP_FLAG_DISCARD);
31 //staptest// swapon ("foobar_swap", SWAP_FLAG_DISCARD) = -NNNN
32 #endif
33
34 swapon("foobar_swap", -1);
35 //staptest// swapon ("foobar_swap", SWAP_FLAG_[^ ]+|XXXX|32767) = -NNNN
36
37 swapon((char *)-1, SWAP_FLAG_PREFER);
38 #ifdef __s390__
39 //staptest// swapon (0x[7]?[f]+, SWAP_FLAG_PREFER|0) = -NNNN
40 #else
41 //staptest// swapon (0x[f]+, SWAP_FLAG_PREFER|0) = -NNNN
42 #endif
43
44 swapoff("foobar_swap");
45 //staptest// swapoff ("foobar_swap") = -NNNN
46
47 swapoff(0);
48 //staptest// swapoff ( *0x0) = -NNNN
49
50 swapoff((char *)-1);
51 #ifdef __s390__
52 //staptest// swapoff (0x[7]?[f]+) = -NNNN
53 #else
54 //staptest// swapoff (0x[f]+) = -NNNN
55 #endif
56
57 return 0;
58 }
59