diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e861c042..0b691773 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,14 +136,24 @@ jobs: run: | make -C build/extra/gcc-m32/debug test make -C build/extra/gcc-m32/release test + - name: 'Mimic ctest tests' + run: | + env -C build/extra/gcc/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh + env -C build/extra/gcc/release bash "$PWD"/misc/testsuite/mimic_ctest.sh + env -C build/extra/clang/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh + env -C build/extra/clang/release bash "$PWD"/misc/testsuite/mimic_ctest.sh + - name: 'Mimic ctest tests 32-bit' + if: ${{ matrix.use_m32 }} + run: | + env -C build/extra/gcc-m32/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh + env -C build/extra/gcc-m32/release bash "$PWD"/misc/testsuite/mimic_ctest.sh - name: 'Run file system test suite' run: | env -C build/extra/gcc/release bash "$PWD"/misc/testsuite/test_symlinks.sh - name: 'Run test suite build/extra/gcc/release' run: | export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)" - testsuite_1="$(readlink -en ./misc/testsuite/upx_testsuite_1.sh)" - env -C build/extra/gcc/release upx_exe=./upx bash "$testsuite_1" + env -C build/extra/gcc/release bash "$PWD"/misc/testsuite/upx_testsuite_1.sh job-macos-cmake: # uses cmake + make if: true @@ -218,12 +228,15 @@ jobs: make -C build/extra/clang/debug test #make -C build/extra/clang/release test for f in ./build/extra/*/*/upx; do echo "===== $f"; $f --sysinfo -v; done + - name: 'Mimic ctest tests' + if: ${{ !contains(matrix.os, 'macos-13') }} # FIXME: UPX on macos-13 is broken => disable self-test for now + run: | + export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" + env -C build/extra/clang/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh + #env -C build/extra/clang/release bash "$PWD"/misc/testsuite/mimic_ctest.sh - name: 'Run file system test suite' if: ${{ matrix.testsuite }} # for coreutils readlink run: | - ## macos-11 does not have "readlink -f" - ## testsuite="$(readlink -fn ./misc/testsuite/test_symlinks.sh)" - ## (cd build/extra/clang/release && upx_exe=./upx bash "$testsuite") export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" env -C build/extra/clang/release bash "$PWD"/misc/testsuite/test_symlinks.sh - name: 'Run test suite build/extra/clang/release' @@ -231,8 +244,7 @@ jobs: run: | export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)" - testsuite_1="$(readlink -en ./misc/testsuite/upx_testsuite_1.sh)" - env -C build/extra/clang/release upx_exe=./upx bash "$testsuite_1" + env -C build/extra/clang/release bash "$PWD"/misc/testsuite/upx_testsuite_1.sh job-windows-cmake: # uses cmake + msbuild if: true @@ -286,8 +298,7 @@ jobs: shell: bash run: | export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)" - testsuite_1="$(readlink -en ./misc/testsuite/upx_testsuite_1.sh)" - env -C build/release/Release upx_exe=./upx bash "$testsuite_1" + env -C build/release/Release bash "$PWD"/misc/testsuite/upx_testsuite_1.sh job-windows-toolchains: # build "by hand" using cmd.exe if: github.repository_owner == 'upx' @@ -397,8 +408,7 @@ jobs: shell: bash run: | export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)" - testsuite_1="$(readlink -en ./misc/testsuite/upx_testsuite_1.sh)" - env -C build/$C/$B/upx upx_exe=./upx.exe bash "$testsuite_1" + env -C build/$C/$B/upx upx_exe=./upx.exe bash "$PWD"/misc/testsuite/upx_testsuite_1.sh job-linux-zigcc: # uses cmake + make if: github.repository_owner == 'upx' @@ -420,7 +430,7 @@ jobs: - { zig_target: aarch64-windows-gnu } - { zig_target: arm-linux-musleabihf } # { zig_target: arm-linux-musleabihf, zig_pic: -fPIE } - # { zig_target: i386-linux-musl } + - { zig_target: i386-linux-musl } # { zig_target: i386-linux-musl, zig_pic: -fPIE } - { zig_target: i386-windows-gnu } # { zig_target: mips-linux-musl } diff --git a/misc/testsuite/mimic_ctest.sh b/misc/testsuite/mimic_ctest.sh new file mode 100755 index 00000000..38663694 --- /dev/null +++ b/misc/testsuite/mimic_ctest.sh @@ -0,0 +1,75 @@ +#! /usr/bin/env bash +## vim:set ts=4 sw=4 et: +set -e; set -o pipefail +argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs") + +# +# Copyright (C) Markus Franz Xaver Johannes Oberhumer +# +# mimic running "ctest", i.e. the "test" section of CMakeLists.txt; does not redirect stdout +# +# requires: +# $upx_exe (required, but with convenience fallback "./upx") +# optional settings: +# $upx_exe_runner (e.g. "qemu-x86_64 -cpu Nehalem" or "valgrind") +# + +#*********************************************************************** +# init & checks +#*********************************************************************** + +# upx_exe +[[ -z $upx_exe && -f ./upx && -x ./upx ]] && upx_exe=./upx # convenience fallback +if [[ -z $upx_exe ]]; then echo "UPX-ERROR: please set \$upx_exe"; exit 1; fi +if [[ ! -f $upx_exe ]]; then echo "UPX-ERROR: file '$upx_exe' does not exist"; exit 1; fi +upx_exe=$(readlink -fn "$upx_exe") # make absolute +[[ -f $upx_exe ]] || exit 1 +upx_run=() +if [[ -n $upx_exe_runner ]]; then + # usage examples: + # export upx_exe_runner="qemu-x86_64 -cpu Nehalem" + # export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet" + # export upx_exe_runner="wine" + IFS=' ' read -r -a upx_run <<< "$upx_exe_runner" # split at spaces into array +elif [[ -n $CMAKE_CROSSCOMPILING_EMULATOR ]]; then + IFS=';' read -r -a upx_run <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array +fi +upx_runner=( "${upx_run[@]}" ) +upx_run+=( "$upx_exe" ) +echo "upx_run='${upx_run[*]}'" + +# upx_run sanity check +if ! "${upx_run[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi +if ! "${upx_run[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi +if ! "${upx_run[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi + +#*********************************************************************** +# see CMakeLists.txt +#*********************************************************************** + +export UPX="--no-color --no-progress" + +"${upx_run[@]}" --version +"${upx_run[@]}" --help +"${upx_run[@]}" --sysinfo -v + +exe=".out" +upx_self_exe=$upx_exe +fo="--force-overwrite" + +"${upx_run[@]}" -3 "${upx_self_exe}" ${fo} -o upx-packed${exe} +"${upx_run[@]}" -3 --nrv2b "${upx_self_exe}" ${fo} -o upx-packed-n2b${exe} +"${upx_run[@]}" -3 --nrv2d "${upx_self_exe}" ${fo} -o upx-packed-n2d${exe} +"${upx_run[@]}" -3 --nrv2e "${upx_self_exe}" ${fo} -o upx-packed-n2e${exe} +"${upx_run[@]}" -1 --lzma "${upx_self_exe}" ${fo} -o upx-packed-lzma${exe} + +"${upx_run[@]}" -l upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe} +"${upx_run[@]}" --fileinfo upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe} +"${upx_run[@]}" -t upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe} +"${upx_run[@]}" -d upx-packed${exe} ${fo} -o upx-unpacked${exe} + +set -x +"${upx_runner[@]}" ./upx-unpacked${exe} --version-short +"${upx_runner[@]}" ./upx-packed${exe} --version-short + +echo "All done." diff --git a/misc/testsuite/test_symlinks.sh b/misc/testsuite/test_symlinks.sh index 841b768c..617ad95e 100755 --- a/misc/testsuite/test_symlinks.sh +++ b/misc/testsuite/test_symlinks.sh @@ -46,11 +46,13 @@ if [[ -n $upx_exe_runner ]]; then # export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet" # export upx_exe_runner="wine" IFS=' ' read -r -a upx_run <<< "$upx_exe_runner" # split at spaces into array +elif [[ -n $CMAKE_CROSSCOMPILING_EMULATOR ]]; then + IFS=';' read -r -a upx_run <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array fi upx_run+=( "$upx_exe" ) echo "upx_run='${upx_run[*]}'" -# upx_run check +# upx_run sanity check if ! "${upx_run[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi if ! "${upx_run[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi if ! "${upx_run[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi diff --git a/misc/testsuite/upx_testsuite_1.sh b/misc/testsuite/upx_testsuite_1.sh index e92218db..0d5ed7a7 100755 --- a/misc/testsuite/upx_testsuite_1.sh +++ b/misc/testsuite/upx_testsuite_1.sh @@ -36,11 +36,13 @@ if [[ -n $upx_exe_runner ]]; then # export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet" # export upx_exe_runner="wine" IFS=' ' read -r -a upx_run <<< "$upx_exe_runner" # split at spaces into array +elif [[ -n $CMAKE_CROSSCOMPILING_EMULATOR ]]; then + IFS=';' read -r -a upx_run <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array fi upx_run+=( "$upx_exe" ) echo "upx_run='${upx_run[*]}'" -# upx_run check, part1 +# upx_run sanity check, part1 if ! "${upx_run[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi if ! "${upx_run[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi if ! "${upx_run[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi @@ -76,7 +78,7 @@ upx_testsuite_BUILDDIR=$(readlink -fn "$upx_testsuite_BUILDDIR") # make absolute cd / && cd "$upx_testsuite_BUILDDIR" || exit 1 : > ./.mfxnobackup -# upx_run check, part2 +# upx_run sanity check, part2 if ! "${upx_run[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED" echo "please make sure that \$upx_exe contains ABSOLUTE file paths and can be run from any directory"