strace/tests/strace-V.test
Dmitry V. Levin 2713444cb7 unwind: prepare configure subsystem for alternative unwinders
Introduce --enable-stacktrace configure option to control whether
-k option support is compiled in, --with-libunwind option remains
available to control whether libunwind can be used as an unwinder.

* m4/st_demangle.m4: New file.
* m4/st_libunwind.m4: Likewise.
* m4/st_stacktrace.m4: Likewise.
* configure.ac: Replace all libunwind and libiberty checks
with a single st_STACKTRACE invocation.
* Makefile.am: Conditionalize checks for USE_LIBUNWIND and USE_DEMANGLE
on ENABLE_STACKTRACE.
[ENABLE_STACKTRACE] (strace_SOURCES): Append unwind.c and unwind.h.
* strace.1.in: Replace libunwind with an unwinder-agnostic wording.
* defs.h: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* strace.c: Likewise.
(print_version): Print stack-trace instead of stack-unwind.
* syscall.c: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* tests/Makefile.am: Likewise.  Replace LIBUNWIND_TESTS
with STACKTRACE_TESTS.
* tests/strace-V.test: Update expected output.
2018-04-08 22:01:12 +00:00

70 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
# Check -V option.
. "${srcdir=.}/init.sh"
run_prog_skip_if_failed date +%Y > /dev/null
year="$(date +%Y)"
run_strace -V > "$LOG"
getstr()
{
sed -r -n 's/#define[[:space:]]*'"$1"'[[:space:]]*"([^"]*)".*/\1/p' \
../../config.h
}
# getoption OPTION YES_STRING [NO_STRING]
#
# Returns YES_STRING in case OPTION is enabled (present in config.h and has
# a non-zero numeric value). Otherwise, NO_STRING (or empty string, if not
# specified) is returned.
getoption()
{
local opt
opt=$(sed -r -n 's/#define[[:space:]]*'"$1"'[[:space:]]*([0-9]+)$/\1/p' \
../../config.h)
if [ -n "$opt" -a "$opt" -ne 0 ]; then
printf "%s" "$2"
else
printf "%s" "${3-}"
fi
}
config_year=$(getstr COPYRIGHT_YEAR)
[ "$year" -ge "$config_year" ] && [ "$config_year" -ge 2017 ] || {
echo >&2 "The year derived from config.h (${config_year}) does not pass sanity checks."
exit 1
}
option_unwind=$(getoption ENABLE_STACKTRACE \
" stack-trace=$(getstr USE_UNWINDER)")
option_demangle=$(getoption USE_DEMANGLE " stack-demangle")
option_m32=
option_mx32=
case "$STRACE_NATIVE_ARCH" in
x86_64)
option_m32=$(getoption HAVE_M32_MPERS ' m32-mpers' ' no-m32-mpers')
option_mx32=$(getoption HAVE_MX32_MPERS ' mx32-mpers' ' no-mx32-mpers')
;;
aarch64|powerpc64|riscv|s390x|sparc64|tile|x32)
option_m32=$(getoption HAVE_M32_MPERS ' m32-mpers' ' no-m32-mpers')
;;
esac
features="${option_unwind}${option_demangle}${option_m32}${option_mx32}"
[ -n "$features" ] || features=" (none)"
cat > "$EXP" << __EOF__
$(getstr PACKAGE_NAME) -- version $(getstr PACKAGE_VERSION)
Copyright (c) 1991-${config_year} The strace developers <$(getstr PACKAGE_URL)>.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Optional features enabled:${features}
__EOF__
match_diff "$LOG" "$EXP"