1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
4 */
5
6 /*\
7 * [Description]
8 *
9 * Checks that swapon() succeds with swapfile.
10 */
11
12 #include <unistd.h>
13 #include <errno.h>
14 #include <stdlib.h>
15 #include "tst_test.h"
16 #include "lapi/syscalls.h"
17 #include "libswap.h"
18
verify_swapon(void)19 static void verify_swapon(void)
20 {
21 TEST(tst_syscall(__NR_swapon, "./swapfile01", 0));
22
23 if (TST_RET == -1) {
24 tst_res(TFAIL | TTERRNO, "Failed to turn on swapfile");
25 } else {
26 tst_res(TPASS, "Succeeded to turn on swapfile");
27 /*we need to turn this swap file off for -i option */
28 if (tst_syscall(__NR_swapoff, "./swapfile01") != 0) {
29 tst_brk(TBROK | TERRNO, "Failed to turn off swapfile,"
30 " system reboot after execution of LTP "
31 "test suite is recommended.");
32 }
33 }
34 }
35
setup(void)36 static void setup(void)
37 {
38 is_swap_supported("./tstswap");
39 make_swapfile("swapfile01", 0);
40 }
41
42 static struct tst_test test = {
43 .needs_tmpdir = 1,
44 .test_all = verify_swapon,
45 .setup = setup
46 };
47