From f789437d98aa5d7afc7d446114d7390dd1daf1a3 Mon Sep 17 00:00:00 2001 From: Davide Cavalca Date: Wed, 4 Jan 2023 09:46:35 -0800 Subject: [PATCH] tests: add test harness for %_include_frame_pointers --- tests/include-frame-pointers/main.fmf | 7 ++++ tests/include-frame-pointers/runtest.sh | 52 +++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/include-frame-pointers/main.fmf create mode 100755 tests/include-frame-pointers/runtest.sh diff --git a/tests/include-frame-pointers/main.fmf b/tests/include-frame-pointers/main.fmf new file mode 100644 index 0000000..a41b1a9 --- /dev/null +++ b/tests/include-frame-pointers/main.fmf @@ -0,0 +1,7 @@ +summary: Test that conditional support for frame pointers works + +require: + - grep + - redhat-rpm-config + - rpm +test: ./runtest.sh diff --git a/tests/include-frame-pointers/runtest.sh b/tests/include-frame-pointers/runtest.sh new file mode 100755 index 0000000..3434684 --- /dev/null +++ b/tests/include-frame-pointers/runtest.sh @@ -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"