[LTP] [PATCH v5 7/8] swapon/off: enable all_filesystem in swap test

Li Wang
2024-01-28T02:51:04Z

testcases/kernel/syscalls/swapoff/swapoff02.c | 11 ++++++-----
testcases/kernel/syscalls/swapon/swapon02.c | 4 ++++
testcases/kernel/syscalls/swapon/swapon03.c | 4 ++++
3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/swapoff/swapoff02.c b/testcases/kernel/syscalls/swapoff/swapoff02.c
index cd940b1e7..53060b320 100644
--- a/testcases/kernel/syscalls/swapoff/swapoff02.c
+++ b/testcases/kernel/syscalls/swapoff/swapoff02.c
@@ -18,6 +18,8 @@
#include "lapi/syscalls.h"
#include "libswap.h"

+#define MNTPOINT "mntpoint"
+
static int setup01(void);
static void cleanup01(void);

@@ -84,14 +86,13 @@ static void setup(void)

is_swap_supported("./tstswap");

- if (!tst_fs_has_free(".", 1, TST_KB))
- tst_brk(TBROK, "Insufficient disk space to create swap file");
-
- if (tst_fill_file("./swapfile01", 0x00, 1024, 1))
- tst_brk(TBROK, "Failed to create swapfile");
+ if (make_swapfile("swapfile01", 10, 1))
+ tst_brk(TBROK, "Failed to create file for swap");
}

static struct tst_test test = {
+ .mntpoint = MNTPOINT,
+ .all_filesystems = 1,
.needs_root = 1,
.needs_tmpdir = 1,
.test = verify_swapoff,
diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c
index f5b0d6d56..acb789fc4 100644
--- a/testcases/kernel/syscalls/swapon/swapon02.c
+++ b/testcases/kernel/syscalls/swapon/swapon02.c
@@ -20,6 +20,8 @@
#include "lapi/syscalls.h"
#include "libswap.h"

+#define MNTPOINT "mntpoint"
+
static uid_t nobody_uid;
static int do_swapoff;

@@ -78,6 +80,8 @@ static void verify_swapon(unsigned int i)
}

static struct tst_test test = {
+ .mntpoint = MNTPOINT,
+ .all_filesystems = 1,
.needs_root = 1,
.needs_tmpdir = 1,
.test = verify_swapon,
diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
index e13009111..249cb12c3 100644
--- a/testcases/kernel/syscalls/swapon/swapon03.c
+++ b/testcases/kernel/syscalls/swapon/swapon03.c
@@ -22,6 +22,8 @@
#include "swaponoff.h"
#include "libswap.h"

+#define MNTPOINT "mntpoint"
+
static int setup_swap(void);
static int clean_swap(void);
static int check_and_swapoff(const char *filename);
@@ -265,6 +267,8 @@ static void cleanup(void)
}

static struct tst_test test = {
+ .mntpoint = MNTPOINT,
+ .all_filesystems = 1,
.needs_root = 1,
.needs_tmpdir = 1,
.forks_child = 1,