Re: [LTP] [PATCH] vma05.sh: Fix check for core file presence

Xiao Yang
2023-11-28T03:03:13Z

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