diff mbox series

[v6,7/8] swapon/off: enable all_filesystem in swap test

Message ID 20240131102514.2739270-8-liwang@redhat.com
State Accepted
Headers show
Series improvement work on libswap library | expand

Commit Message

Li Wang Jan. 31, 2024, 10:25 a.m. UTC
Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/swapoff/swapoff01.c | 16 ++++++++---
 testcases/kernel/syscalls/swapoff/swapoff02.c | 20 ++++++++------
 testcases/kernel/syscalls/swapon/swapon02.c   | 27 ++++++++++++-------
 testcases/kernel/syscalls/swapon/swapon03.c   |  8 +++++-
 4 files changed, 49 insertions(+), 22 deletions(-)

Comments

Petr Vorel Jan. 31, 2024, 5:38 p.m. UTC | #1
Hi Li,

LGTM

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Although get on all VMs due low memory:

tst_test.c:1091: TCONF: No enough memory for tmpfs use

instead of
libswap.c:202: TCONF: Swapfile on tmpfs not implemented

I would also suggest to print who much memory is needed, e.g.:

diff --git lib/tst_test.c lib/tst_test.c
index edb42f7f4..151c6acca 100644
--- lib/tst_test.c
+++ lib/tst_test.c
@@ -1088,7 +1088,8 @@ static const char *limit_tmpfs_mount_size(const char *mnt_data,
 		tmpfs_size = tdev.size;
 
 	if ((tst_available_mem() / 1024) < (tmpfs_size * 2))
-		tst_brk(TCONF, "No enough memory for tmpfs use");
+		tst_brk(TCONF, "No enough memory for tmpfs use (%d MB < %d MB)",
+				tst_available_mem() / 1024, tmpfs_size * 2);
 
 	if (mnt_data)
 		snprintf(buf, buf_size, "%s,size=%uM", mnt_data, tmpfs_size);
Petr Vorel Jan. 31, 2024, 6:53 p.m. UTC | #2
Hi Li,

First, I suppose you wait for Cyril, otherwise I would be for merging up to
previous commit ("libswap: customize swapfile size").

I found a problem in this commit. It looks like this patch breaks testing on
TMPDIR on tmpfs on Tumbleweed kernel 6.8.0-rc1-2.gf4ba5db-default:

TMPDIR=/tmp LTP_SINGLE_FS_TYPE=ntfs ./swapoff01
tst_test.c:1701: TINFO: === Testing on ntfs ===
tst_test.c:1117: TINFO: Formatting /dev/loop0 with ntfs opts='' extra opts=''
The partition start sector was not specified for /dev/loop0 and it could not be obtained automatically.  It has been set to 0.
The number of sectors per track was not specified for /dev/loop0 and it could not be obtained automatically.  It has been set to 0.
The number of heads was not specified for /dev/loop0 and it could not be obtained automatically.  It has been set to 0.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swawDOaMz/mntpoint fstyp=ntfs flags=0
tst_test.c:1131: TINFO: Trying FUSE...
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
libswap.c:144: TBROK: Insufficient disk space to create swap file

df -hT /tmp/
Filesystem     Type   Size  Used Avail Use% Mounted on
tmpfs          tmpfs  717M     0  717M   0% /tmp

Test works on 6.6.x stable kernel, but that's due bigger tmpfs.
Could we at least TCONF (see below)?

I also wonder if we could make whole disk size a bit smaller.
The default 300 MB is not enough for XFS, right? But why 512 MB?
On6.8.0-rc1-2.gf4ba5db-default 350 MB is enough to test everything:

...
tst_test.c:1701: TINFO: === Testing on ntfs ===
tst_test.c:1117: TINFO: Formatting /dev/loop0 with ntfs opts='' extra opts=''
The partition start sector was not specified for /dev/loop0 and it could not be obtained automatically.  It has been set to 0.
The number of sectors per track was not specified for /dev/loop0 and it could not be obtained automatically.  It has been set to 0.
The number of heads was not specified for /dev/loop0 and it could not be obtained automatically.  It has been set to 0.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swaWEYzzv/mntpoint fstyp=ntfs flags=0
tst_test.c:1131: TINFO: Trying FUSE...
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapoff01.c:39: TPASS: Succeeded to turn off swapfile
tst_test.c:1701: TINFO: === Testing on tmpfs ===
tst_test.c:1117: TINFO: Skipping mkfs for TMPFS filesystem
tst_test.c:1098: TINFO: Limiting tmpfs size to 512MB
tst_test.c:1131: TINFO: Mounting ltp-tmpfs to /tmp/LTP_swaWEYzzv/mntpoint fstyp=tmpfs flags=0
tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22)
libswap.c:198: TCONF: Swapfile on tmpfs not implemented

Summary:
passed   8
failed   0
broken   0
skipped  1
warnings 0

Kind regards,
Petr

diff --git a/testcases/kernel/syscalls/swapoff/swapoff01.c b/testcases/kernel/syscalls/swapoff/swapoff01.c
index af2a759cb..bde59df77 100644
--- a/testcases/kernel/syscalls/swapoff/swapoff01.c
+++ b/testcases/kernel/syscalls/swapoff/swapoff01.c
@@ -45,8 +45,7 @@ static void setup(void)
 	is_swap_supported(TEST_FILE);

 	if (!tst_fs_has_free(".", 64, TST_MB))
-		tst_brk(TBROK,
-			"Insufficient disk space to create swap file");
+		tst_brk(TCONF, "Insufficient disk space to create swap file");

 	if (make_swapfile(SWAP_FILE, 65536, 1))
 		tst_brk(TBROK, "Failed to create file for swap");
Petr Vorel Jan. 31, 2024, 7:01 p.m. UTC | #3
Hi Li,

also I got failures on ppc64le in our CI

* swapoff01 6.7.2 and other versions up to 4.12 based kernels on ppc64le
...
tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1117: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swazu2fTl/mntpoint fstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
libswap.c:146: TBROK: Failed to create swapfile

Summary:
passed   0
failed   0
broken   1
skipped  0
warnings 0
### TEST swapoff01 COMPLETE >>> 2.

* swapon03 on 6.7.2 on ppc64le
...
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1117: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swaT8ZD57/mntpoint fstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
Failed to create swapfile: swapfile02
swapon03.c:180: TFAIL: Failed to setup swaps

Summary:
passed   0
failed   1
broken   0
skipped  0
warnings 0

* swapon03 on very old kernels (>= 4.4)
...
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1118: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts=''
mke2fs 1.42.11 (09-Jul-2014)
tst_test.c:1132: TINFO: Mounting /dev/loop0 to /tmp/LTP_swahOeodw/mntpoint fstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
libswap.c:37: TINFO: FS_NOCOW_FL attribute set on swapfile02
Failed to create swapfile: swapfile02
swapon03.c:180: TFAIL: Failed to setup swaps

Summary:
passed   0
failed   1
broken   0
skipped  0
warnings 0

All other tests are working.

Kind regards,
Petr
Li Wang Feb. 1, 2024, 4 a.m. UTC | #4
Hi Petr,

On Thu, Feb 1, 2024 at 2:53 AM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Li,
>
> First, I suppose you wait for Cyril, otherwise I would be for merging up to
> previous commit ("libswap: customize swapfile size").


Sure, I merged the patch to 5/8. To better focus on the new changes.

I found a problem in this commit. It looks like this patch breaks testing on
> TMPDIR on tmpfs on Tumbleweed kernel 6.8.0-rc1-2.gf4ba5db-default:
>
> TMPDIR=/tmp LTP_SINGLE_FS_TYPE=ntfs ./swapoff01
> tst_test.c:1701: TINFO: === Testing on ntfs ===
> tst_test.c:1117: TINFO: Formatting /dev/loop0 with ntfs opts='' extra
> opts=''
> The partition start sector was not specified for /dev/loop0 and it could
> not be obtained automatically.  It has been set to 0.
> The number of sectors per track was not specified for /dev/loop0 and it
> could not be obtained automatically.  It has been set to 0.
> The number of heads was not specified for /dev/loop0 and it could not be
> obtained automatically.  It has been set to 0.
> To boot from a device, Windows needs the 'partition start sector', the
> 'sectors per track' and the 'number of heads' to be set.
> Windows will not be able to boot from this device.
> tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swawDOaMz/mntpoint
> fstyp=ntfs flags=0
> tst_test.c:1131: TINFO: Trying FUSE...
> tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
> libswap.c:144: TBROK: Insufficient disk space to create swap file
>
> df -hT /tmp/
> Filesystem     Type   Size  Used Avail Use% Mounted on
> tmpfs          tmpfs  717M     0  717M   0% /tmp
>
> Test works on 6.6.x stable kernel, but that's due bigger tmpfs.
> Could we at least TCONF (see below)?
>

+1



>
> I also wonder if we could make whole disk size a bit smaller.
> The default 300 MB is not enough for XFS, right? But why 512 MB?
> On6.8.0-rc1-2.gf4ba5db-default 350 MB is enough to test everything:
>

Yes, 350MB is enough, I counted that by page_size (should use blk_size)
wrongly on aarch64.



>
> ...
> tst_test.c:1701: TINFO: === Testing on ntfs ===
> tst_test.c:1117: TINFO: Formatting /dev/loop0 with ntfs opts='' extra
> opts=''
> The partition start sector was not specified for /dev/loop0 and it could
> not be obtained automatically.  It has been set to 0.
> The number of sectors per track was not specified for /dev/loop0 and it
> could not be obtained automatically.  It has been set to 0.
> The number of heads was not specified for /dev/loop0 and it could not be
> obtained automatically.  It has been set to 0.
> To boot from a device, Windows needs the 'partition start sector', the
> 'sectors per track' and the 'number of heads' to be set.
> Windows will not be able to boot from this device.
> tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swaWEYzzv/mntpoint
> fstyp=ntfs flags=0
> tst_test.c:1131: TINFO: Trying FUSE...
> tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
> swapoff01.c:39: TPASS: Succeeded to turn off swapfile
> tst_test.c:1701: TINFO: === Testing on tmpfs ===
> tst_test.c:1117: TINFO: Skipping mkfs for TMPFS filesystem
> tst_test.c:1098: TINFO: Limiting tmpfs size to 512MB
> tst_test.c:1131: TINFO: Mounting ltp-tmpfs to /tmp/LTP_swaWEYzzv/mntpoint
> fstyp=tmpfs flags=0
> tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22)
> libswap.c:198: TCONF: Swapfile on tmpfs not implemented
>
> Summary:
> passed   8
> failed   0
> broken   0
> skipped  1
> warnings 0
>
> Kind regards,
> Petr
>
> diff --git a/testcases/kernel/syscalls/swapoff/swapoff01.c
> b/testcases/kernel/syscalls/swapoff/swapoff01.c
> index af2a759cb..bde59df77 100644
> --- a/testcases/kernel/syscalls/swapoff/swapoff01.c
> +++ b/testcases/kernel/syscalls/swapoff/swapoff01.c
> @@ -45,8 +45,7 @@ static void setup(void)
>         is_swap_supported(TEST_FILE);
>
>         if (!tst_fs_has_free(".", 64, TST_MB))
> -               tst_brk(TBROK,
> -                       "Insufficient disk space to create swap file");
> +               tst_brk(TCONF, "Insufficient disk space to create swap
> file");
>

This is not needed, libswap.c has a free space check already.


>
>         if (make_swapfile(SWAP_FILE, 65536, 1))
>                 tst_brk(TBROK, "Failed to create file for swap");
>
>
Li Wang Feb. 1, 2024, 6:57 a.m. UTC | #5
On Thu, Feb 1, 2024 at 3:01 AM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Li,
>
> also I got failures on ppc64le in our CI
>
> * swapoff01 6.7.2 and other versions up to 4.12 based kernels on ppc64le
> ...
> tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs
> tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
> tst_test.c:1701: TINFO: === Testing on ext2 ===
> tst_test.c:1117: TINFO: Formatting /dev/loop0 with ext2 opts='' extra
> opts=''
> mke2fs 1.47.0 (5-Feb-2023)
> tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swazu2fTl/mntpoint
> fstyp=ext2 flags=0
> tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
> libswap.c:146: TBROK: Failed to create swapfile
>


Err, I reproduce it with an RHEL9 ppc64le too.
I guess it does not allow to create a file that size less than page_size.

Once I replace the blk_size with page_size, all tests get passed.



>
> Summary:
> passed   0
> failed   0
> broken   1
> skipped  0
> warnings 0
> ### TEST swapoff01 COMPLETE >>> 2.
>
> * swapon03 on 6.7.2 on ppc64le
> ...
> tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
> tst_test.c:1701: TINFO: === Testing on ext2 ===
> tst_test.c:1117: TINFO: Formatting /dev/loop0 with ext2 opts='' extra
> opts=''
> mke2fs 1.47.0 (5-Feb-2023)
> tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swaT8ZD57/mntpoint
> fstyp=ext2 flags=0
> tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
> Failed to create swapfile: swapfile02
> swapon03.c:180: TFAIL: Failed to setup swaps
>
> Summary:
> passed   0
> failed   1
> broken   0
> skipped  0
> warnings 0
>
> * swapon03 on very old kernels (>= 4.4)
> ...
> tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
> tst_test.c:1701: TINFO: === Testing on ext2 ===
> tst_test.c:1118: TINFO: Formatting /dev/loop0 with ext2 opts='' extra
> opts=''
> mke2fs 1.42.11 (09-Jul-2014)
> tst_test.c:1132: TINFO: Mounting /dev/loop0 to /tmp/LTP_swahOeodw/mntpoint
> fstyp=ext2 flags=0
> tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
> libswap.c:37: TINFO: FS_NOCOW_FL attribute set on swapfile02
> Failed to create swapfile: swapfile02
> swapon03.c:180: TFAIL: Failed to setup swaps
>
> Summary:
> passed   0
> failed   1
> broken   0
> skipped  0
> warnings 0
>
> All other tests are working.
>
> Kind regards,
> Petr
>
>
Petr Vorel Feb. 1, 2024, 7:46 a.m. UTC | #6
> On Thu, Feb 1, 2024 at 3:01 AM Petr Vorel <pvorel@suse.cz> wrote:

> > Hi Li,

> > also I got failures on ppc64le in our CI

> > * swapoff01 6.7.2 and other versions up to 4.12 based kernels on ppc64le
> > ...
> > tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs
> > tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
> > tst_test.c:1701: TINFO: === Testing on ext2 ===
> > tst_test.c:1117: TINFO: Formatting /dev/loop0 with ext2 opts='' extra
> > opts=''
> > mke2fs 1.47.0 (5-Feb-2023)
> > tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swazu2fTl/mntpoint
> > fstyp=ext2 flags=0
> > tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
> > libswap.c:146: TBROK: Failed to create swapfile



> Err, I reproduce it with an RHEL9 ppc64le too.
> I guess it does not allow to create a file that size less than page_size.

> Once I replace the blk_size with page_size, all tests get passed.

+1, great. Feel free to merge the rest with my ack.

Kind regards,
Petr
Li Wang Feb. 1, 2024, 8:05 a.m. UTC | #7
On Thu, Feb 1, 2024 at 3:46 PM Petr Vorel <pvorel@suse.cz> wrote:


> > Err, I reproduce it with an RHEL9 ppc64le too.
> > I guess it does not allow to create a file that size less than page_size.
>
> > Once I replace the blk_size with page_size, all tests get passed.
>
> +1, great. Feel free to merge the rest with my ack.
>

Thanks, pushed with your suggestion (and tiny fixes).
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/swapoff/swapoff01.c b/testcases/kernel/syscalls/swapoff/swapoff01.c
index e3b445d05..af2a759cb 100644
--- a/testcases/kernel/syscalls/swapoff/swapoff01.c
+++ b/testcases/kernel/syscalls/swapoff/swapoff01.c
@@ -17,15 +17,19 @@ 
 #include "lapi/syscalls.h"
 #include "libswap.h"
 
+#define MNTPOINT	"mntpoint"
+#define TEST_FILE	MNTPOINT"/testswap"
+#define SWAP_FILE	MNTPOINT"/swapfile"
+
 static void verify_swapoff(void)
 {
-	if (tst_syscall(__NR_swapon, "./swapfile01", 0) != 0) {
+	if (tst_syscall(__NR_swapon, SWAP_FILE, 0) != 0) {
 		tst_res(TFAIL | TERRNO, "Failed to turn on the swap file"
 			 ", skipping test iteration");
 		return;
 	}
 
-	TEST(tst_syscall(__NR_swapoff, "./swapfile01"));
+	TEST(tst_syscall(__NR_swapoff, SWAP_FILE));
 
 	if (TST_RET == -1) {
 		tst_res(TFAIL | TTERRNO, "Failed to turn off swapfile,"
@@ -38,17 +42,21 @@  static void verify_swapoff(void)
 
 static void setup(void)
 {
-	is_swap_supported("./tstswap");
+	is_swap_supported(TEST_FILE);
 
 	if (!tst_fs_has_free(".", 64, TST_MB))
 		tst_brk(TBROK,
 			"Insufficient disk space to create swap file");
 
-	if (make_swapfile("swapfile01", 65536, 1))
+	if (make_swapfile(SWAP_FILE, 65536, 1))
 		tst_brk(TBROK, "Failed to create file for swap");
 }
 
 static struct tst_test test = {
+	.mntpoint = MNTPOINT,
+	.mount_device = 1,
+	.dev_min_size = 512,
+	.all_filesystems = 1,
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.test_all = verify_swapoff,
diff --git a/testcases/kernel/syscalls/swapoff/swapoff02.c b/testcases/kernel/syscalls/swapoff/swapoff02.c
index cd940b1e7..89ffd6ece 100644
--- a/testcases/kernel/syscalls/swapoff/swapoff02.c
+++ b/testcases/kernel/syscalls/swapoff/swapoff02.c
@@ -18,6 +18,10 @@ 
 #include "lapi/syscalls.h"
 #include "libswap.h"
 
+#define MNTPOINT	"mntpoint"
+#define TEST_FILE	MNTPOINT"/testswap"
+#define SWAP_FILE	MNTPOINT"/swapfile"
+
 static int setup01(void);
 static void cleanup01(void);
 
@@ -32,8 +36,8 @@  static struct tcase {
 	void (*cleanup)(void);
 } tcases[] = {
 	{"path does not exist", ENOENT, "ENOENT", "./doesnotexist", NULL, NULL},
-	{"Invalid file", EINVAL, "EINVAL", "./swapfile01", NULL, NULL},
-	{"Permission denied", EPERM, "EPERM", "./swapfile01", setup01, cleanup01}
+	{"Invalid file", EINVAL, "EINVAL", SWAP_FILE, NULL, NULL},
+	{"Permission denied", EPERM, "EPERM", SWAP_FILE, setup01, cleanup01}
 };
 
 static void verify_swapoff(unsigned int i)
@@ -82,16 +86,16 @@  static void setup(void)
 	nobody = SAFE_GETPWNAM("nobody");
 	nobody_uid = nobody->pw_uid;
 
-	is_swap_supported("./tstswap");
-
-	if (!tst_fs_has_free(".", 1, TST_KB))
-		tst_brk(TBROK, "Insufficient disk space to create swap file");
+	is_swap_supported(TEST_FILE);
 
-	if (tst_fill_file("./swapfile01", 0x00, 1024, 1))
-		tst_brk(TBROK, "Failed to create swapfile");
+	if (make_swapfile(SWAP_FILE, 10, 1))
+		tst_brk(TBROK, "Failed to create file for swap");
 }
 
 static struct tst_test test = {
+	.mntpoint = MNTPOINT,
+	.mount_device = 1,
+	.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..d8ff16b08 100644
--- a/testcases/kernel/syscalls/swapon/swapon02.c
+++ b/testcases/kernel/syscalls/swapon/swapon02.c
@@ -20,6 +20,12 @@ 
 #include "lapi/syscalls.h"
 #include "libswap.h"
 
+#define MNTPOINT	"mntpoint"
+#define TEST_FILE	MNTPOINT"/testswap"
+#define NOTSWAP_FILE	MNTPOINT"/notswap"
+#define SWAP_FILE	MNTPOINT"/swapfile"
+#define USED_FILE	MNTPOINT"/alreadyused"
+
 static uid_t nobody_uid;
 static int do_swapoff;
 
@@ -29,9 +35,9 @@  static struct tcase {
 	char *path;
 } tcases[] = {
 	{"Path does not exist", ENOENT, "./doesnotexist"},
-	{"Invalid path", EINVAL, "./notswap"},
-	{"Permission denied", EPERM, "./swapfile01"},
-	{"File already used", EBUSY, "./alreadyused"},
+	{"Invalid path", EINVAL, NOTSWAP_FILE},
+	{"Permission denied", EPERM, SWAP_FILE},
+	{"File already used", EBUSY, USED_FILE},
 };
 
 static void setup(void)
@@ -41,13 +47,13 @@  static void setup(void)
 	nobody = SAFE_GETPWNAM("nobody");
 	nobody_uid = nobody->pw_uid;
 
-	is_swap_supported("./tstswap");
+	is_swap_supported(TEST_FILE);
 
-	SAFE_TOUCH("notswap", 0777, NULL);
-	make_swapfile("swapfile01", 10, 0);
-	make_swapfile("alreadyused", 10, 0);
+	SAFE_TOUCH(NOTSWAP_FILE, 0777, NULL);
+	make_swapfile(SWAP_FILE, 10, 0);
+	make_swapfile(USED_FILE, 10, 0);
 
-	if (tst_syscall(__NR_swapon, "alreadyused", 0))
+	if (tst_syscall(__NR_swapon, USED_FILE, 0))
 		tst_res(TWARN | TERRNO, "swapon(alreadyused) failed");
 	else
 		do_swapoff = 1;
@@ -55,7 +61,7 @@  static void setup(void)
 
 static void cleanup(void)
 {
-	if (do_swapoff && tst_syscall(__NR_swapoff, "alreadyused"))
+	if (do_swapoff && tst_syscall(__NR_swapoff, USED_FILE))
 		tst_res(TWARN | TERRNO, "swapoff(alreadyused) failed");
 }
 
@@ -78,6 +84,9 @@  static void verify_swapon(unsigned int i)
 }
 
 static struct tst_test test = {
+	.mntpoint = MNTPOINT,
+	.mount_device = 1,
+	.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..72f39e7c7 100644
--- a/testcases/kernel/syscalls/swapon/swapon03.c
+++ b/testcases/kernel/syscalls/swapon/swapon03.c
@@ -22,6 +22,9 @@ 
 #include "swaponoff.h"
 #include "libswap.h"
 
+#define MNTPOINT	"mntpoint"
+#define TEST_FILE	MNTPOINT"/testswap"
+
 static int setup_swap(void);
 static int clean_swap(void);
 static int check_and_swapoff(const char *filename);
@@ -256,7 +259,7 @@  static void setup(void)
 	if (access("/proc/swaps", F_OK))
 		tst_brk(TCONF, "swap not supported by kernel");
 
-	is_swap_supported("./tstswap");
+	is_swap_supported(TEST_FILE);
 }
 
 static void cleanup(void)
@@ -265,6 +268,9 @@  static void cleanup(void)
 }
 
 static struct tst_test test = {
+	.mntpoint = MNTPOINT,
+	.mount_device = 1,
+	.all_filesystems = 1,
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.forks_child = 1,