all: improve tests

This commit is contained in:
Markus F.X.J. Oberhumer
2024-04-16 15:20:56 +02:00
parent 35c6a200ad
commit 1d2b276425
11 changed files with 249 additions and 216 deletions
+46 -38
View File
@@ -25,24 +25,24 @@ 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=()
# set emu and run_upx
emu=()
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
IFS=' ' read -r -a emu <<< "$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
IFS=';' read -r -a emu <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array
fi
upx_runner=( "${upx_run[@]}" )
upx_run+=( "$upx_exe" )
echo "upx_run='${upx_run[*]}'"
run_upx=( "${emu[@]}" "$upx_exe" )
echo "run_upx='${run_upx[*]}'"
# 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
# run_upx sanity check
if ! "${run_upx[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
if ! "${run_upx[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
#***********************************************************************
# see CMakeLists.txt
@@ -65,11 +65,11 @@ set_on_off UPX_CONFIG_DISABLE_RUN_PACKED_TEST
export UPX="--no-color --no-progress"
"${upx_run[@]}" --version
"${upx_run[@]}" --version-short
"${upx_run[@]}" --help
"${upx_run[@]}" --license
"${upx_run[@]}" --sysinfo -v
"${run_upx[@]}" --version
"${run_upx[@]}" --version-short
"${run_upx[@]}" --help
"${run_upx[@]}" --license
"${run_upx[@]}" --sysinfo -v
if [[ $UPX_CONFIG_DISABLE_SELF_PACK_TEST == ON ]]; then
echo "Self-pack test disabled. All done."; exit 0
@@ -79,36 +79,44 @@ exe=".out"
upx_self_exe=$upx_exe
fo="--force-overwrite"
"${upx_run[@]}" -3 --all-filters "${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}
"${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 --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}
"${run_upx[@]}" -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}
"${run_upx[@]}" -l upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe}
"${run_upx[@]}" --fileinfo upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe}
"${run_upx[@]}" -t upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe}
"${upx_run[@]}" -d upx-packed${exe} ${fo} -o upx-unpacked${exe}
"${upx_run[@]}" -d upx-packed-n2b${exe} ${fo} -o upx-unpacked-n2b${exe}
"${upx_run[@]}" -d upx-packed-n2d${exe} ${fo} -o upx-unpacked-n2d${exe}
"${upx_run[@]}" -d upx-packed-n2e${exe} ${fo} -o upx-unpacked-n2e${exe}
"${upx_run[@]}" -d upx-packed-lzma${exe} ${fo} -o upx-unpacked-lzma${exe}
"${run_upx[@]}" -d upx-packed${exe} ${fo} -o upx-unpacked${exe}
"${run_upx[@]}" -d upx-packed-fa${exe} ${fo} -o upx-unpacked-fa${exe}
"${run_upx[@]}" -d upx-packed-fn${exe} ${fo} -o upx-unpacked-fn${exe}
"${run_upx[@]}" -d upx-packed-nrv2b${exe} ${fo} -o upx-unpacked-nrv2b${exe}
"${run_upx[@]}" -d upx-packed-nrv2d${exe} ${fo} -o upx-unpacked-nrv2d${exe}
"${run_upx[@]}" -d upx-packed-nrv2e${exe} ${fo} -o upx-unpacked-nrv2e${exe}
"${run_upx[@]}" -d upx-packed-lzma${exe} ${fo} -o upx-unpacked-lzma${exe}
if [[ $UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST == OFF ]]; then
"${upx_runner[@]}" ./upx-unpacked${exe} --version-short
"${upx_runner[@]}" ./upx-unpacked-n2b${exe} --version-short
"${upx_runner[@]}" ./upx-unpacked-n2d${exe} --version-short
"${upx_runner[@]}" ./upx-unpacked-n2e${exe} --version-short
"${upx_runner[@]}" ./upx-unpacked-lzma${exe} --version-short
"${emu[@]}" ./upx-unpacked${exe} --version-short
"${emu[@]}" ./upx-unpacked-fa${exe} --version-short
"${emu[@]}" ./upx-unpacked-fn${exe} --version-short
"${emu[@]}" ./upx-unpacked-nrv2b${exe} --version-short
"${emu[@]}" ./upx-unpacked-nrv2d${exe} --version-short
"${emu[@]}" ./upx-unpacked-nrv2e${exe} --version-short
"${emu[@]}" ./upx-unpacked-lzma${exe} --version-short
fi
if [[ $UPX_CONFIG_DISABLE_RUN_PACKED_TEST == OFF ]]; then
"${upx_runner[@]}" ./upx-packed${exe} --version-short
"${upx_runner[@]}" ./upx-packed-n2b${exe} --version-short
"${upx_runner[@]}" ./upx-packed-n2d${exe} --version-short
"${upx_runner[@]}" ./upx-packed-n2e${exe} --version-short
"${upx_runner[@]}" ./upx-packed-lzma${exe} --version-short
"${emu[@]}" ./upx-packed${exe} --version-short
"${emu[@]}" ./upx-packed-fa${exe} --version-short
"${emu[@]}" ./upx-packed-fn${exe} --version-short
"${emu[@]}" ./upx-packed-nrv2b${exe} --version-short
"${emu[@]}" ./upx-packed-nrv2d${exe} --version-short
"${emu[@]}" ./upx-packed-nrv2e${exe} --version-short
"${emu[@]}" ./upx-packed-lzma${exe} --version-short
fi
echo "All done."
+118 -117
View File
@@ -40,23 +40,24 @@ 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=()
# set emu and run_upx
emu=()
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
IFS=' ' read -r -a emu <<< "$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
IFS=';' read -r -a emu <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array
fi
upx_run+=( "$upx_exe" )
echo "upx_run='${upx_run[*]}'"
run_upx=( "${emu[@]}" "$upx_exe" )
echo "run_upx='${run_upx[*]}'"
# 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
# run_upx sanity check
if ! "${run_upx[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
if ! "${run_upx[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
#***********************************************************************
# util
@@ -203,57 +204,57 @@ mkdir default
cd default
create_files
enter_dir z_dir_1
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file && failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
assert_symlink_to_file z_symlink_file z_symlink_file_link
assert_symlink_to_dir z_symlink_dir
assert_symlink_dangling z_symlink_dangling
leave_dir
enter_dir z_dir_2
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file && failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
assert_symlink_to_file z_symlink_file z_symlink_file_link
assert_symlink_to_dir z_symlink_dir
assert_symlink_dangling z_symlink_dangling
leave_dir
enter_dir z_dir_3
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file && failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
assert_symlink_to_file z_symlink_file z_symlink_file_link
assert_symlink_to_dir z_symlink_dir
assert_symlink_dangling z_symlink_dangling
leave_dir
enter_dir z_dir_4
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file && failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
assert_symlink_to_file z_symlink_file z_symlink_file_link
assert_symlink_to_dir z_symlink_dir
assert_symlink_dangling z_symlink_dangling
@@ -266,57 +267,57 @@ mkdir force-overwrite
cd force-overwrite
create_files
enter_dir z_dir_1
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
assert_file z_symlink_file z_symlink_file_link
assert_file z_symlink_dir
assert_file z_symlink_dangling
leave_dir
enter_dir z_dir_2
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
assert_file z_symlink_file z_symlink_file_link
assert_file z_symlink_dir
assert_file z_symlink_dangling
leave_dir
enter_dir z_dir_3
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
assert_symlink_to_file z_symlink_file z_symlink_file_link
assert_symlink_to_dir z_symlink_dir
assert_symlink_dangling z_symlink_dangling
leave_dir
enter_dir z_dir_4
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
assert_symlink_to_file z_symlink_file z_symlink_file_link
assert_symlink_to_dir z_symlink_dir
assert_symlink_dangling z_symlink_dangling
@@ -330,57 +331,57 @@ mkdir link
cd link
create_files
enter_dir z_dir_1
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
assert_file z_symlink_file z_symlink_file_link
assert_file z_symlink_dir
assert_file z_symlink_dangling
leave_dir
enter_dir z_dir_2
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
assert_file z_symlink_file z_symlink_file_link
assert_file z_symlink_dir
assert_file z_symlink_dangling
leave_dir
enter_dir z_dir_3
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
assert_symlink_to_file z_symlink_file z_symlink_file_link
assert_symlink_to_dir z_symlink_dir
assert_symlink_dangling z_symlink_dangling
leave_dir
enter_dir z_dir_4
"${upx_run[@]}" $flags z_symlink_file && failed 10
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
"${run_upx[@]}" $flags z_symlink_file && failed 10
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
assert_symlink_to_file z_symlink_file z_symlink_file_link
assert_symlink_to_dir z_symlink_dir
assert_symlink_dangling z_symlink_dangling
+19 -18
View File
@@ -29,23 +29,24 @@ 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=()
# set emu and run_upx
emu=()
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
IFS=' ' read -r -a emu <<< "$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
IFS=';' read -r -a emu <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array
fi
upx_run+=( "$upx_exe" )
echo "upx_run='${upx_run[*]}'"
run_upx=( "${emu[@]}" "$upx_exe" )
echo "run_upx='${run_upx[*]}'"
# 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
# run_upx sanity check, part1
if ! "${run_upx[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
if ! "${run_upx[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
# upx_testsuite_SRCDIR
if [[ -z $upx_testsuite_SRCDIR ]]; then
@@ -78,15 +79,15 @@ upx_testsuite_BUILDDIR=$(readlink -fn "$upx_testsuite_BUILDDIR") # make absolute
cd / && cd "$upx_testsuite_BUILDDIR" || exit 1
: > ./.mfxnobackup
# upx_run sanity check, part2
if ! "${upx_run[@]}" --version-short >/dev/null; then
# run_upx sanity check, part2
if ! "${run_upx[@]}" --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"
echo "INFO: upx_run='${upx_run[*]}'"
echo "INFO: run_upx='${run_upx[*]}'"
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
if ! "${run_upx[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
case $UPX_TESTSUITE_LEVEL in
[0-8]) ;;
@@ -121,11 +122,11 @@ cd testsuite_1 || exit 1
run_upx() {
local ec=0
if [[ $UPX_TESTSUITE_VERBOSE == 1 ]]; then
echo "LOG: '${upx_run[*]}' $*"
echo "LOG: '${run_upx[*]}' $*"
fi
"${upx_run[@]}" "$@" || ec=$?
"${run_upx[@]}" "$@" || ec=$?
if [[ $ec != 0 ]]; then
echo "FATAL: '${upx_run[*]}' $*"
echo "FATAL: '${run_upx[*]}' $*"
echo " (exit code was $ec)"
exit 42
fi
@@ -319,7 +320,7 @@ ls -l "$upx_exe"
if command -v file >/dev/null; then
file "$upx_exe" || true
fi
echo "upx_run='${upx_run[*]}'"
echo "run_upx='${run_upx[*]}'"
echo "upx_testsuite_SRCDIR='$upx_testsuite_SRCDIR'"
echo "upx_testsuite_BUILDDIR='$upx_testsuite_BUILDDIR'"
echo ".sha256sums.{expected,current} counts:"