tests: add test harness for %_include_frame_pointers

This commit is contained in:
Davide Cavalca 2023-01-04 09:46:35 -08:00
parent 9ce7719338
commit f789437d98
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,7 @@
summary: Test that conditional support for frame pointers works
require:
- grep
- redhat-rpm-config
- rpm
test: ./runtest.sh

View File

@ -0,0 +1,52 @@
#!/bin/sh
# Not using set -e on purpose as we manually validate the exit codes to print
# useful messages.
set -u
passed=0
failed=0
rpmeval() {
# Note: --eval needs to always be *last* here
rpm "$@" --eval='%optflags'
}
validate() {
ret=$?
if [ $ret -eq 0 ]; then
echo "PASS: $*"
passed=$((passed+1))
else
echo "FAIL: $*"
failed=$((failed+1))
fi
}
for arch in aarch64 armv7hl i386 i486 i585 i686 athlon x86_64 ppc64le s390x riscv64; do
case "$arch" in
x86_64|aarch64)
flags='-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer'
;;
s390x)
flags='-fno-omit-frame-pointer -mbackchain'
;;
*)
flags='-fno-omit-frame-pointer'
;;
esac
rpmeval --target="${arch}-linux" --define='%_include_frame_pointers 1' | grep -q -- "$flags"
validate "[${arch}] Test that the flags are included if the macro is defined"
rpmeval --target="${arch}-linux" --undefine='_include_frame_pointers' | grep -qv -- "$flags"
validate "[${arch}] Test that the flags are _not_ included if the macro is undefined"
rpmeval --target="${arch}-linux" | grep -q -- "$flags"
validate "[${arch}] Test that the flags are included by default"
done
echo
echo "${passed} passed, ${failed} failed"
exit "$failed"