Skip to content

Commit

Permalink
swapon01: Simplify code, add copyright
Browse files Browse the repository at this point in the history
Remove ambiguous comment with -i option during swapoff(),
it's needed for a test cleanup anyway.

Link: https://lore.kernel.org/ltp/[email protected]/
Reviewed-by: Cyril Hrubis <[email protected]>
Signed-off-by: Petr Vorel <[email protected]>
  • Loading branch information
pevik committed Jan 19, 2024
1 parent 557fd76 commit e34d6cd
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions testcases/kernel/syscalls/swapon/swapon01.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
* Copyright (c) Linux Test Project, 2003-2024
*/

/*\
Expand All @@ -16,27 +17,22 @@
#include "lapi/syscalls.h"
#include "libswap.h"

#define SWAP_FILE "swapfile01"

static void verify_swapon(void)
{
TEST(tst_syscall(__NR_swapon, "./swapfile01", 0));
TST_EXP_PASS(tst_syscall(__NR_swapon, SWAP_FILE, 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.");
}
if (TST_PASS && tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {
tst_brk(TBROK | TERRNO,
"Failed to turn off swapfile, system reboot recommended");
}
}

static void setup(void)
{
is_swap_supported("./tstswap");
make_swapfile("swapfile01", 0);
is_swap_supported(SWAP_FILE);
make_swapfile(SWAP_FILE, 0);
}

static struct tst_test test = {
Expand Down

0 comments on commit e34d6cd

Please sign in to comment.