Update testsuite.

This commit is contained in:
Markus F.X.J. Oberhumer 2016-10-06 01:26:01 +02:00
parent d335d7bafd
commit 8f5e89c900
3 changed files with 75 additions and 31 deletions

View File

@ -55,26 +55,41 @@ testsuite_check_sha() {
if ! cmp -s $1/.sha256sums.expected $1/.sha256sums.current; then
echo "UPX-ERROR: checksum mismatch"
diff -u $1/.sha256sums.expected $1/.sha256sums.current || true
#exit 1
exit_code=1
let num_errors+=1 || true
#exit 1
fi
echo
}
testsuite_check_sha_decompressed() {
(cd "$1" && sha256sum -b */* | LC_ALL=C sort -k2) > $1/.sha256sums.current
if ! cmp -s $1/.sha256sums.expected $1/.sha256sums.current; then
cat $1/.sha256sums.current
echo "UPX-ERROR: decompressed checksum mismatch"
diff -u $1/.sha256sums.expected $1/.sha256sums.current || true
exit 1
fi
}
testsuite_run_compress() {
testsuite_header $testdir
local f
for f in t01_decompressed/*/*; do
for f in t01_canonicalized/*/*; do
testsuite_split_f $f
[[ -z $fb ]] && continue
mkdir -p $testdir/$fsubdir
mkdir -p $testdir/$fsubdir $testdir/.decompressed/$fsubdir
$upx_run --prefer-ucl "$@" $f -o $testdir/$fsubdir/$fb
$upx_run -qq -d $testdir/$fsubdir/$fb -o $testdir/.decompressed/$fsubdir/$fb
done
testsuite_check_sha $testdir
$upx_run -l $testdir/*/*
$upx_run --file-info $testdir/*/*
$upx_run -t $testdir/*/*
# check that after decompression the file matches the canonicalized version
cp t01_canonicalized/.sha256sums.expected $testdir/.decompressed/
testsuite_check_sha_decompressed $testdir/.decompressed
rm -rf ./$testdir/.decompressed
}
# /***********************************************************************
@ -116,8 +131,7 @@ if [[ $BM_B =~ (^|\+)coverage($|\+) ]]; then
(cd / && cd $upx_BUILDDIR && lcov -d . --zerocounters)
fi
export UPX=
export UPX="--no-color --no-progress"
export UPX="--prefer-ucl --no-color --no-progress"
# let's go
if ! $upx_run --version >/dev/null; then exit 1; fi
@ -153,6 +167,31 @@ done
testsuite_check_sha $testdir
# run one pack+unpack step to canonicalize the files
testdir=t01_canonicalized
mkdir $testdir; echo -n "\
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
28d7ca8f0dfca8159e637eaf2057230b6e6719e07751aca1d19a45b5efed817c *arm-wince.pe/upx-3.91.exe
b1c1c38d50007616aaf8e942839648c80a6111023e0b411e5fa7a06c543aeb4a *armeb-linux.elf/upx-3.91
bcac77a287289301a45fde9a75e4e6c9ad7f8d57856bae6eafaae12ae4445a34 *i386-dos32.djgpp2.coff/upx-3.91.exe
730a513b72a094697f827e4ac1a4f8ef58a614fc7a7ad448fa58d60cd89af7ed *i386-linux.elf/upx-3.91
1f378dc3f8c6f0cf604c057b468c22beb46a16837bd2410cf5f8fa44a42b2f6f *i386-win32.pe/upx-3.91.exe
8e5333ea040f5594d3e67d5b09e005d52b3a52ef55099a7c11d7e39ead38e66d *m68k-atari.tos/upx-3.91.ttp
c3f44b4d00a87384c03a6f9e7aec809c1addfe3e271244d38a474f296603088c *mipsel-linux.elf/upx-3.91
b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.elf/upx-3.91
" > $testdir/.sha256sums.expected
testsuite_header $testdir
for f in t01_decompressed/*/*; do
testsuite_split_f $f
[[ -z $fb ]] && continue
mkdir -p $testdir/$fsubdir/.packed
$upx_run --prefer-ucl -1 $f -o $testdir/$fsubdir/.packed/$fb
$upx_run -d $testdir/$fsubdir/.packed/$fb -o $testdir/$fsubdir/$fb
done
testsuite_check_sha $testdir
# /***********************************************************************
# // compression tests
# // info: we use fast compression levels because we want to

View File

@ -141,6 +141,31 @@ help$(objext): $(MAKEFILE_LIST)
endif
# "make run-testsuite"
#
# search for the UPX testsuite -- git clone https://github.com/upx/upx-testsuite.git
# you also can set upx_testsuite_SRCDIR
ifndef upx_testsuite_SRCDIR
# search standard locations below $(top_srcdir)
ifneq ($(wildcard $(top_srcdir)/../upx-testsuite.git/files/packed/.),)
upx_testsuite_SRCDIR := $(top_srcdir)/../upx-testsuite.git
else ifneq ($(wildcard $(top_srcdir)/../upx-testsuite/files/packed/.),)
upx_testsuite_SRCDIR := $(top_srcdir)/../upx-testsuite
endif
endif
# run the UPX testsuite
ifneq ($(wildcard $(upx_testsuite_SRCDIR)/files/packed/.),)
ifneq ($(wildcard $(top_srcdir)/.github/travis_testsuite_1.sh),)
run-testsuite: export upx_exe := ./upx$(exeext)
run-testsuite: export upx_testsuite_SRCDIR := $(upx_testsuite_SRCDIR)
run-testsuite: export upx_testsuite_BUILDDIR := ./tmp-testsuite
run-testsuite: ./upx$(exeext)
time -p bash $(top_srcdir)/.github/travis_testsuite_1.sh
.PHONY: run-testsuite
endif
endif
# automatically format some C++ source code files
ifeq ($(shell uname),Linux)
CLANG_FORMAT_FILES += packhead.cpp
@ -153,26 +178,4 @@ clang-format:
.PHONY: clang-format
endif
# run the UPX testsuite - git clone https://github.com/upx/upx-testsuite.git
# you have to set upx_testsuite_SRCDIR
ifneq ($(wildcard $(top_srcdir)/.github/travis_testsuite_1.sh),)
ifndef upx_testsuite_SRCDIR
# search standard locations below $(top_srcdir)
ifneq ($(wildcard $(top_srcdir)/../upx-testsuite.git/files/packed/.),)
upx_testsuite_SRCDIR := $(top_srcdir)/../upx-testsuite.git
else ifneq ($(wildcard $(top_srcdir)/../upx-testsuite/files/packed/.),)
upx_testsuite_SRCDIR := $(top_srcdir)/../upx-testsuite
endif
endif
ifneq ($(wildcard $(upx_testsuite_SRCDIR)/files/packed/.),)
run-testsuite: export upx_exe := ./upx$(exeext)
run-testsuite: export upx_testsuite_SRCDIR := $(upx_testsuite_SRCDIR)
run-testsuite: export upx_testsuite_BUILDDIR := ./tmp-testsuite
run-testsuite: ./upx$(exeext)
time -p bash $(top_srcdir)/.github/travis_testsuite_1.sh
.PHONY: run-testsuite
endif
endif
# vim:set ts=8 sw=8 noet:

View File

@ -1,15 +1,17 @@
#!/bin/sh
set -e
#! /usr/bin/env bash
## vim:set ts=4 sw=4 et:
set -e; set -o pipefail
# NOTE: we are using clang-format-3.9.0 from upx-stubtools
# see https://github.com/upx/upx-stubtools/releases
CLANG_FORMAT="$HOME/local/bin/bin-upx/clang-format-3.9.0"
if ! test -f "$CLANG_FORMAT"; then
if [[ ! -f $CLANG_FORMAT ]]; then
CLANG_FORMAT="$HOME/bin/bin-upx/clang-format-3.9.0"
fi
if ! test -f "$CLANG_FORMAT"; then
if [[ ! -f $CLANG_FORMAT ]]; then
echo "ERROR: $0: cannot find clang-format-3.9.0"
echo "ERROR: $0: please visit https://github.com/upx/upx-stubtools/releases"
exit 1
fi