summaryrefslogtreecommitdiff
path: root/tests/strace-V.test
blob: a46948e69b771c437bcc40d895133bd945a82f25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh

# Check -V option.
. "${srcdir=.}/init.sh"

run_prog_skip_if_failed date +%Y > /dev/null
year="$(date +%Y)"

run_strace -V > "$OUT"
run_strace --version > "$LOG"
match_diff "$LOG" "$OUT" '-V and --version output mismatch'

config_year=$(get_config_str 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=$(get_config_option ENABLE_STACKTRACE \
		" stack-trace=$(get_config_str USE_UNWINDER)")
option_demangle=$(get_config_option USE_DEMANGLE " stack-demangle")

option_m32=
option_mx32=
case "$STRACE_NATIVE_ARCH" in
x86_64)
	option_m32=$(get_config_option HAVE_M32_MPERS ' m32-mpers' ' no-m32-mpers')
	option_mx32=$(get_config_option HAVE_MX32_MPERS ' mx32-mpers' ' no-mx32-mpers')
	;;
aarch64|powerpc64|s390x|sparc64|tile|x32)
	option_m32=$(get_config_option HAVE_M32_MPERS ' m32-mpers' ' no-m32-mpers')
	;;
esac

option_secontext=$(get_config_option ENABLE_SECONTEXT " secontext")

features="${option_unwind}${option_demangle}${option_m32}${option_mx32}${option_secontext}"
[ -n "$features" ] || features=" (none)"

for i in $(seq 4); do
	case "$i" in
		1) opt="-V";;
		2) opt="-V -V -V -V";;
		3) opt="-VVVV -VVVV -VVVV -VVVV";;
		4) opt="-VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";;
	esac

	run_strace ${opt} > "${LOG}.${opt}"

	cat > "${EXP}.${opt}" <<-__EOF__
		$(get_config_str PACKAGE_NAME) -- version $(get_config_str PACKAGE_VERSION)
		Copyright (c) 1991-${config_year} The strace developers <$(get_config_str 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__

	if [ 3 -le "$i" ]; then
		cat $srcdir/strauss_head.exp >> "${EXP}.${opt}"
	fi

	if [ 4 -le "$i" ]; then
		cat $srcdir/strauss_body.exp >> "${EXP}.${opt}"
	fi

	match_diff "${LOG}.${opt}" "${EXP}.${opt}"
done