]> granicus.if.org Git - strace/blob - tests/swap.c
Remove XLAT_END
[strace] / tests / swap.c
1 /*
2  * Copyright (c) 2016-2019 The strace developers.
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  */
7
8 #include "tests.h"
9 #include "scno.h"
10
11 #if defined __NR_swapon && defined __NR_swapoff
12
13 # include <stdio.h>
14 # include <sys/swap.h>
15 # include <unistd.h>
16
17 int
18 main(void)
19 {
20         static const char sample[] = "swap.sample";
21         long rc;
22
23         rc = syscall(__NR_swapon, sample, 0);
24         printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
25                sample, "0", rc, errno2name());
26
27         rc = syscall(__NR_swapon, sample, 42);
28         printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
29                sample, "42", rc, errno2name());
30
31         rc = syscall(__NR_swapon, sample, SWAP_FLAG_PREFER);
32         printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
33                sample, "SWAP_FLAG_PREFER|0", rc, errno2name());
34
35         rc = syscall(__NR_swapon, sample, SWAP_FLAG_PREFER | 42);
36         printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
37                sample, "SWAP_FLAG_PREFER|42", rc, errno2name());
38
39         rc = syscall(__NR_swapon, sample, -1L);
40         printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
41                sample,
42                "SWAP_FLAG_PREFER|SWAP_FLAG_DISCARD|SWAP_FLAG_DISCARD_ONCE"
43                "|SWAP_FLAG_DISCARD_PAGES|0xfff80000|32767",
44                rc, errno2name());
45
46         rc = syscall(__NR_swapoff, sample);
47         printf("swapoff(\"%s\") = %ld %s (%m)\n",
48                sample, rc, errno2name());
49
50         puts("+++ exited with 0 +++");
51         return 0;
52 }
53
54 #else
55
56 SKIP_MAIN_UNDEFINED("__NR_swapon && __NR_swapoff")
57
58 #endif