cmake: run tests in parallel; misc/podman: add 30-rebuild-stubs.sh

This commit is contained in:
Markus F.X.J. Oberhumer 2024-04-26 10:36:01 +02:00
parent 0e6478a60f
commit ddf2da3d76
11 changed files with 228 additions and 129 deletions

View File

@ -138,15 +138,15 @@ jobs:
(cd build/extra/gcc/release && DESTDIR="$PWD/Install with make" make install)
- name: 'Run ctest tests'
run: |
make -C build/extra/gcc/debug test
make -C build/extra/gcc/release test
make -C build/extra/clang/debug test
make -C build/extra/clang/release test
make build/extra/gcc/debug+test
make build/extra/gcc/release+test
make build/extra/clang/debug+test
make build/extra/clang/release+test
- name: 'Run ctest tests 32-bit'
if: ${{ matrix.use_m32 }}
run: |
make -C build/extra/gcc-m32/debug test
make -C build/extra/gcc-m32/release test
make build/extra/gcc-m32/debug+test
make build/extra/gcc-m32/release+test
- name: 'Mimic ctest tests'
run: |
env -C build/extra/gcc/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh
@ -276,8 +276,8 @@ jobs:
(cd build/extra/clang/release && DESTDIR="$PWD/Install with make" make install)
- name: 'Run ctest tests'
run: |
make -C build/extra/clang/debug test
make -C build/extra/clang/release test
make build/extra/clang/debug+test
make build/extra/clang/release+test
for f in ./build/extra/*/*/upx; do echo "===== $f"; $f --sysinfo -v; done
- name: 'Mimic ctest tests'
run: |
@ -339,8 +339,8 @@ jobs:
- name: 'Run ctest tests'
if: ${{ matrix.vsarch != 'amd64_arm64' }}
run: |
ctest --test-dir build/debug -C Debug
ctest --test-dir build/release -C Release
ctest --test-dir build/debug --parallel 8 -C Debug
ctest --test-dir build/release --parallel 8 -C Release
- name: 'Run test suite build/release'
if: ${{ matrix.vsarch != 'amd64_arm64' }}
shell: bash
@ -577,8 +577,8 @@ jobs:
- name: 'Run ctest tests'
if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' }}
run: |
make -C build/zig/${ZIG_TARGET}${ZIG_PIC}/debug test
make -C build/zig/${ZIG_TARGET}${ZIG_PIC}/release test
make build/zig/${ZIG_TARGET}${ZIG_PIC}/debug+test
make build/zig/${ZIG_TARGET}${ZIG_PIC}/release+test
- name: 'Mimic ctest tests'
if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' }}
run: |

View File

@ -435,93 +435,21 @@ if(NOT UPX_CONFIG_CMAKE_DISABLE_TEST)
include(CTest)
if(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
add_test(NAME upx-version COMMAND upx --version)
add_test(NAME upx-version-short COMMAND upx --version-short)
add_test(NAME upx-license COMMAND upx --license)
add_test(NAME upx-help-1 COMMAND upx --help)
add_test(NAME upx-help-2 COMMAND upx --help-short)
add_test(NAME upx-help-3 COMMAND upx --help-verbose)
add_test(NAME upx-sysinfo-1 COMMAND upx --sysinfo)
add_test(NAME upx-sysinfo-2 COMMAND upx --sysinfo -v)
add_test(NAME upx-sysinfo-3 COMMAND upx --sysinfo -vv)
if(NOT UPX_CONFIG_DISABLE_SELF_PACK_TEST)
# IMPORTANT NOTE: these tests can only work if the host executable format is supported by UPX!
set(emu "")
if(DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
set(emu "${CMAKE_CROSSCOMPILING_EMULATOR}")
upx_add_test(upx-version upx --version)
upx_add_test(upx-version-short upx --version-short)
upx_add_test(upx-license upx --license)
upx_add_test(upx-help-1 upx --help)
upx_add_test(upx-help-2 upx --help-short)
upx_add_test(upx-help-3 upx --help-verbose)
upx_add_test(upx-sysinfo-1 upx --sysinfo)
upx_add_test(upx-sysinfo-2 upx --sysinfo -v)
upx_add_test(upx-sysinfo-3 upx --sysinfo -vv)
if(NOT UPX_CONFIG_DISABLE_SELF_PACK_TEST)
# IMPORTANT NOTE: these tests can only work if the host executable format
# is supported by UPX!
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/self_pack_test.cmake")
endif()
set(exe "${CMAKE_EXECUTABLE_SUFFIX}")
set(upx_self_exe "$<TARGET_FILE:upx>")
set(fo "--force-overwrite")
# use fast compression levels because
# - we want to test UPX and not the compression libraries
# - higher compression levels are somewhat slow in our automated QEMU/Valgrind CI tests
upx_add_serial_test(upx-self-pack upx -3 "${upx_self_exe}" ${fo} -o upx-packed${exe})
upx_add_serial_test(upx-self-pack-fa upx -3 --all-filters "${upx_self_exe}" ${fo} -o upx-packed-fa${exe})
upx_add_serial_test(upx-self-pack-fn upx -3 --no-filter "${upx_self_exe}" ${fo} -o upx-packed-fn${exe})
upx_add_serial_test(upx-self-pack-fr upx -3 --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-fr${exe})
upx_add_serial_test(upx-self-pack-nrv2b upx -3 --nrv2b "${upx_self_exe}" ${fo} -o upx-packed-nrv2b${exe})
upx_add_serial_test(upx-self-pack-nrv2d upx -3 --nrv2d "${upx_self_exe}" ${fo} -o upx-packed-nrv2d${exe})
upx_add_serial_test(upx-self-pack-nrv2e upx -3 --nrv2e "${upx_self_exe}" ${fo} -o upx-packed-nrv2e${exe})
upx_add_serial_test(upx-self-pack-lzma upx -1 --lzma "${upx_self_exe}" ${fo} -o upx-packed-lzma${exe})
upx_add_serial_test(upx-list upx -l upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe})
upx_add_serial_test(upx-fileinfo upx --fileinfo upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe})
upx_add_serial_test(upx-test upx -t upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe})
upx_add_serial_test(upx-unpack upx -d upx-packed${exe} ${fo} -o upx-unpacked${exe})
upx_add_serial_test(upx-unpack-fa upx -d upx-packed-fa${exe} ${fo} -o upx-unpacked-fa${exe})
upx_add_serial_test(upx-unpack-fn upx -d upx-packed-fn${exe} ${fo} -o upx-unpacked-fn${exe})
upx_add_serial_test(upx-unpack-fr upx -d upx-packed-fr${exe} ${fo} -o upx-unpacked-fr${exe})
upx_add_serial_test(upx-unpack-nrv2b upx -d upx-packed-nrv2b${exe} ${fo} -o upx-unpacked-nrv2b${exe})
upx_add_serial_test(upx-unpack-nrv2d upx -d upx-packed-nrv2d${exe} ${fo} -o upx-unpacked-nrv2d${exe})
upx_add_serial_test(upx-unpack-nrv2e upx -d upx-packed-nrv2e${exe} ${fo} -o upx-unpacked-nrv2e${exe})
upx_add_serial_test(upx-unpack-lzma upx -d upx-packed-lzma${exe} ${fo} -o upx-unpacked-lzma${exe})
# all unpacked files must be identical
upx_add_serial_test(upx-compare-fa "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-fa${exe})
upx_add_serial_test(upx-compare-fn "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-fn${exe})
upx_add_serial_test(upx-compare-fr "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-fr${exe})
upx_add_serial_test(upx-compare-nrv2b "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-nrv2b${exe})
upx_add_serial_test(upx-compare-nrv2d "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-nrv2d${exe})
upx_add_serial_test(upx-compare-nrv2e "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-nrv2e${exe})
upx_add_serial_test(upx-compare-lzma "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-lzma${exe})
if(NOT UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST)
upx_add_serial_test(upx-run-unpacked ${emu} ./upx-unpacked${exe} --version-short)
endif()
if(NOT UPX_CONFIG_DISABLE_RUN_PACKED_TEST)
upx_add_serial_test(upx-run-packed ${emu} ./upx-packed${exe} --version-short)
upx_add_serial_test(upx-run-packed-fa ${emu} ./upx-packed-fa${exe} --version-short)
upx_add_serial_test(upx-run-packed-fn ${emu} ./upx-packed-fn${exe} --version-short)
upx_add_serial_test(upx-run-packed-fr ${emu} ./upx-packed-fr${exe} --version-short)
upx_add_serial_test(upx-run-packed-nrv2b ${emu} ./upx-packed-nrv2b${exe} --version-short)
upx_add_serial_test(upx-run-packed-nrv2d ${emu} ./upx-packed-nrv2d${exe} --version-short)
upx_add_serial_test(upx-run-packed-nrv2e ${emu} ./upx-packed-nrv2e${exe} --version-short)
upx_add_serial_test(upx-run-packed-lzma ${emu} ./upx-packed-lzma${exe} --version-short)
endif()
# TODO later: check if we can somehow run these tests in parallel groups
if(NOT UPX_CONFIG_DISABLE_EXHAUSTIVE_TEST)
foreach(method IN ITEMS nrv2b nrv2d nrv2e lzma)
foreach(level IN ITEMS 1 2 3 4 5 6 7)
set(s "${method}-${level}")
upx_add_serial_test(upx-self-pack-${s} upx --${method} -${level} --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe})
upx_add_serial_test(upx-list-${s} upx -l upx-packed-${s}${exe})
upx_add_serial_test(upx-fileinfo-${s} upx --fileinfo upx-packed-${s}${exe})
upx_add_serial_test(upx-test-${s} upx -t upx-packed-${s}${exe})
upx_add_serial_test(upx-unpack-pack-${s} upx -d upx-packed-${s}${exe} ${fo} -o upx-unpacked-${s}${exe})
upx_add_serial_test(upx-compare-${s} "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-${s}${exe})
if(NOT UPX_CONFIG_DISABLE_RUN_PACKED_TEST)
upx_add_serial_test(upx-run-packed-${s} ${emu} ./upx-packed-${s}${exe} --version-short)
endif()
endforeach()
endforeach()
endif () # UPX_CONFIG_DISABLE_EXHAUSTIVE_TEST
endif() # UPX_CONFIG_DISABLE_SELF_PACK_TEST
endif() # CMAKE_CROSSCOMPILING
endif()
endif() # UPX_CONFIG_CMAKE_DISABLE_TEST

View File

@ -51,19 +51,35 @@ release: build/release PHONY
all build/all: build/debug build/release PHONY
build/%/all: $$(dir $$@)debug $$(dir $$@)release PHONY ;
#***********************************************************************
# test
#***********************************************************************
CTEST_JOBS ?= 8
CTEST = ctest --parallel $(CTEST_JOBS)
build/debug+test: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CTEST)
build/%/debug+test: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CTEST)
build/release+test: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CTEST)
build/%/release+test: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CTEST)
build/%/all+test: $$(dir $$@)debug+test $$(dir $$@)release+test PHONY ;
# shortcuts
debug+test: build/debug+test PHONY
release+test: build/release+test PHONY
all+test build/all+test: build/debug+test build/release+test PHONY
# by default do test debug and release builds
test:: build/all+test PHONY
#
# END of Makefile
#
# extra pre-defined build configurations and some utility; optional
ifneq ($(MAKEFILE_LIST),)
include $(dir $(lastword $(MAKEFILE_LIST)))/misc/make/Makefile-extra.mk
else
include ./misc/make/Makefile-extra.mk
endif
# developer convenience
test:: build/all+test PHONY
ifneq ($(wildcard /usr/bin/env),) # need Unix utils like bash, perl, sed, xargs, etc.
ifneq ($(wildcard ./misc/scripts/.),)
check-whitespace clang-format run-testsuite run-testsuite-all run-testsuite-debug run-testsuite-release: src/Makefile PHONY

View File

@ -362,11 +362,21 @@ endfunction()
# test
#***********************************************************************
function(upx_add_serial_test) # ARGV
function(upx_add_test) # ARGV
set(name "${ARGV0}")
list(REMOVE_AT ARGV 0)
add_test(NAME "${name}" COMMAND ${ARGV})
set_tests_properties("${name}" PROPERTIES RUN_SERIAL TRUE) # run these tests sequentially
endfunction()
function(upx_test_depends) # ARGV
set(name "${ARGV0}")
list(REMOVE_AT ARGV 0)
get_property(prop TEST "${name}" PROPERTY DEPENDS)
if(prop MATCHES "^(NOTFOUND)?$")
set_tests_properties("${name}" PROPERTIES DEPENDS "${ARGV}")
else()
set_tests_properties("${name}" PROPERTIES DEPENDS "${prop};${ARGV}")
endif()
endfunction()
# vim:set ft=cmake ts=4 sw=4 tw=0 et:

View File

@ -0,0 +1,125 @@
#
# UPX "CMake" build file; see https://cmake.org/
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
#
#***********************************************************************
# test section: self-pack tests
#
# IMPORTANT NOTE: these tests can only work if the host executable format
# is supported by UPX!
#***********************************************************************
set(emu "")
if(DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
set(emu "${CMAKE_CROSSCOMPILING_EMULATOR}")
endif()
set(exe "${CMAKE_EXECUTABLE_SUFFIX}")
set(upx_self_exe "$<TARGET_FILE:upx>")
set(fo "--force-overwrite")
upx_add_test(upx-self-pack upx -3 "${upx_self_exe}" ${fo} -o upx-packed${exe})
upx_add_test(upx-self-pack-fa upx -3 --all-filters "${upx_self_exe}" ${fo} -o upx-packed-fa${exe})
upx_add_test(upx-self-pack-fn upx -3 --no-filter "${upx_self_exe}" ${fo} -o upx-packed-fn${exe})
upx_add_test(upx-self-pack-fr upx -3 --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-fr${exe})
upx_add_test(upx-self-pack-nrv2b upx -3 --nrv2b "${upx_self_exe}" ${fo} -o upx-packed-nrv2b${exe})
upx_add_test(upx-self-pack-nrv2d upx -3 --nrv2d "${upx_self_exe}" ${fo} -o upx-packed-nrv2d${exe})
upx_add_test(upx-self-pack-nrv2e upx -3 --nrv2e "${upx_self_exe}" ${fo} -o upx-packed-nrv2e${exe})
upx_add_test(upx-self-pack-lzma upx -1 --lzma "${upx_self_exe}" ${fo} -o upx-packed-lzma${exe})
upx_add_test(upx-list upx -l upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe})
upx_add_test(upx-fileinfo upx --fileinfo upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe})
upx_add_test(upx-test upx -t upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe})
upx_add_test(upx-unpack upx -d upx-packed${exe} ${fo} -o upx-unpacked${exe})
upx_add_test(upx-unpack-fa upx -d upx-packed-fa${exe} ${fo} -o upx-unpacked-fa${exe})
upx_add_test(upx-unpack-fn upx -d upx-packed-fn${exe} ${fo} -o upx-unpacked-fn${exe})
upx_add_test(upx-unpack-fr upx -d upx-packed-fr${exe} ${fo} -o upx-unpacked-fr${exe})
upx_add_test(upx-unpack-nrv2b upx -d upx-packed-nrv2b${exe} ${fo} -o upx-unpacked-nrv2b${exe})
upx_add_test(upx-unpack-nrv2d upx -d upx-packed-nrv2d${exe} ${fo} -o upx-unpacked-nrv2d${exe})
upx_add_test(upx-unpack-nrv2e upx -d upx-packed-nrv2e${exe} ${fo} -o upx-unpacked-nrv2e${exe})
upx_add_test(upx-unpack-lzma upx -d upx-packed-lzma${exe} ${fo} -o upx-unpacked-lzma${exe})
# all unpacked files must be identical!
upx_add_test(upx-compare-fa "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-fa${exe})
upx_add_test(upx-compare-fn "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-fn${exe})
upx_add_test(upx-compare-fr "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-fr${exe})
upx_add_test(upx-compare-nrv2b "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-nrv2b${exe})
upx_add_test(upx-compare-nrv2d "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-nrv2d${exe})
upx_add_test(upx-compare-nrv2e "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-nrv2e${exe})
upx_add_test(upx-compare-lzma "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-lzma${exe})
# test dependencies
upx_test_depends(upx-list "upx-self-pack;upx-self-pack-fa;upx-self-pack-fn;upx-self-pack-fr;upx-self-pack-nrv2b;upx-self-pack-nrv2d;upx-self-pack-nrv2e;upx-self-pack-lzma")
upx_test_depends(upx-fileinfo "upx-self-pack;upx-self-pack-fa;upx-self-pack-fn;upx-self-pack-fr;upx-self-pack-nrv2b;upx-self-pack-nrv2d;upx-self-pack-nrv2e;upx-self-pack-lzma")
upx_test_depends(upx-test "upx-self-pack;upx-self-pack-fa;upx-self-pack-fn;upx-self-pack-fr;upx-self-pack-nrv2b;upx-self-pack-nrv2d;upx-self-pack-nrv2e;upx-self-pack-lzma")
upx_test_depends(upx-unpack upx-self-pack)
upx_test_depends(upx-unpack-fa upx-self-pack-fa)
upx_test_depends(upx-unpack-fn upx-self-pack-fn)
upx_test_depends(upx-unpack-fr upx-self-pack-fr)
upx_test_depends(upx-unpack-nrv2b upx-self-pack-nrv2b)
upx_test_depends(upx-unpack-nrv2d upx-self-pack-nrv2d)
upx_test_depends(upx-unpack-nrv2e upx-self-pack-nrv2e)
upx_test_depends(upx-unpack-lzma upx-self-pack-lzma)
upx_test_depends(upx-compare-fa "upx-unpack;upx-unpack-fa")
upx_test_depends(upx-compare-fn "upx-unpack;upx-unpack-fn")
upx_test_depends(upx-compare-fr "upx-unpack;upx-unpack-fr")
upx_test_depends(upx-compare-nrv2b "upx-unpack;upx-unpack-nrv2b")
upx_test_depends(upx-compare-nrv2d "upx-unpack;upx-unpack-nrv2d")
upx_test_depends(upx-compare-nrv2e "upx-unpack;upx-unpack-nrv2e")
upx_test_depends(upx-compare-lzma "upx-unpack;upx-unpack-lzma")
if(NOT UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST)
upx_add_test(upx-run-unpacked ${emu} ./upx-unpacked${exe} --version-short)
upx_test_depends(upx-run-unpacked upx-unpack)
endif()
if(NOT UPX_CONFIG_DISABLE_RUN_PACKED_TEST)
upx_add_test(upx-run-packed ${emu} ./upx-packed${exe} --version-short)
upx_add_test(upx-run-packed-fa ${emu} ./upx-packed-fa${exe} --version-short)
upx_add_test(upx-run-packed-fn ${emu} ./upx-packed-fn${exe} --version-short)
upx_add_test(upx-run-packed-fr ${emu} ./upx-packed-fr${exe} --version-short)
upx_add_test(upx-run-packed-nrv2b ${emu} ./upx-packed-nrv2b${exe} --version-short)
upx_add_test(upx-run-packed-nrv2d ${emu} ./upx-packed-nrv2d${exe} --version-short)
upx_add_test(upx-run-packed-nrv2e ${emu} ./upx-packed-nrv2e${exe} --version-short)
upx_add_test(upx-run-packed-lzma ${emu} ./upx-packed-lzma${exe} --version-short)
upx_test_depends(upx-run-packed upx-self-pack)
upx_test_depends(upx-run-packed-fa upx-self-pack-fa)
upx_test_depends(upx-run-packed-fn upx-self-pack-fn)
upx_test_depends(upx-run-packed-fr upx-self-pack-fr)
upx_test_depends(upx-run-packed-nrv2b upx-self-pack-nrv2b)
upx_test_depends(upx-run-packed-nrv2d upx-self-pack-nrv2d)
upx_test_depends(upx-run-packed-nrv2e upx-self-pack-nrv2e)
upx_test_depends(upx-run-packed-lzma upx-self-pack-lzma)
endif()
if(NOT UPX_CONFIG_DISABLE_EXHAUSTIVE_TEST)
foreach(method IN ITEMS nrv2b nrv2d nrv2e lzma)
foreach(level IN ITEMS 1 2 3 4 5 6 7)
set(s "${method}-${level}")
upx_add_test(upx-self-pack-${s} upx --${method} -${level} --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe})
upx_add_test(upx-list-${s} upx -l upx-packed-${s}${exe})
upx_add_test(upx-fileinfo-${s} upx --fileinfo upx-packed-${s}${exe})
upx_add_test(upx-test-${s} upx -t upx-packed-${s}${exe})
upx_add_test(upx-unpack-${s} upx -d upx-packed-${s}${exe} ${fo} -o upx-unpacked-${s}${exe})
upx_add_test(upx-compare-${s} "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-${s}${exe})
upx_test_depends(upx-list-${s} upx-self-pack-${s})
upx_test_depends(upx-fileinfo-${s} upx-self-pack-${s})
upx_test_depends(upx-test-${s} upx-self-pack-${s})
upx_test_depends(upx-unpack-${s} upx-self-pack-${s})
upx_test_depends(upx-compare-${s} "upx-unpack;upx-unpack-${s}")
if(NOT UPX_CONFIG_DISABLE_RUN_PACKED_TEST)
upx_add_test(upx-run-packed-${s} ${emu} ./upx-packed-${s}${exe} --version-short)
upx_test_depends(upx-run-packed-${s} upx-self-pack-${s})
endif()
endforeach()
endforeach()
endif () # UPX_CONFIG_DISABLE_EXHAUSTIVE_TEST
# clean up
set(emu "")
set(exe "")
set(upx_self_exe "")
set(fo "")
# vim:set ft=cmake ts=4 sw=4 tw=0 et:

View File

@ -11,23 +11,6 @@ override check_undefined = $(foreach 1,$1,$(if $(filter undefined,$(origin $1)),
$(call check_defined,run_config run_build)
$(call check_undefined,run_config_and_build)
#***********************************************************************
# build and test
#***********************************************************************
CTEST = ctest
build/debug+test: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CTEST)
build/%/debug+test: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CTEST)
build/release+test: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CTEST)
build/%/release+test: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CTEST)
build/%/all+test: $$(dir $$@)debug+test $$(dir $$@)release+test PHONY ;
# shortcuts
debug+test: build/debug+test PHONY
release+test: build/release+test PHONY
all+test build/all+test: build/debug+test build/release+test PHONY
#***********************************************************************
# extra builds: some pre-defined build configurations
#***********************************************************************

View File

@ -0,0 +1,34 @@
#! /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")"
# rebuild stubs from source code
# using a rootless Podman container
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
image="$("$argv0dir/10-create-image.sh" --print-image)"
flags=( --read-only --rm --pull=never )
flags+=( --cap-drop=all ) # drop all capabilities
flags+=( --network=none ) # no network needed
if [[ 1 == 1 ]]; then
# run as user upx 2000:2000
flags+=( --user 2000 )
# map container users 0..999 to subuid-users 1..1000, and map container user 2000 to current host user
flags+=( --uidmap=0:1:1000 --uidmap=2000:0:1 )
# map container groups 0..999 to subgid-groups 1..1000, and map container group 2000 to current host group
flags+=( --gidmap=0:1:1000 --gidmap=2000:0:1 )
# NOTE: we mount the upx top-level directory read-write under /home/upx/src/upx
# INFO: SELinux users *may* have to add ":z" to the volume mount flags; check the docs!
flags+=( -v "${argv0dir}/../../..:/home/upx/src/upx" )
fi
podman run "${flags[@]}" "$image" bash -c $'
set -ex; set -o pipefail
cd /home/upx/src/upx/src/stub
make maintainer-clean extra-clean
make extra-all all
echo "===== Rebuilt stubs. All done. ====="
exit 0
'

View File

@ -93,7 +93,7 @@ fo="--force-overwrite"
"${run_upx[@]}" -3 "${upx_self_exe}" ${fo} -o upx-packed${exe}
"${run_upx[@]}" -3 --all-filters "${upx_self_exe}" ${fo} -o upx-packed-fa${exe}
"${run_upx[@]}" -3 --no-filter "${upx_self_exe}" ${fo} -o upx-packed-fn${exe}
"${run_upx[@]}" -3 --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-fr${exe}
"${run_upx[@]}" -3 --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-fr${exe}
"${run_upx[@]}" -3 --nrv2b "${upx_self_exe}" ${fo} -o upx-packed-nrv2b${exe}
"${run_upx[@]}" -3 --nrv2d "${upx_self_exe}" ${fo} -o upx-packed-nrv2d${exe}
"${run_upx[@]}" -3 --nrv2e "${upx_self_exe}" ${fo} -o upx-packed-nrv2e${exe}
@ -142,7 +142,7 @@ if [[ $UPX_CONFIG_DISABLE_EXHAUSTIVE_TEST == OFF ]]; then
for level in 1 2 3 4 5 6 7; do
s="${method}-${level}"
echo "========== $s =========="
"${run_upx[@]}" -qq --${method} -${level} --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe}
"${run_upx[@]}" -qq --${method} -${level} --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe}
"${run_upx[@]}" -qq -l upx-packed-${s}${exe}
"${run_upx[@]}" -qq --fileinfo upx-packed-${s}${exe}
"${run_upx[@]}" -qq -t upx-packed-${s}${exe}

View File

@ -1031,14 +1031,16 @@ void Packer::compressWithFilters(byte *i_ptr,
assert(orig_ft.id == 0);
// prepare methods and filters
int methods[256];
constexpr int MAX_METHODS = 8;
constexpr int MAX_FILTERS = 16;
int methods[MAX_METHODS];
int nmethods = prepareMethods(methods, ph.method, getCompressionMethods(M_ALL, ph.level));
assert(nmethods > 0);
assert(nmethods < 256);
int filters[256];
assert(nmethods < MAX_METHODS);
int filters[MAX_FILTERS];
int nfilters = prepareFilters(filters, filter_strategy, getFilters());
assert(nfilters > 0);
assert(nfilters < 256);
assert(nfilters < MAX_FILTERS);
#if 0
printf("compressWithFilters: m(%d):", nmethods);
for (int i = 0; i < nmethods; i++)

View File

@ -3,7 +3,7 @@
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
#
# NOTE: see misc/podman/rebuild-stubs/20-image-run-shell.sh
# NOTE: see misc/podman/rebuild-stubs/30-rebuild-stubs.sh
# how to rebuild the UPX stubs from source code
MAKEFLAGS += -rR

View File

@ -264,6 +264,7 @@ int upx_rand(void) noexcept { return ::rand(); }
void upx_rand_init(void) noexcept {
unsigned seed = 0;
seed ^= UPX_VERSION_HEX;
#if (!HAVE_GETTIMEOFDAY || (ACC_OS_DOS32 && defined(__DJGPP__))) && !defined(__wasi__)
seed ^= (unsigned) time(nullptr);
seed ^= ((unsigned) clock()) << 12;