test/common: don't specify output dir for core_pattern in command line

Remove output directory argument for core-collector.sh when
setting system core_pattern. Instead save the full output
directory path into a file to a known location and read it
directly in core-collector.sh.

The reason for this change is 128 bytes command line length
for core_pattern (see 'man core 5'). In case working with
long paths the core_pattern command line gets truncated and
core dumps are not generated.

Change-Id: Ia74c180e4923fb43d6ff66129ffe54c32827adca
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12755
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Michal Berger <michallinuxstuff@gmail.com>
Reviewed-by: Pawel Piatek <pawelx.piatek@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Karol Latecki 2022-05-20 10:45:16 +02:00 committed by Jim Harris
parent 68108360f9
commit a985a3ae01
3 changed files with 8 additions and 4 deletions

1
.gitignore vendored
View File

@ -39,3 +39,4 @@ PYTHON_COMMAND
test_completions.txt test_completions.txt
timing.txt timing.txt
test/common/build_config.sh test/common/build_config.sh
.coredump_path

View File

@ -28,8 +28,12 @@ fi
if [ $(uname -s) = Linux ]; then if [ $(uname -s) = Linux ]; then
old_core_pattern=$(< /proc/sys/kernel/core_pattern) old_core_pattern=$(< /proc/sys/kernel/core_pattern)
mkdir -p "$output_dir/coredumps" mkdir -p "$output_dir/coredumps"
# set core_pattern to a known value to avoid ABRT, systemd-coredump, etc. # Set core_pattern to a known value to avoid ABRT, systemd-coredump, etc.
echo "|$rootdir/scripts/core-collector.sh %P %s %t %c $output_dir/coredumps" > /proc/sys/kernel/core_pattern # Dump the $output_dir path to a file so collector can pick it up while executing.
# We don't set in in the core_pattern command line because of the string length limitation
# of 128 bytes. See 'man core 5' for details.
echo "|$rootdir/scripts/core-collector.sh %P %s %t %c" > /proc/sys/kernel/core_pattern
echo "$output_dir/coredumps" > "$rootdir/.coredump_path"
# make sure nbd (network block device) driver is loaded if it is available # make sure nbd (network block device) driver is loaded if it is available
# this ensures that when tests need to use nbd, it will be fully initialized # this ensures that when tests need to use nbd, it will be fully initialized

View File

@ -31,7 +31,6 @@ args+=(core_pid)
args+=(core_sig) args+=(core_sig)
args+=(core_ts) args+=(core_ts)
args+=(rlimit) args+=(rlimit)
args+=(output_dir)
read -r "${args[@]}" <<< "$*" read -r "${args[@]}" <<< "$*"
@ -41,7 +40,7 @@ statm=$(< "/proc/$core_pid/statm")
core_time=$(date -d@"$core_ts") core_time=$(date -d@"$core_ts")
core_sig_name=$(kill -l "$core_sig") core_sig_name=$(kill -l "$core_sig")
core=$output_dir/${exe_path##*/}_$core_pid.core core=$(< "${0%/*}/../.coredump_path")/${exe_path##*/}_$core_pid.core
stderr stderr
# RLIMIT_CORE is not enforced when core is piped to us. To make # RLIMIT_CORE is not enforced when core is piped to us. To make