diff mbox series

[v1] mem/swapping01: Make sure swap is supported by kernel

Message ID 20220210133812.13368-1-bogdan.lezhepekov@suse.com
State Accepted
Headers show
Series [v1] mem/swapping01: Make sure swap is supported by kernel | expand

Commit Message

Bogdan Lezhepekov Feb. 10, 2022, 1:38 p.m. UTC
Previous version caused false positive result
on machines support no swap in kernel.

Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
 testcases/kernel/mem/swapping/swapping01.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Cyril Hrubis Feb. 10, 2022, 4:11 p.m. UTC | #1
Hi!
Applied, thanks.

I guess that the SAFE_OPEN() caused TBROK on machines without
CONFIG_SWAP, right?
Bogdan Lezhepekov Feb. 10, 2022, 4:30 p.m. UTC | #2
Absolutely correct 🙂

Thanks for the review!
-Bogdan
Li Wang Feb. 11, 2022, 12:39 a.m. UTC | #3
On Fri, Feb 11, 2022 at 12:09 AM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> Applied, thanks.
>
> I guess that the SAFE_OPEN() caused TBROK on machines without
> CONFIG_SWAP, right?
>

If so, why not go fix with .needs_config for "CONFIG_SWAP=y" ?
Yang Xu Feb. 11, 2022, 1:21 a.m. UTC | #4
Hi Li
>
>
> On Fri, Feb 11, 2022 at 12:09 AM Cyril Hrubis <chrubis@suse.cz
> <mailto:chrubis@suse.cz>> wrote:
>
>     Hi!
>     Applied, thanks.
>
>     I guess that the SAFE_OPEN() caused TBROK on machines without
>     CONFIG_SWAP, right?
>
>
> If so, why not go fix with .needs_config for "CONFIG_SWAP=y" ?
+1, it is also friendly to docparse.

ps: I never listen user complaint for the lack of CONFIG_PORC, so only 
using .needs_config for "CONFIG_SWAP=y" can work well.

Best Regards
Yang Xu
>
> --
> Regards,
> Li Wang
>
>
>
>
Bogdan Lezhepekov Feb. 11, 2022, 7:35 a.m. UTC | #5
Hi all,

I didn't go for CONFIG_SWAP just because wanted to be aligned with syscalls/swapon/swapon03.c and to not multiply patterns.

If you see CONFIG_SWAP more beneficial for docparser, I can make another patch.

Should I?

Cheers,
Bogdan
Yang Xu Feb. 11, 2022, 8:30 a.m. UTC | #6
Hi Bogdan
> Hi all,
>
> I didn't go for CONFIG_SWAP just because wanted to be aligned with
> syscalls/swapon/swapon03.c and to not multiply patterns.
>
> If you see CONFIG_SWAP more beneficial for docparser, I can make another
> patch.
>
> Should I?
IMO, yes, but let's listen voice from other maintainers.
@Petr,@Cyril

Best Regards
Yang Xu
>
> Cheers,
> Bogdan
> ------------------------------------------------------------------------
> *From:* ltp <ltp-bounces+bogdan.lezhepekov=suse.com@lists.linux.it> on
> behalf of xuyang2018.jy@fujitsu.com <xuyang2018.jy@fujitsu.com>
> *Sent:* Friday, February 11, 2022 3:21
> *To:* Li Wang <liwang@redhat.com>
> *Cc:* LTP List <ltp@lists.linux.it>
> *Subject:* Re: [LTP] [PATCH v1] mem/swapping01: Make sure swap is
> supported by kernel
> Hi Li
>>
>>
>>  On Fri, Feb 11, 2022 at 12:09 AM Cyril Hrubis <chrubis@suse.cz
>>  <mailto:chrubis@suse.cz>> wrote:
>>
>>  Hi!
>>  Applied, thanks.
>>
>>  I guess that the SAFE_OPEN() caused TBROK on machines without
>>  CONFIG_SWAP, right?
>>
>>
>>  If so, why not go fix with .needs_config for "CONFIG_SWAP=y" ?
> +1, it is also friendly to docparse.
>
> ps: I never listen user complaint for the lack of CONFIG_PORC, so only
> using .needs_config for "CONFIG_SWAP=y" can work well.
>
> Best Regards
> Yang Xu
>>
>>  --
>>  Regards,
>>  Li Wang
>>
>>
>>
>>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
Petr Vorel Feb. 11, 2022, 8:59 a.m. UTC | #7
Hi all,

> Hi Bogdan
> > Hi all,

> > I didn't go for CONFIG_SWAP just because wanted to be aligned with
> > syscalls/swapon/swapon03.c and to not multiply patterns.

> > If you see CONFIG_SWAP more beneficial for docparser, I can make another
> > patch.

> > Should I?
> IMO, yes, but let's listen voice from other maintainers.
> @Petr,@Cyril

We have 3 options.

1) keep check access("/proc/swaps", F_OK)
2) use .needs_config for "CONFIG_SWAP=y"
3) Add .needs_swap flag to struct tst_test

To be honest, I'm not sure, what's the best, probably .needs_config.
I worried little bit about .needs_config forcing config to be available in the
past, but that should be solved KCONFIG_SKIP_CHECK added by Xu.

Kind regards,
Petr

> Best Regards
> Yang Xu

> > Cheers,
> > Bogdan
> > ------------------------------------------------------------------------
> > *From:* ltp <ltp-bounces+bogdan.lezhepekov=suse.com@lists.linux.it> on
> > behalf of xuyang2018.jy@fujitsu.com <xuyang2018.jy@fujitsu.com>
> > *Sent:* Friday, February 11, 2022 3:21
> > *To:* Li Wang <liwang@redhat.com>
> > *Cc:* LTP List <ltp@lists.linux.it>
> > *Subject:* Re: [LTP] [PATCH v1] mem/swapping01: Make sure swap is
> > supported by kernel
> > Hi Li


> >>  On Fri, Feb 11, 2022 at 12:09 AM Cyril Hrubis <chrubis@suse.cz
> >>  <mailto:chrubis@suse.cz>> wrote:

> >>  Hi!
> >>  Applied, thanks.

> >>  I guess that the SAFE_OPEN() caused TBROK on machines without
> >>  CONFIG_SWAP, right?


> >>  If so, why not go fix with .needs_config for "CONFIG_SWAP=y" ?
> > +1, it is also friendly to docparse.

> > ps: I never listen user complaint for the lack of CONFIG_PORC, so only
> > using .needs_config for "CONFIG_SWAP=y" can work well.

> > Best Regards
> > Yang Xu

> >>  --
> >>  Regards,
> >>  Li Wang
Cyril Hrubis Feb. 11, 2022, 1:15 p.m. UTC | #8
Hi!
> 1) keep check access("/proc/swaps", F_OK)
> 2) use .needs_config for "CONFIG_SWAP=y"
> 3) Add .needs_swap flag to struct tst_test
> 
> To be honest, I'm not sure, what's the best, probably .needs_config.
> I worried little bit about .needs_config forcing config to be available in the
> past, but that should be solved KCONFIG_SKIP_CHECK added by Xu.

I guess that the easiest solution would be .needs_kconfig, we ended up
depending on it in quite a few testcases anyway so I would say that
nobody is runing LTP without having kernel config exproted anyways.
Bogdan Lezhepekov Feb. 11, 2022, 1:16 p.m. UTC | #9
Hi,

Ok, I will send out a new patch.

Do I need to update syscalls/swapon/swapon03.c accordingly to make it a pattern?

Cheers,
Bogdan
Li Wang Feb. 12, 2022, 2:19 a.m. UTC | #10
On Fri, Feb 11, 2022 at 9:16 PM Bogdan Lezhepekov <
bogdan.lezhepekov@suse.com> wrote:

> Hi,
>
> Ok, I will send out a new patch.
>
> Do I need to update syscalls/swapon/swapon03.c accordingly to make it a
> pattern?
>

Yes, that would be great to have. Thanks~
diff mbox series

Patch

diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index 1a494bf69..3b4f0a61a 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -155,11 +155,18 @@  static void check_swapping(void)
 	SAFE_WAITPID(pid, &status, 0);
 }
 
+static void setup(void)
+{
+	if (access("/proc/swaps", F_OK))
+		tst_brk(TCONF, "swap not supported by kernel");
+}
+
 static struct tst_test test = {
 	.needs_root = 1,
 	.forks_child = 1,
 	.min_mem_avail = 10,
 	.test_all = test_swapping,
+	.setup = setup,
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "50a15981a1fa"},
 		{}