[LTP] [PATCH] swapon03: Correct the test swapfile name for swapoff() to work

Avinesh Kumar akumar@suse.de
Fri Oct 31 01:44:44 CET 2025


Fix an obvious mistake in the test. It remained hidden as test used
to run successfully and was never executing it.
On failure, it causes umount to fail as we do not swapoff() for the
edge case swapfile, and also causes breakage in subsequent filesystems
as we use the same loop device.

swapon03.c:63: TINFO: Successfully created 22 swap files
swapon03.c:64: TINFO: create a swapfile size of 1 megabytes (MB)
swapon03.c:105: TFAIL: swapon(mntpoint/testswap, 0) succeeded
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  1...
tst_device.c:421: TINFO: Likely gvfsd-trash is probing newly mounted fs, kill it to speed up tests.
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  2...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  3...
...
...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try 49...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try 50...
tst_device.c:428: TWARN: Failed to umount('mntpoint') after 50 retries
tst_test.c:1956: TINFO: === Testing on ext3 ===
tst_test.c:1280: TINFO: Formatting /dev/loop0 with ext3 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
/dev/loop0 is mounted; will not make a filesystem here!
tst_test.c:1280: TWARN: mkfs may have failed because the device is busy (e.g., udisks2 probing). Consider disabling background probing services.
tst_test.c:1280: TBROK: mkfs.ext3 failed with exit code 1
Summary:
passed   0
failed   1
broken   1
skipped  0
warnings 2
tst_device.c:270: TWARN: ioctl(/dev/loop0, LOOP_CLR_FD, 0) no ENXIO for too long
tst_tmpdir.c:347: TWARN: tst_rmdir: rmobj(/var/tmp/LTP_swa5hk5Lk) failed: unlink(/var/tmp/LTP_swa5hk5Lk/mntpoint) failed; errno=21: EISDIR

Fixes: 8fd941649a ("syscalls/swapon03: Simply this case")
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 testcases/kernel/syscalls/swapon/swapon03.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
index 0068560fe..d6445d5fc 100644
--- a/testcases/kernel/syscalls/swapon/swapon03.c
+++ b/testcases/kernel/syscalls/swapon/swapon03.c
@@ -97,7 +97,7 @@ static void clean_swap(void)
 		check_and_swapoff(filename);
 	}
 
-	check_and_swapoff("testfile");
+	check_and_swapoff(TEST_FILE);
 }
 
 static void verify_swapon(void)
-- 
2.51.0



More information about the ltp mailing list