summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Webb <swebb@blackberry.com>2022-08-05 10:15:59 -0400
committerStephen M. Webb <stephen.webb@bregmasoft.ca>2022-08-05 15:17:27 -0400
commit91021e748ecd226ca006583fc2cc320b5039a09d (patch)
treedbcc9fce7bfbb5da25ca4218d373682f9c498ab1
parent14e199e1f2edeecc5789e3ce10dbd5de7fd86441 (diff)
downloadlibunwind-91021e748ecd226ca006583fc2cc320b5039a09d.tar.gz
Cross-build CI `make check` QEMU tweak
The cross-built CI runs using GiotHub actions were using QEMU to run `make check`. Instead, the host should run `make check` and the actual test binary should be run under QEMU. This change configures the cross build to use a (new) qemu-test-driver script as the test harness, which in turn invokes the test under QEMU. The tests are linked to the libunwind libraries statically to avoid complicating the search paths and invoking libtool. Fixes #401.
-rw-r--r--.github/workflows/CI-linux.yml33
-rwxr-xr-xscripts/qemu-test-driver156
2 files changed, 175 insertions, 14 deletions
diff --git a/.github/workflows/CI-linux.yml b/.github/workflows/CI-linux.yml
index 9405cf12..3abef54d 100644
--- a/.github/workflows/CI-linux.yml
+++ b/.github/workflows/CI-linux.yml
@@ -79,18 +79,18 @@ jobs:
fail-fast: false
matrix:
config:
- - {target: arm, toolchain: gcc-arm-linux-gnueabi, host: arm-linux-gnueabi, qemu: qemu-arm-static }
- - {target: armhf, toolchain: gcc-arm-linux-gnueabihf, host: arm-linux-gnueabihf, qemu: qemu-arm-static }
- - {target: aarch64, toolchain: gcc-aarch64-linux-gnu, host: aarch64-linux-gnu, qemu: qemu-aarch64-static }
- - {target: riscv64, toolchain: gcc-riscv64-linux-gnu, host: riscv64-linux-gnu, qemu: qemu-riscv64-static }
- - {target: ppc, toolchain: gcc-powerpc-linux-gnu, host: powerpc-linux-gnu, qemu: qemu-ppc-static }
- - {target: ppc64, toolchain: gcc-powerpc64-linux-gnu, host: powerpc64-linux-gnu, qemu: qemu-ppc64-static }
- - {target: ppc64le, toolchain: gcc-powerpc64le-linux-gnu, host: powerpc64le-linux-gnu, qemu: qemu-ppc64le-static }
- - {target: s390x, toolchain: gcc-s390x-linux-gnu, host: s390x-linux-gnu, qemu: qemu-s390x-static }
- - {target: mips, toolchain: gcc-mips-linux-gnu, host: mips-linux-gnu, qemu: qemu-mips-static }
- - {target: mips64, toolchain: gcc-mips64-linux-gnuabi64, host: mips64-linux-gnuabi64, qemu: qemu-mips64-static }
- - {target: mipsel, toolchain: gcc-mipsel-linux-gnu, host: mipsel-linux-gnu, qemu: qemu-mipsel-static }
- - {target: mips64el,toolchain: gcc-mips64el-linux-gnuabi64, host: mips64el-linux-gnuabi64,qemu: qemu-mips64el-static }
+ - {target: arm, toolchain: g++-arm-linux-gnueabi, host: arm-linux-gnueabi, qemu: arm }
+ - {target: armhf, toolchain: g++-arm-linux-gnueabihf, host: arm-linux-gnueabihf, qemu: arm }
+ - {target: aarch64, toolchain: g++-aarch64-linux-gnu, host: aarch64-linux-gnu, qemu: aarch64 }
+ - {target: riscv64, toolchain: g++-riscv64-linux-gnu, host: riscv64-linux-gnu, qemu: riscv64 }
+ - {target: ppc, toolchain: g++-powerpc-linux-gnu, host: powerpc-linux-gnu, qemu: ppc }
+ - {target: ppc64, toolchain: g++-powerpc64-linux-gnu, host: powerpc64-linux-gnu, qemu: ppc64 }
+ - {target: ppc64le, toolchain: g++-powerpc64le-linux-gnu, host: powerpc64le-linux-gnu, qemu: ppc64le }
+ - {target: s390x, toolchain: g++-s390x-linux-gnu, host: s390x-linux-gnu, qemu: s390x }
+ - {target: mips, toolchain: g++-mips-linux-gnu, host: mips-linux-gnu, qemu: mips }
+ - {target: mips64, toolchain: g++-mips64-linux-gnuabi64, host: mips64-linux-gnuabi64, qemu: mips64 }
+ - {target: mipsel, toolchain: g++-mipsel-linux-gnu, host: mipsel-linux-gnu, qemu: mipsel }
+ - {target: mips64el,toolchain: g++-mips64el-linux-gnuabi64, host: mips64el-linux-gnuabi64,qemu: mips64el }
steps:
- uses: actions/checkout@v2
@@ -112,7 +112,7 @@ jobs:
set -x
autoreconf -i
BUILD=x86_64-linux-gnu
- ./configure --build=$BUILD --host=${{ matrix.config.host }}
+ ./configure --build=$BUILD --host=${{ matrix.config.host }} --with-testdriver=$(pwd)/scripts/qemu-test-driver
- name: Build
run: |
make -j8
@@ -121,4 +121,9 @@ jobs:
set -x
sudo bash -c 'echo core.%p.%p > /proc/sys/kernel/core_pattern'
ulimit -c unlimited
- ${{ matrix.config.qemu }} make -j8 check
+ CROSS_LIB="/usr/${{ matrix.config.host }}"
+ make -j8 check LOG_DRIVER_FLAGS="--qemu-arch ${{ matrix.config.qemu }}" LDFLAGS="-L$CROSS_LIB/lib -static" QEMU_LD_PREFIX="$CROSS_LIB"
+ - name: Show Logs
+ if: ${{ failure() }}
+ run: |
+ cat tests/test-suite.log 2>/dev/null
diff --git a/scripts/qemu-test-driver b/scripts/qemu-test-driver
new file mode 100755
index 00000000..6b49d824
--- /dev/null
+++ b/scripts/qemu-test-driver
@@ -0,0 +1,156 @@
+#! /bin/sh
+# qemu-test-driver - testsuite driver script modified to use qemu
+
+scriptversion=2013-07-13.22; # UTC
+
+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+# Make unconditional expansion of undefined variables an error. This
+# helps a lot in preventing typo-related bugs.
+set -u
+
+usage_error ()
+{
+ echo "$0: $*" >&2
+ print_usage >&2
+ exit 2
+}
+
+print_usage ()
+{
+ cat <<END
+Usage:
+ test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
+ [--expect-failure={yes|no}] [--color-tests={yes|no}]
+ [--enable-hard-errors={yes|no}] [--]
+ TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
+The '--test-name', '--log-file' and '--trs-file' options are mandatory.
+END
+}
+
+test_name= # Used for reporting.
+log_file= # Where to save the output of the test script.
+trs_file= # Where to save the metadata of the test run.
+expect_failure=no
+color_tests=no
+enable_hard_errors=yes
+verbose=no
+while test $# -gt 0; do
+ case $1 in
+ --help) print_usage; exit $?;;
+ --version) echo "test-driver $scriptversion"; exit $?;;
+ --test-name) test_name=$2; shift;;
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ --color-tests) color_tests=$2; shift;;
+ --expect-failure) expect_failure=$2; shift;;
+ --enable-hard-errors) enable_hard_errors=$2; shift;;
+ --qemu-arch) qemu_arch=$2; shift;;
+ --verbose) verbose=$2; shift;;
+ --) shift; break;;
+ -*) usage_error "invalid option: '$1'";;
+ *) break;;
+ esac
+ shift
+done
+
+missing_opts=
+test x"$test_name" = x && missing_opts="$missing_opts --test-name"
+test x"$log_file" = x && missing_opts="$missing_opts --log-file"
+test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
+test x"$qemu_arch" = x && missing_opts="$missing_opts --qemu-arch"
+if test x"$missing_opts" != x; then
+ usage_error "the following mandatory options are missing:$missing_opts"
+fi
+
+if test $# -eq 0; then
+ usage_error "missing argument"
+fi
+
+if test $color_tests = yes; then
+ # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
+ red='' # Red.
+ grn='' # Green.
+ lgn='' # Light green.
+ blu='' # Blue.
+ mgn='' # Magenta.
+ std='' # No color.
+else
+ red= grn= lgn= blu= mgn= std=
+fi
+
+do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
+trap "st=129; $do_exit" 1
+trap "st=130; $do_exit" 2
+trap "st=141; $do_exit" 13
+trap "st=143; $do_exit" 15
+
+qemu_cmd="qemu-${qemu_arch}-static"
+# Test script is run here.
+if test x$verbose != xno; then
+ printf "%s\n" "${qemu_cmd} $@"
+fi
+${qemu_cmd} "$@" >$log_file 2>&1
+estatus=$?
+
+if test $enable_hard_errors = no && test $estatus -eq 99; then
+ tweaked_estatus=1
+else
+ tweaked_estatus=$estatus
+fi
+
+case $tweaked_estatus:$expect_failure in
+ 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
+ 0:*) col=$grn res=PASS recheck=no gcopy=no;;
+ 77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
+ 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
+ *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
+ *:*) col=$red res=FAIL recheck=yes gcopy=yes;;
+esac
+
+# Report the test outcome and exit status in the logs, so that one can
+# know whether the test passed or failed simply by looking at the '.log'
+# file, without the need of also peaking into the corresponding '.trs'
+# file (automake bug#11814).
+echo "$res $test_name (exit status: $estatus)" >>$log_file
+
+# Report outcome to console.
+echo "${col}${res}${std}: $test_name"
+
+# Register the test result, and other relevant metadata.
+echo ":test-result: $res" > $trs_file
+echo ":global-test-result: $res" >> $trs_file
+echo ":recheck: $recheck" >> $trs_file
+echo ":copy-in-global-log: $gcopy" >> $trs_file
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End: