From 91021e748ecd226ca006583fc2cc320b5039a09d Mon Sep 17 00:00:00 2001 From: Stephen Webb Date: Fri, 5 Aug 2022 10:15:59 -0400 Subject: 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. --- .github/workflows/CI-linux.yml | 33 +++++---- scripts/qemu-test-driver | 156 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+), 14 deletions(-) create mode 100755 scripts/qemu-test-driver 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 . + +# 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 or send patches to +# . + +# 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 <$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: -- cgit v1.2.1