[LTP] [PATCH v3 3/3] swapon02: Add test cases for invalid swapflags
Cyril Hrubis
chrubis@suse.cz
Thu Sep 3 13:32:48 CEST 2026
Hi!
> static void setup(void)
> @@ -66,20 +96,20 @@ static void cleanup(void)
>
> static void verify_swapon(unsigned int i)
> {
> - struct tcase *tc = tcases + i;
> + struct tcase *tc = &tcases[i];
> +
> if (tc->exp_errno == EPERM)
> SAFE_SETEUID(nobody_uid);
>
> - TST_EXP_FAIL(tst_syscall(__NR_swapon, tc->path, 0), tc->exp_errno,
> + TST_EXP_FAIL(tst_syscall(__NR_swapon, tc->path, tc->flags), tc->exp_errno,
> "swapon(2) fail with %s", tc->err_desc);
>
> if (tc->exp_errno == EPERM)
> SAFE_SETEUID(0);
>
> - if (TST_RET != -1) {
> - tst_res(TFAIL, "swapon(2) failed unexpectedly, expected: %s",
> - tst_strerrno(tc->exp_errno));
> - }
> + /* If swapon() unexpectedly succeeded, undo it for the next iteration */
This probably falls into commenting the obvious.
> + if (TST_RET == 0 && tst_syscall(__NR_swapoff, tc->path) != 0)
> + tst_res(TWARN | TTERRNO, "swapoff(%s) failed", tc->path);
> }
^
TERRNO
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list