1 #include "tests.h"
2 #include <asm/unistd.h>
3
4 #if defined __NR_swapon && defined __NR_swapoff
5
6 # include <stdio.h>
7 # include <sys/swap.h>
8 # include <unistd.h>
9
10 int
main(void)11 main(void)
12 {
13 static const char sample[] = "swap.sample";
14 long rc;
15
16 rc = syscall(__NR_swapon, sample, 0);
17 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
18 sample, "0", rc, errno2name());
19
20 rc = syscall(__NR_swapon, sample, 42);
21 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
22 sample, "42", rc, errno2name());
23
24 rc = syscall(__NR_swapon, sample, SWAP_FLAG_PREFER);
25 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
26 sample, "SWAP_FLAG_PREFER|0", rc, errno2name());
27
28 rc = syscall(__NR_swapon, sample, SWAP_FLAG_PREFER | 42);
29 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
30 sample, "SWAP_FLAG_PREFER|42", rc, errno2name());
31
32 rc = syscall(__NR_swapon, sample, -1L);
33 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
34 sample,
35 "SWAP_FLAG_PREFER|SWAP_FLAG_DISCARD|SWAP_FLAG_DISCARD_ONCE"
36 "|SWAP_FLAG_DISCARD_PAGES|0xfff80000|32767",
37 rc, errno2name());
38
39 rc = syscall(__NR_swapoff, sample);
40 printf("swapoff(\"%s\") = %ld %s (%m)\n",
41 sample, rc, errno2name());
42
43 puts("+++ exited with 0 +++");
44 return 0;
45 }
46
47 #else
48
49 SKIP_MAIN_UNDEFINED("__NR_swapon && __NR_swapoff")
50
51 #endif
52