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