public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] vma05.sh: Fix check for core file presence
@ 2023-11-10  3:56 Yang Xu
  2023-11-16  2:02 ` Yang Xu (Fujitsu)
  2023-11-28  3:02 ` Xiao Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Yang Xu @ 2023-11-10  3:56 UTC (permalink / raw)
  To: ltp

When I tested it, I found that the test produced the error:
vma05 1 TBROK: missing core file

I try to get the generated core file
  rm -rf core*
  { vma05_vdso; } > /dev/null 2>&1
+ ls -l *core*
  [ -f core ] || tst_brk TCONF "missing core file"

<<<test_output>>>
incrementing stop
vma05 1 TINFO: timeout per run is 0h 5m 0s
vma05 1 TPASS: [vsyscall] reported correctly
-rw------- 1 root root 458752 Nov 10 02:16 core.931905
vma05 1 TBROK: missing core file

The test actually generates not core but in the form of core.n
So may be '[ -f core ]' should be changed to '[ -f core* ]'

Fixes: 63529eef ("vma05.sh: Add check for core file presence")
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/mem/vma/vma05.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/mem/vma/vma05.sh b/testcases/kernel/mem/vma/vma05.sh
index a09951462..6f5459308 100755
--- a/testcases/kernel/mem/vma/vma05.sh
+++ b/testcases/kernel/mem/vma/vma05.sh
@@ -54,7 +54,7 @@ vma_report_check()
 
 	rm -rf core*
 	{ vma05_vdso; } > /dev/null 2>&1
-	[ -f core ] || tst_brk TBROK "missing core file"
+	[ -f core* ] || tst_brk TBROK "missing core file"
 
 	TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\
 		vma05_vdso ./core* 2> /dev/null)
-- 
2.39.1


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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] vma05.sh: Fix check for core file presence
  2023-11-10  3:56 [LTP] [PATCH] vma05.sh: Fix check for core file presence Yang Xu
@ 2023-11-16  2:02 ` Yang Xu (Fujitsu)
  2023-11-28  3:02 ` Xiao Yang
  1 sibling, 0 replies; 4+ messages in thread
From: Yang Xu (Fujitsu) @ 2023-11-16  2:02 UTC (permalink / raw)
  To: ltp@lists.linux.it

Hi all,

Ping

Best Regards
Yang Xu

>When I tested it, I found that the test produced the error:
>vma05 1 TBROK: missing core file

>I try to get the generated core file
>  rm -rf core*
>  { vma05_vdso; } > /dev/null 2>&1
>+ ls -l *core*
>  [ -f core ] || tst_brk TCONF "missing core file"

><<<test_output>>>
>incrementing stop
>vma05 1 TINFO: timeout per run is 0h 5m 0s
>vma05 1 TPASS: [vsyscall] reported correctly
>-rw------- 1 root root 458752 Nov 10 02:16 core.931905
>vma05 1 TBROK: missing core file

>The test actually generates not core but in the form of core.n
>So may be '[ -f core ]' should be changed to '[ -f core* ]'

>Fixes: 63529eef ("vma05.sh: Add check for core file presence")
>Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
>---
 >testcases/kernel/mem/vma/vma05.sh | 2 +-
 >1 file changed, 1 insertion(+), 1 deletion(-)

>diff --git a/testcases/kernel/mem/vma/vma05.sh b/testcases/kernel/mem/vma/vma05.sh
>index a09951462..6f5459308 100755
>--- a/testcases/kernel/mem/vma/vma05.sh
>+++ b/testcases/kernel/mem/vma/vma05.sh
>@@ -54,7 +54,7 @@ vma_report_check()

>         rm -rf core*
>         { vma05_vdso; } > /dev/null 2>&1
>-       [ -f core ] || tst_brk TBROK "missing core file"
>+       [ -f core* ] || tst_brk TBROK "missing core file"

 >        TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\
 >                vma05_vdso ./core* 2> /dev/null)
--
2.39.1


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] vma05.sh: Fix check for core file presence
  2023-11-10  3:56 [LTP] [PATCH] vma05.sh: Fix check for core file presence Yang Xu
  2023-11-16  2:02 ` Yang Xu (Fujitsu)
@ 2023-11-28  3:02 ` Xiao Yang
  2023-11-28 13:35   ` Petr Vorel
  1 sibling, 1 reply; 4+ messages in thread
From: Xiao Yang @ 2023-11-28  3:02 UTC (permalink / raw)
  To: Yang Xu, ltp

Hi Yang

On 2023/11/10 11:56, Yang Xu wrote:
>   	rm -rf core*
>   	{ vma05_vdso; } > /dev/null 2>&1
> -	[ -f core ] || tst_brk TBROK "missing core file"
> +	[ -f core* ] || tst_brk TBROK "missing core file"

The root cause seems that the name of core file contains the pid number 
by default. I think the better solution is set 
/proc/sys/kernel/core_uses_pid to 0 before running vma05_vdso. Like this:

diff --git a/testcases/kernel/mem/vma/vma05.sh 
b/testcases/kernel/mem/vma/vma05.sh
index a09951462..e1ef1014e 100755
--- a/testcases/kernel/mem/vma/vma05.sh
+++ b/testcases/kernel/mem/vma/vma05.sh
@@ -25,11 +25,13 @@ TST_NEEDS_CMDS="gdb"

  CORE_LIMIT=$(ulimit -c)
  CORE_PATTERN=$(cat /proc/sys/kernel/core_pattern)
+CORE_USES_PID=$(cat /proc/sys/kernel/core_uses_pid)

  setup()
  {
         ulimit -c unlimited
         echo "core" > /proc/sys/kernel/core_pattern
+       echo 0 > /proc/sys/kernel/core_uses_pid
         unset DEBUGINFOD_URLS
  }

@@ -37,6 +39,7 @@ cleanup()
  {
         ulimit -c "$CORE_LIMIT"
         echo "$CORE_PATTERN" > /proc/sys/kernel/core_pattern
+       echo $CORE_USES_PID > /proc/sys/kernel/core_uses_pid
  }

Best Regards,
Xiao Yang

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] vma05.sh: Fix check for core file presence
  2023-11-28  3:02 ` Xiao Yang
@ 2023-11-28 13:35   ` Petr Vorel
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2023-11-28 13:35 UTC (permalink / raw)
  To: Xiao Yang; +Cc: ltp

Hi,

> Hi Yang

> On 2023/11/10 11:56, Yang Xu wrote:
> >   	rm -rf core*
> >   	{ vma05_vdso; } > /dev/null 2>&1
> > -	[ -f core ] || tst_brk TBROK "missing core file"
> > +	[ -f core* ] || tst_brk TBROK "missing core file"
This will not work in case of more files:

$ touch core.foo core.bar; [ -f core* ]
bash: [: core.bar: binary operator expected

> The root cause seems that the name of core file contains the pid number by
> default. I think the better solution is set /proc/sys/kernel/core_uses_pid
> to 0 before running vma05_vdso. Like this:

> diff --git a/testcases/kernel/mem/vma/vma05.sh
> b/testcases/kernel/mem/vma/vma05.sh
> index a09951462..e1ef1014e 100755
> --- a/testcases/kernel/mem/vma/vma05.sh
> +++ b/testcases/kernel/mem/vma/vma05.sh
> @@ -25,11 +25,13 @@ TST_NEEDS_CMDS="gdb"

>  CORE_LIMIT=$(ulimit -c)
>  CORE_PATTERN=$(cat /proc/sys/kernel/core_pattern)
> +CORE_USES_PID=$(cat /proc/sys/kernel/core_uses_pid)

>  setup()
>  {
>         ulimit -c unlimited
>         echo "core" > /proc/sys/kernel/core_pattern
> +       echo 0 > /proc/sys/kernel/core_uses_pid
>         unset DEBUGINFOD_URLS
>  }

> @@ -37,6 +39,7 @@ cleanup()
>  {
>         ulimit -c "$CORE_LIMIT"
>         echo "$CORE_PATTERN" > /proc/sys/kernel/core_pattern
> +       echo $CORE_USES_PID > /proc/sys/kernel/core_uses_pid
>  }

This patch looks better to me. Feel free to merge it with my RBT
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

> Best Regards,
> Xiao Yang

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-28 13:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-10  3:56 [LTP] [PATCH] vma05.sh: Fix check for core file presence Yang Xu
2023-11-16  2:02 ` Yang Xu (Fujitsu)
2023-11-28  3:02 ` Xiao Yang
2023-11-28 13:35   ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox