Skip to contentSkip to conversation

swapon03: Correct the test swapfile name for swapoff() to work

PATCH In review Avinesh Kumar 3 participants 3 messages Oct 31, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 swapon03: Correct the test swapfile name for swapoff() to work

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")
---
 testcases/kernel/syscalls/swapon/swapon03.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/swapon/swapon03.c +1 -1
index 0068560fe..d6445d5fc 100644
@@ -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)
Signature · 5 lines
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw

Hi Avinesh,

Quoted 5 lines

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.

Good catch, thank you!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 10 lines · Petr Vorel

Hi Avinesh,

Quoted 5 lines

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.

Good catch, thank you!

Absolutely, patch merged.

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp