misc: improve upx_testsuite; cmake update
This commit is contained in:
parent
672d69c68a
commit
b866631448
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@ -12,8 +12,8 @@ env:
|
||||
CMAKE_REQUIRED_QUIET: OFF
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
UPX_CMAKE_BUILD_FLAGS: --verbose
|
||||
# 2023-07-15
|
||||
ZIG_DIST_VERSION: 0.11.0-dev.4002+7dd1cf26f
|
||||
# 2023-07-19
|
||||
ZIG_DIST_VERSION: 0.11.0-dev.4009+11695745e
|
||||
|
||||
jobs:
|
||||
job-rebuild-and-verify-stubs:
|
||||
@ -66,7 +66,7 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- { os: ubuntu-22.04, use_m32: true }
|
||||
- { os: ubuntu-20.04, use_m32: false }
|
||||
- { os: ubuntu-20.04, use_m32: false } # use_m32 also works here, but save some CI time
|
||||
steps:
|
||||
- name: 'Install extra 32-bit and Windows packages'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
@ -152,8 +152,8 @@ jobs:
|
||||
# testsuite needs working "readlink -en" and "sha256sum"
|
||||
if ! test -e /usr/local/opt/coreutils/libexec/gnubin/readlink; then
|
||||
echo "===== brew leaves:"; brew leaves; echo "===== brew list:"; brew list
|
||||
brew update
|
||||
brew install coreutils
|
||||
# only run "brew update" if needed
|
||||
if ! brew install coreutils; then brew update && brew install coreutils; fi
|
||||
fi
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v3
|
||||
|
||||
4
.github/workflows/weekly-ci-zigcc.yml
vendored
4
.github/workflows/weekly-ci-zigcc.yml
vendored
@ -8,8 +8,8 @@ on:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: OFF
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
# 2023-07-15
|
||||
ZIG_DIST_VERSION: 0.11.0-dev.4002+7dd1cf26f
|
||||
# 2023-07-19
|
||||
ZIG_DIST_VERSION: 0.11.0-dev.4009+11695745e
|
||||
|
||||
jobs:
|
||||
job-linux-zigcc: # uses cmake + make
|
||||
|
||||
@ -40,7 +40,7 @@ option(UPX_CONFIG_DISABLE_SELF_PACK_TEST "Do not test packing UPX with itself" O
|
||||
|
||||
# Disallow in-source builds. Note that you will still have to manually
|
||||
# clean up a few files if you accidentally try an in-source build.
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git" AND NOT MSVC_IDE)
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
||||
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
||||
if(",${CMAKE_CURRENT_SOURCE_DIR}," STREQUAL ",${CMAKE_CURRENT_BINARY_DIR},")
|
||||
@ -49,7 +49,8 @@ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git" AND NOT MSVC_IDE)
|
||||
endif()
|
||||
|
||||
# useful for CI jobs: allow settings via environment and cache result
|
||||
function(upx_cache_bool_vars default_value)
|
||||
function(upx_cache_bool_vars)
|
||||
set(default_value "${ARGV0}")
|
||||
list(REMOVE_AT ARGV 0)
|
||||
foreach(var ${ARGV})
|
||||
set(value ${default_value})
|
||||
@ -185,15 +186,36 @@ else()
|
||||
set(warn_WX -WX)
|
||||
endif()
|
||||
|
||||
function(upx_add_definitions)
|
||||
foreach(flag ${ARGV})
|
||||
function(upx_add_definitions_with_prefix)
|
||||
set(flag_prefix "${ARGV0}")
|
||||
if(flag_prefix MATCHES "^dummy$") # need dummy to work around bug in old CMake versions
|
||||
set(flag_prefix "")
|
||||
endif()
|
||||
list(REMOVE_AT ARGV 0)
|
||||
set(failed "")
|
||||
foreach(f ${ARGV})
|
||||
set(flag "${flag_prefix}${f}")
|
||||
string(REGEX REPLACE "[^0-9a-zA-Z_]" "_" cache_var "HAVE_CFLAG_${flag}")
|
||||
check_c_compiler_flag("${flag}" ${cache_var})
|
||||
if(${cache_var})
|
||||
#message(STATUS "add_definitions: ${flag}")
|
||||
add_definitions("${flag}")
|
||||
else()
|
||||
list(APPEND failed "${f}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(failed_flags "${failed}" PARENT_SCOPE) # return value
|
||||
endfunction()
|
||||
|
||||
function(upx_add_definitions)
|
||||
set(failed_flags "")
|
||||
if(MSVC_FRONTEND AND CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# for clang-cl try "-clang:" flag prefix first
|
||||
upx_add_definitions_with_prefix("-clang:" ${ARGV})
|
||||
upx_add_definitions_with_prefix("dummy" ${failed_flags})
|
||||
else()
|
||||
upx_add_definitions_with_prefix("dummy" ${ARGV})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(NOT CMAKE_C_COMPILER_ID MATCHES "^MSVC")
|
||||
@ -417,7 +439,8 @@ if(NOT CMAKE_CROSSCOMPILING)
|
||||
endif()
|
||||
if(NOT CMAKE_CROSSCOMPILING AND NOT UPX_CONFIG_DISABLE_SELF_PACK_TEST)
|
||||
# IMPORTANT NOTE: these tests can only work if the host executable format is supported by UPX!
|
||||
function(upx_add_test name)
|
||||
function(upx_add_test)
|
||||
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
|
||||
@ -489,6 +512,7 @@ print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION)
|
||||
print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_CROSSCOMPILING)
|
||||
print_var(CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION CMAKE_C_COMPILER_FRONTEND_VARIANT CMAKE_C_COMPILER_ARCHITECTURE_ID CMAKE_C_PLATFORM_ID CMAKE_C_COMPILER_ABI)
|
||||
print_var(CMAKE_CXX_COMPILER_ID CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_COMPILER_FRONTEND_VARIANT CMAKE_CXX_COMPILER_ARCHITECTURE_ID CMAKE_CXX_PLATFORM_ID CMAKE_CXX_COMPILER_ABI)
|
||||
print_var(CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
print_var(CYGWIN GNUC MINGW MSVC MSVC_FRONTEND MSVC_IDE WIN32 WIN64)
|
||||
endif() # UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO
|
||||
print_var(CMAKE_INSTALL_PREFIX CMAKE_CONFIGURATION_TYPES CMAKE_BUILD_TYPE)
|
||||
|
||||
12
Makefile
12
Makefile
@ -87,6 +87,12 @@ build/extra/clang-m64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-m64/%: export CC = clang -m64
|
||||
build/extra/clang-m64/%: export CXX = clang++ -m64
|
||||
|
||||
# force building with clang/clang++ -static
|
||||
build/extra/clang-static/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-static/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-static/%: export CC = clang -static
|
||||
build/extra/clang-static/%: export CXX = clang++ -static
|
||||
|
||||
# force building with gcc/g++
|
||||
build/extra/gcc/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
@ -111,6 +117,12 @@ build/extra/gcc-m64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-m64/%: export CC = gcc -m64
|
||||
build/extra/gcc-m64/%: export CXX = g++ -m64
|
||||
|
||||
# force building with gcc/g++ -static
|
||||
build/extra/gcc-static/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-static/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-static/%: export CC = gcc -static
|
||||
build/extra/gcc-static/%: export CXX = g++ -static
|
||||
|
||||
# force building with clang Static Analyzer (scan-build)
|
||||
build/extra/scan-build/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/scan-build/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
|
||||
@ -32,7 +32,11 @@ else
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# now we can cross-compile UPX for Windows:
|
||||
# cd /home/upx/src/upx
|
||||
|
||||
@ -32,7 +32,11 @@ else
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# now we can rebuild the UPX stubs:
|
||||
# cd /home/upx/src/upx/src/stub
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
test-qemu-with-podman
|
||||
=====================
|
||||
|
||||
This directory provides scripts for creating and running rather small Alpine Linux container
|
||||
images, intended for testing statically-linked Linux executables with qemu-user.
|
||||
This directory provides some simple scripts for creating and running
|
||||
quite small Alpine Linux container images, intended for testing
|
||||
statically-linked Linux executables with Podman and qemu-user.
|
||||
|
||||
Very short usage instructions follow.
|
||||
|
||||
@ -39,7 +40,7 @@ Very short usage instructions follow.
|
||||
```sh
|
||||
cd /home/upx/src/upx/tmp
|
||||
|
||||
# check that the official binaries do work
|
||||
# check that the official UPX release binaries do work
|
||||
qemu-i386 ./upx-4.0.2-i386_linux/upx --version
|
||||
qemu-mips ./upx-4.0.2-mips_linux/upx --version
|
||||
# ...same for more architectures
|
||||
|
||||
@ -32,6 +32,10 @@ else
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# please see usage instructions in ../README.md
|
||||
|
||||
@ -32,6 +32,10 @@ else
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# please see usage instructions in ../README.md
|
||||
|
||||
@ -32,6 +32,10 @@ else
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# please see usage instructions in ../README.md
|
||||
|
||||
@ -32,6 +32,10 @@ else
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# please see usage instructions in ../README.md
|
||||
|
||||
@ -32,6 +32,10 @@ else
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# please see usage instructions in ../README.md
|
||||
|
||||
@ -32,6 +32,10 @@ else
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# please see usage instructions in ../README.md
|
||||
|
||||
@ -32,6 +32,10 @@ else
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# please see usage instructions in ../README.md
|
||||
|
||||
180
misc/testsuite/upx_testsuite_1.sh
Normal file → Executable file
180
misc/testsuite/upx_testsuite_1.sh
Normal file → Executable file
@ -1,37 +1,99 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs=$(readlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
|
||||
argv0=$0; argv0abs=$(readlink -en -- "$argv0"); argv0dir=$(dirname "$argv0abs")
|
||||
|
||||
# very first version of the upx-testsuite; requires:
|
||||
# $upx_exe
|
||||
# $upx_testsuite_SRCDIR
|
||||
# $upx_testsuite_SRCDIR (semi-optional)
|
||||
# $upx_testsuite_BUILDDIR (optional)
|
||||
# $BM_T (optional)
|
||||
# $upx_testsuite_verbose (optional)
|
||||
#
|
||||
# see https://github.com/upx/upx-testsuite.git
|
||||
|
||||
# convenience
|
||||
[[ -z $upx_testsuite_BUILDDIR ]] && upx_testsuite_BUILDDIR=./tmp-upx-testsuite
|
||||
[[ -f $upx_exe ]] && upx_exe=$(readlink -en -- "$upx_exe")
|
||||
# /***********************************************************************
|
||||
# // init & checks
|
||||
# ************************************************************************/
|
||||
|
||||
# make dirs absolute
|
||||
upx_testsuite_SRCDIR=$(readlink -en -- "$upx_testsuite_SRCDIR")
|
||||
if [[ -z $upx_exe ]]; then echo "UPX-ERROR: please set \$upx_exe"; exit 1; fi
|
||||
# convenience: try to make filename absolute
|
||||
[[ -f "$upx_exe" ]] && upx_exe=$(readlink -en -- "$upx_exe")
|
||||
# upx_exe check, part1
|
||||
if ! $upx_exe --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
|
||||
if ! $upx_exe -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
|
||||
if ! $upx_exe --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
|
||||
|
||||
# upx_testsuite_SRCDIR
|
||||
if [[ -z $upx_testsuite_SRCDIR ]]; then
|
||||
# convenience: search standard locations below upx top-level directory
|
||||
if [[ -d "$argv0dir/../../../upx--upx-testsuite.git/files/packed" ]]; then
|
||||
upx_testsuite_SRCDIR="$argv0dir/../../../upx--upx-testsuite.git"
|
||||
elif [[ -d "$argv0dir/../../../upx-testsuite.git/files/packed" ]]; then
|
||||
upx_testsuite_SRCDIR="$argv0dir/../../../upx-testsuite.git"
|
||||
elif [[ -d "$argv0dir/../../../upx-testsuite/files/packed" ]]; then
|
||||
upx_testsuite_SRCDIR="$argv0dir/../../../upx-testsuite"
|
||||
fi
|
||||
fi
|
||||
if [[ ! -d "$upx_testsuite_SRCDIR/files/packed" ]]; then
|
||||
echo 'invalid or missing $upx_testsuite_SRCDIR:'
|
||||
echo ' please git clone https://github.com/upx/upx-testsuite.git'
|
||||
echo ' and set (export) the envvar upx_testsuite_SRCDIR to the local file path'
|
||||
echo "invalid or missing \$upx_testsuite_SRCDIR:"
|
||||
echo " please git clone https://github.com/upx/upx-testsuite.git"
|
||||
echo " and set (export) the envvar upx_testsuite_SRCDIR to the local file path"
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$upx_testsuite_BUILDDIR"
|
||||
upx_testsuite_SRCDIR=$(readlink -en -- "$upx_testsuite_SRCDIR")
|
||||
|
||||
# upx_testsuite_BUILDDIR
|
||||
if [[ -z $upx_testsuite_BUILDDIR ]]; then
|
||||
upx_testsuite_BUILDDIR="./tmp-upx-testsuite"
|
||||
fi
|
||||
mkdir -p "$upx_testsuite_BUILDDIR" || exit 1
|
||||
upx_testsuite_BUILDDIR=$(readlink -en -- "$upx_testsuite_BUILDDIR")
|
||||
|
||||
cd / && cd "$upx_testsuite_BUILDDIR" || exit 1
|
||||
|
||||
# upx_exe check, part2
|
||||
if ! $upx_exe --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"
|
||||
exit 1
|
||||
fi
|
||||
if ! $upx_exe -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
|
||||
if ! $upx_exe --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
|
||||
|
||||
# /***********************************************************************
|
||||
# // setup
|
||||
# ************************************************************************/
|
||||
|
||||
#set -x # debug
|
||||
exit_code=0
|
||||
num_errors=0
|
||||
all_errors=
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
|
||||
export UPX_DEBUG_DOCTEST_VERBOSE=0
|
||||
|
||||
rm -rf ./testsuite_1
|
||||
mkdir testsuite_1 || exit 1
|
||||
cd testsuite_1 || exit 1
|
||||
|
||||
# /***********************************************************************
|
||||
# // support functions
|
||||
# ************************************************************************/
|
||||
|
||||
run_upx() {
|
||||
local ec=0
|
||||
if [[ $upx_testsuite_verbose == 1 ]]; then
|
||||
echo "LOG: $upx_exe $@"
|
||||
fi
|
||||
$upx_exe "$@" || ec=$?
|
||||
if [[ $ec != 0 ]]; then
|
||||
echo "FATAL: $upx_exe $@"
|
||||
echo " (exit code was $ec)"
|
||||
exit 42
|
||||
fi
|
||||
}
|
||||
|
||||
testsuite_header() {
|
||||
local x='==========='; x="$x$x$x$x$x$x$x"
|
||||
echo -e "\n${x}\n${1}\n${x}\n"
|
||||
@ -43,7 +105,7 @@ testsuite_split_f() {
|
||||
fsubdir=$(basename "$fd")
|
||||
# sanity checks
|
||||
if [[ ! -f $1 || -z $fsubdir || -z $fb ]]; then
|
||||
fd= fb= fsubdir=
|
||||
fd=''; fb=''; fsubdir=''
|
||||
fi
|
||||
}
|
||||
|
||||
@ -77,22 +139,22 @@ testsuite_run_compress() {
|
||||
testsuite_header $testdir
|
||||
local files f
|
||||
if [[ $testsuite_use_canonicalized == 1 ]]; then
|
||||
files=t020_canonicalized/*/*
|
||||
files='t020_canonicalized/*/*'
|
||||
else
|
||||
files=t010_decompressed/*/*
|
||||
files='t010_decompressed/*/*'
|
||||
fi
|
||||
for f in $files; do
|
||||
testsuite_split_f $f
|
||||
testsuite_split_f "$f"
|
||||
[[ -z $fb ]] && continue
|
||||
echo "# $f"
|
||||
mkdir -p $testdir/$fsubdir $testdir/.decompressed/$fsubdir
|
||||
$upx_run -qq --prefer-ucl "$@" $f -o $testdir/$fsubdir/$fb
|
||||
$upx_run -qq -d $testdir/$fsubdir/$fb -o $testdir/.decompressed/$fsubdir/$fb
|
||||
run_upx -qq --prefer-ucl "$@" "$f" -o $testdir/$fsubdir/$fb
|
||||
run_upx -qq -d $testdir/$fsubdir/$fb -o $testdir/.decompressed/$fsubdir/$fb
|
||||
done
|
||||
testsuite_check_sha $testdir
|
||||
$upx_run -qq -l $testdir/*/*
|
||||
$upx_run -qq --file-info $testdir/*/*
|
||||
$upx_run -q -t $testdir/*/*
|
||||
run_upx -qq -l $testdir/*/*
|
||||
run_upx -qq --file-info $testdir/*/*
|
||||
run_upx -q -t $testdir/*/*
|
||||
if [[ $testsuite_use_canonicalized == 1 ]]; then
|
||||
# check that after decompression the file matches the canonicalized version
|
||||
cp t020_canonicalized/.sha256sums.expected $testdir/.decompressed/
|
||||
@ -113,7 +175,7 @@ recreate_expected_sha256sums() {
|
||||
local o=$1
|
||||
local files f d
|
||||
echo "########## begin .sha256sums.recreate" > "$o"
|
||||
files=*/.sha256sums.current
|
||||
files='*/.sha256sums.current'
|
||||
for f in $files; do
|
||||
d=$(dirname "$f")
|
||||
echo "expected_sha256sums__${d}="'"\' >> "$o"
|
||||
@ -125,52 +187,6 @@ recreate_expected_sha256sums() {
|
||||
|
||||
source "$argv0dir/upx_testsuite_1-expected_sha256sums.sh" || exit 1
|
||||
|
||||
# /***********************************************************************
|
||||
# // init
|
||||
# ************************************************************************/
|
||||
|
||||
#set -x # debug
|
||||
exit_code=0
|
||||
num_errors=0
|
||||
all_errors=
|
||||
|
||||
if [[ $BM_T =~ (^|\+)ALLOW_FAIL($|\+) ]]; then
|
||||
echo "ALLOW_FAIL"
|
||||
set +e
|
||||
fi
|
||||
|
||||
if [[ -z $upx_exe ]]; then exit 1; fi
|
||||
upx_run=$upx_exe
|
||||
if [[ $BM_T =~ (^|\+)qemu($|\+) && -n $upx_qemu ]]; then
|
||||
upx_run="$upx_qemu $upx_qemu_flags -- $upx_exe"
|
||||
fi
|
||||
if [[ $BM_T =~ (^|\+)wine($|\+) && -n $upx_wine ]]; then
|
||||
upx_run="$upx_wine $upx_wine_flags $upx_exe"
|
||||
fi
|
||||
if [[ $BM_T =~ (^|\+)valgrind($|\+) ]]; then
|
||||
if [[ -z $upx_valgrind ]]; then
|
||||
upx_valgrind="valgrind"
|
||||
fi
|
||||
if [[ -z $upx_valgrind_flags ]]; then
|
||||
#upx_valgrind_flags="--leak-check=full --show-reachable=yes"
|
||||
#upx_valgrind_flags="-q --leak-check=no --error-exitcode=1"
|
||||
upx_valgrind_flags="--leak-check=no --error-exitcode=1"
|
||||
fi
|
||||
upx_run="$upx_valgrind $upx_valgrind_flags $upx_exe"
|
||||
fi
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
|
||||
export UPX_DEBUG_DOCTEST_VERBOSE=0
|
||||
|
||||
# let's go
|
||||
if ! $upx_run --version-short; 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
|
||||
rm -rf ./testsuite_1
|
||||
mkdir testsuite_1
|
||||
cd testsuite_1 || exit 1
|
||||
|
||||
# /***********************************************************************
|
||||
# // decompression tests
|
||||
# ************************************************************************/
|
||||
@ -179,12 +195,12 @@ testdir=t010_decompressed
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
|
||||
testsuite_header $testdir
|
||||
for f in $upx_testsuite_SRCDIR/files/packed/*/upx-3.9[15]*; do
|
||||
testsuite_split_f $f
|
||||
for f in "$upx_testsuite_SRCDIR"/files/packed/*/upx-3.9[15]*; do
|
||||
testsuite_split_f "$f"
|
||||
[[ -z $fb ]] && continue
|
||||
echo "# $f"
|
||||
mkdir -p $testdir/$fsubdir
|
||||
$upx_run -qq -d $f -o $testdir/$fsubdir/$fb
|
||||
run_upx -qq -d "$f" -o $testdir/$fsubdir/$fb
|
||||
done
|
||||
testsuite_check_sha $testdir
|
||||
|
||||
@ -194,12 +210,12 @@ mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha2
|
||||
|
||||
testsuite_header $testdir
|
||||
for f in t010_decompressed/*/*; do
|
||||
testsuite_split_f $f
|
||||
testsuite_split_f "$f"
|
||||
[[ -z $fb ]] && continue
|
||||
echo "# $f"
|
||||
mkdir -p $testdir/$fsubdir/.packed
|
||||
$upx_run -qq --prefer-ucl -1 $f -o $testdir/$fsubdir/.packed/$fb
|
||||
$upx_run -qq -d $testdir/$fsubdir/.packed/$fb -o $testdir/$fsubdir/$fb
|
||||
run_upx -qq --prefer-ucl -1 "$f" -o $testdir/$fsubdir/.packed/$fb
|
||||
run_upx -qq -d $testdir/$fsubdir/.packed/$fb -o $testdir/$fsubdir/$fb
|
||||
done
|
||||
testsuite_check_sha $testdir
|
||||
|
||||
@ -264,24 +280,18 @@ fi
|
||||
recreate_expected_sha256sums .sha256sums.recreate
|
||||
|
||||
testsuite_header "UPX testsuite summary"
|
||||
if ! $upx_run --version-short; then
|
||||
echo "UPX-ERROR: upx --version-short FAILED"
|
||||
exit 1
|
||||
fi
|
||||
run_upx --version-short
|
||||
echo
|
||||
echo "upx_exe='$upx_exe'"
|
||||
if [[ $upx_run != "$upx_exe" ]]; then
|
||||
echo "upx_run='$upx_run'"
|
||||
fi
|
||||
if [[ -f $upx_exe ]]; then
|
||||
if [[ -f "$upx_exe" ]]; then
|
||||
ls -l "$upx_exe"
|
||||
file "$upx_exe" || true
|
||||
fi
|
||||
echo "upx_testsuite_SRCDIR='$upx_testsuite_SRCDIR'"
|
||||
echo "upx_testsuite_BUILDDIR='$upx_testsuite_BUILDDIR'"
|
||||
echo ".sha256sums.{expected,current}:"
|
||||
cat */.sha256sums.expected | LC_ALL=C sort | wc
|
||||
cat */.sha256sums.current | LC_ALL=C sort | wc
|
||||
echo ".sha256sums.{expected,current} counts:"
|
||||
cat ./*/.sha256sums.expected | LC_ALL=C sort | wc
|
||||
cat ./*/.sha256sums.current | LC_ALL=C sort | wc
|
||||
echo
|
||||
if [[ $exit_code == 0 ]]; then
|
||||
echo "UPX testsuite passed. All done."
|
||||
|
||||
@ -241,6 +241,7 @@ void PackW32PeI386::addNewRelocations(Reloc &rel, unsigned base) {
|
||||
void PackW32PeI386::setOhDataBase(const pe_section_t *osection) { oh.database = osection[2].vaddr; }
|
||||
|
||||
void PackW32PeI386::setOhHeaderSize(const pe_section_t *osection) {
|
||||
// SizeOfHeaders
|
||||
oh.headersize = ALIGN_UP(pe_offset + sizeof(oh) + sizeof(*osection) * oh.objects, oh.filealign);
|
||||
}
|
||||
|
||||
|
||||
@ -231,6 +231,7 @@ void PackW64PeAmd64::defineSymbols(unsigned ncsection, unsigned upxsection, unsi
|
||||
}
|
||||
|
||||
void PackW64PeAmd64::setOhHeaderSize(const pe_section_t *osection) {
|
||||
// SizeOfHeaders
|
||||
oh.headersize = ALIGN_UP(pe_offset + sizeof(oh) + sizeof(*osection) * oh.objects, oh.filealign);
|
||||
}
|
||||
|
||||
|
||||
@ -92,6 +92,7 @@ void PackW64PeArm64::defineSymbols(unsigned ncsection, unsigned upxsection, unsi
|
||||
}
|
||||
|
||||
void PackW64PeArm64::setOhHeaderSize(const pe_section_t *osection) {
|
||||
// SizeOfHeaders
|
||||
UNUSED(osection);
|
||||
throwCantPack("not yet implemented");
|
||||
}
|
||||
|
||||
@ -217,6 +217,7 @@ void PackWinCeArm::defineSymbols(unsigned ncsection, unsigned, unsigned, unsigne
|
||||
void PackWinCeArm::setOhDataBase(const pe_section_t *osection) { oh.database = osection[2].vaddr; }
|
||||
|
||||
void PackWinCeArm::setOhHeaderSize(const pe_section_t *osection) {
|
||||
// SizeOfHeaders
|
||||
oh.headersize = osection[1].rawdataptr;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user