* [LTP] [PATCH 1/1] swapon03: swapon() file on mounted filesystem
@ 2024-02-12 19:26 Petr Vorel
2024-02-13 2:02 ` Li Wang
0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2024-02-12 19:26 UTC (permalink / raw)
To: ltp
Change in 009a407a0 left the testing actually on TMPDIR (i.e. not on
mounted filesystems), but it also failed on 6.7.0 openSUSE Tumbleweed
kernel (it worked on 6.8.0-rc1):
# ./swapon03
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_swaqXc3II/mntpoint fstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
Failed to create swapfile: swapfile02
swapon03.c:181: TFAIL: Failed to setup swaps
While at it, use snprintf() consistently and remove error handling (we
newer use check for snprintf()), use TTERRNO.
Fixes: 009a407a0 ("swapon/off: enable all_filesystem in swap test")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,
this is a proper fix, replacing
https://patchwork.ozlabs.org/project/ltp/patch/20240205022857.191692-2-pvorel@suse.cz/
Kind regards,
Petr
testcases/kernel/syscalls/swapon/swapon03.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
index 05fe2045f..2a0fc99e6 100644
--- a/testcases/kernel/syscalls/swapon/swapon03.c
+++ b/testcases/kernel/syscalls/swapon/swapon03.c
@@ -52,8 +52,7 @@ static void verify_swapon(void)
TEST(tst_syscall(__NR_swapon, swap_testfiles[0].filename, 0));
if ((TST_RET == -1) && (TST_ERR == expected_errno)) {
- tst_res(TPASS, "swapon(2) got expected failure (%d),",
- expected_errno);
+ tst_res(TPASS | TTERRNO, "swapon(2) got expected failure");
} else if (TST_RET < 0) {
tst_res(TFAIL | TTERRNO,
"swapon(2) failed to produce expected error "
@@ -151,14 +150,8 @@ static int setup_swap(void)
/*create and turn on remaining swapfiles */
for (j = 0; j < swapfiles; j++) {
- /* prepare filename for the iteration */
- if (sprintf(filename, "swapfile%02d", j + 2) < 0) {
- printf("sprintf() failed to create "
- "filename");
- exit(1);
- }
-
/* Create the swapfile */
+ snprintf(filename, sizeof(filename), "%s%02d", TEST_FILE, j + 2);
make_swapfile(filename, 10, 0);
/* turn on the swap file */
@@ -196,14 +189,8 @@ static int clean_swap(void)
char filename[FILENAME_MAX];
for (j = 0; j < swapfiles; j++) {
- if (snprintf(filename, sizeof(filename),
- "swapfile%02d", j + 2) < 0) {
- tst_res(TWARN, "sprintf() failed to create filename");
- tst_res(TWARN, "Failed to turn off swap files. System"
- " reboot after execution of LTP test"
- " suite is recommended");
- return -1;
- }
+ snprintf(filename, sizeof(filename), "%s%02d", TEST_FILE, j + 2);
+
if (check_and_swapoff(filename) != 0) {
tst_res(TWARN, "Failed to turn off swap file %s.", filename);
return -1;
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 1/1] swapon03: swapon() file on mounted filesystem
2024-02-12 19:26 [LTP] [PATCH 1/1] swapon03: swapon() file on mounted filesystem Petr Vorel
@ 2024-02-13 2:02 ` Li Wang
2024-02-13 11:44 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2024-02-13 2:02 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Tue, Feb 13, 2024 at 3:26 AM Petr Vorel <pvorel@suse.cz> wrote:
> Change in 009a407a0 left the testing actually on TMPDIR (i.e. not on
> mounted filesystems), but it also failed on 6.7.0 openSUSE Tumbleweed
> kernel (it worked on 6.8.0-rc1):
>
> # ./swapon03
> 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_swaqXc3II/mntpoint fstyp=ext2 flags=0
> tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
> Failed to create swapfile: swapfile02
> swapon03.c:181: TFAIL: Failed to setup swaps
>
> While at it, use snprintf() consistently and remove error handling (we
> newer use check for snprintf()), use TTERRNO.
>
> Fixes: 009a407a0 ("swapon/off: enable all_filesystem in swap test")
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>
Reviewed-by: Li Wang <liwang@redhat.com>
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 1/1] swapon03: swapon() file on mounted filesystem
2024-02-13 2:02 ` Li Wang
@ 2024-02-13 11:44 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2024-02-13 11:44 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi Li,
thanks for your review, merged!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-13 11:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-12 19:26 [LTP] [PATCH 1/1] swapon03: swapon() file on mounted filesystem Petr Vorel
2024-02-13 2:02 ` Li Wang
2024-02-13 11:44 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox