Files
qt5/coin/provisioning/common/linux/enable_test_stacktraces.sh
Dimitrios Apostolou 358a5f58e2 Enable automatic gdb stacktrace in QTest, in case a test crashes
On Linux, this requires that gdb can be found in PATH, and that no
kernel security settings like yama.ptrace_scope  prevent it.

Patch contains also a drive-by architecture detection fix for Debian arm64.

Fixes: QTQAINFRA-6029
Fixes: QTQAINFRA-5940
Fixes: QTQAINFRA-6030
Fixes: QTQAINFRA-6046
Fixes: QTQAINFRA-6012
Fixes: QTQAINFRA-5930
Task-number: QTQAINFRA-5933
Change-Id: Ie6debde94c1cc5783161ffa7354b58734c372702
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Toni Saario <toni.saario@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit c66f8407a8)
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
2024-02-14 09:19:41 +00:00

36 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
#Copyright (C) 2023 The Qt Company Ltd
#SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
### Enable automatic stacktraces in case of fatal errors in QTest.
# This requires that gdb can be found in PATH, and that no
# kernel security settings like yama.ptrace_scope prevent it.
PROVISIONING_DIR="$(dirname "$0")/../.."
source "$PROVISIONING_DIR/common/unix/common.sourced.sh"
f="/etc/sysctl.d/10-ptrace.conf"
if [ -f $f ]
then
echo "Modifying $f ..."
sudo sed -i '/^kernel\.yama\.ptrace_scope *= *[1-9]$/s/[1-9]$/0/' $f
# Reload the modified setting, so that we can verify it right afterwards.
sudo sysctl -p $f
fi
# Verify that yama.ptrace_scope = 0, if it's supported by the kernel.
ptrace_scope_value=`sudo sysctl kernel.yama.ptrace_scope 2>/dev/null \
| sed -E 's/.*([0-9])$/\1/'`
if [ -n "$ptrace_scope_value" ] && [ "$ptrace_scope_value" != 0 ]
then
fatal "kernel.yama.ptrace_scope = $ptrace_scope_value \
which means that QTest automatic stacktraces will not work"
else
echo kernel.yama.ptrace_scope = "$ptrace_scope_value"
fi
$CMD_PKG_INSTALL gdb