From a985a3ae01bf9f67842f423fbc4f901016eebea8 Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Fri, 20 May 2022 10:45:16 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12755 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Michal Berger Reviewed-by: Pawel Piatek Reviewed-by: Konrad Sztyber Reviewed-by: Jim Harris --- .gitignore | 1 + autotest.sh | 8 ++++++-- scripts/core-collector.sh | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 59c9c630512..23fffb08147 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ PYTHON_COMMAND test_completions.txt timing.txt test/common/build_config.sh +.coredump_path diff --git a/autotest.sh b/autotest.sh index 54f6ba4b389..9098eb2a4ac 100755 --- a/autotest.sh +++ b/autotest.sh @@ -28,8 +28,12 @@ fi if [ $(uname -s) = Linux ]; then old_core_pattern=$(< /proc/sys/kernel/core_pattern) mkdir -p "$output_dir/coredumps" - # 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 + # Set core_pattern to a known value to avoid ABRT, systemd-coredump, etc. + # 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 # this ensures that when tests need to use nbd, it will be fully initialized diff --git a/scripts/core-collector.sh b/scripts/core-collector.sh index 28155b39407..b7355df5271 100755 --- a/scripts/core-collector.sh +++ b/scripts/core-collector.sh @@ -31,7 +31,6 @@ args+=(core_pid) args+=(core_sig) args+=(core_ts) args+=(rlimit) -args+=(output_dir) read -r "${args[@]}" <<< "$*" @@ -41,7 +40,7 @@ statm=$(< "/proc/$core_pid/statm") core_time=$(date -d@"$core_ts") 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 # RLIMIT_CORE is not enforced when core is piped to us. To make