Add check_whitespace.sh and call it from Makefile. Update Travis.

This commit is contained in:
Markus F.X.J. Oberhumer
2016-10-02 15:46:57 +02:00
parent 0f74162551
commit 9d14185f7d
8 changed files with 125 additions and 86 deletions
+12 -35
View File
@@ -24,35 +24,11 @@ echo "$CC --version"; $CC --version
echo "$CXX --version"; $CXX --version
echo
# whitespace
# check whitespace
if [[ $TRAVIS_OS_NAME == linux ]]; then
cd / && cd $upx_SRCDIR || exit 1
echo "Checking source code for whitespace violations..."
find . \
-type d -name '.git' -prune -o \
-type d -name '.hg' -prune -o \
-type d -name 'build' -prune -o \
-type d -name 'tmp' -prune -o \
-type f -iname '*.bat' -prune -o \
-type f -iname '*.exe' -prune -o \
-type f -iname '*.pdf' -prune -o \
-type f -print0 | LC_ALL=C sort -z | \
xargs -0r perl -n -e '
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
if (m,([ \t]+)$,) {
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
if ($1 ne " " || $ARGV !~ m,\.md$,) {
print "ERROR: trailing whitespace detected $ARGV: $_"; exit(1);
}
}
if (m,\t,) {
if ($ARGV =~ m,(^|/)\.gitmodules$,) { }
elsif ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { }
elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { }
elsif ($ARGV =~ m,/src/stub/src/arch/.*\.S$,) { }
else { print "ERROR: hard TAB detected $ARGV: $_"; exit(1); }
}
' || exit 1
bash ./src/stub/scripts/check_whitespace.sh || exit 1
echo " Passed."
fi # linux
@@ -64,7 +40,7 @@ set -x
cd / && cd $ucl_BUILDDIR || exit 1
if [[ -n $BM_CROSS || $TRAVIS_OS_NAME == windows ]]; then
# configure is too old
# ucl-1.03/configure is too old - build manually
rm -f ./*.o libucl.a
$CC -O2 -I$ucl_SRCDIR/include -I$ucl_SRCDIR -c $ucl_SRCDIR/src/*.c
$AR rcs libucl.a *.o
@@ -81,12 +57,13 @@ fi
# build zlib
#
if [[ $BUILD_LOCAL_ZLIB ]]; then
if [[ $BUILD_LOCAL_ZLIB == 1 ]]; then
cd / && cd $zlib_BUILDDIR || exit 1
# build manually
rm -f ./*.o libz.a
$CC -O2 -c $zlib_SRCDIR/*.c
$AR rcs libz.a *.o
fi # BUILD_LOCAL_ZLIB
fi
#
# build UPX
@@ -97,7 +74,7 @@ cd / && cd $upx_BUILDDIR || exit 1
make="make -f $upx_SRCDIR/src/Makefile"
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DUCL_NO_ASM"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$ucl_BUILDDIR/src/.libs"
if [[ $BUILD_LOCAL_ZLIB ]]; then
if [[ $BUILD_LOCAL_ZLIB == 1 ]]; then
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -I$zlib_SRCDIR"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$zlib_BUILDDIR"
fi
@@ -124,11 +101,11 @@ if [[ $BM_B =~ (^|\+)ALLOW_FAIL($|\+) ]]; then
fi
export EXTRA_CPPFLAGS EXTRA_CXXFLAGS EXTRA_LDFLAGS
$make
[[ -z $upx_exeext ]] && upx_exeext=.out
$make exeext=$upx_exeext
[[ -z $exeext ]] && exeext=.out
ls -l upx${exeext}
$SIZE upx${exeext} || true
file upx${exeext}
ls -l upx${upx_exeext}
$SIZE upx${upx_exeext} || true
file upx${upx_exeext}
exit 0
+25 -20
View File
@@ -6,12 +6,12 @@
#set -x # debug
umask 022
# rename short Build-Matrix variables to more readable names
# rename short variables to more readable Build-Matrix BM_ names
# C is COMPILER
# B is BUILD_TYPE
# T is TESTSUITE_FLAGS
BM_C=$C; BM_B=$B; BM_CROSS=$CROSS; BM_T=$T
unset C B CROSS T
# B is BUILD_OPTIONS
# T is TESTSUITE_OPTIONS
BM_CROSS=$CROSS; BM_C=$C; BM_B=$B; BM_T=$T
unset CROSS C B T
[[ -z $BM_C ]] && BM_C=gcc
[[ -z $BM_B ]] && BM_B=release
@@ -41,7 +41,7 @@ CC=false CXX=false SCAN_BUILD=false
AR=ar SIZE=size
if [[ -n $APPVEYOR_JOB_ID ]]; then
BUILD_LOCAL_ZLIB=1
export exeext=.exe
upx_exeext=.exe
# dir c:\cygwin
case $BM_C in
gcc-m32 | gcc-4.9-m32)
@@ -68,7 +68,7 @@ if [[ -n $BM_CROSS ]]; then
case $BM_CROSS-$BM_C in
arm-linux-gnueabi-gcc | arm-linux-gnueabi-gcc-4.6)
export upx_EXTRA_LDFLAGS="-static-libgcc -static-libstdc++"
[[ -z $upx_qemu ]] && upx_qemu="qemu-arm-static -L/usr/arm-linux-gnueabi"
[[ -z $upx_qemu ]] && upx_qemu="qemu-arm -L/usr/arm-linux-gnueabi"
x=arm-linux-gnueabi; AR="$x-ar"; CC="$x-gcc"; CXX="$x-g++" ;;
arm-linux-gnueabihf-gcc | arm-linux-gnueabihf-gcc-4.6)
export upx_EXTRA_LDFLAGS="-static-libgcc -static-libstdc++"
@@ -142,22 +142,28 @@ done
[[ -z $lcov_OUTPUTDIR ]] && lcov_OUTPUTDIR=$(readlink -mn -- "$toptop_bdir/.lcov-results")
unset toptop_builddir toptop_bdir
# ensure absolute dirs
# ensure absolute directories
make_absolute() {
while [[ $# -gt 0 ]]; do
if [[ -n ${!1} ]]; then
d=$(readlink -mn -- "${!1}")
eval $1="$d"
fi
shift
done
}
for var_prefix in ucl upx upx_testsuite zlib; do
for var_suffix in _BUILDDIR _SRCDIR; do
var_name=${var_prefix}${var_suffix}
if [[ -n ${!var_name} ]]; then
d=$(readlink -mn -- "${!var_name}")
eval $var_name="$d"
fi
for var_suffix in _BUILDDIR _SRCDIR; do
make_absolute ${var_prefix}${var_suffix}
done
done
done
unset var_name var_prefix var_suffix
make_absolute lcov_OUTPUTDIR
unset var_prefix var_suffix
print_settings() {
local v var_prefix var_suffix
# Build Matrix
for v in TRAVIS_OS_NAME BM_C BM_B BM_CROSS BM_T; do
for v in TRAVIS_OS_NAME BM_CROSS BM_C BM_B BM_T; do
[[ -n ${!v} ]] && echo "${v}='${!v}'"
done
# BM_C related
@@ -166,8 +172,8 @@ print_settings() {
v=EXTRA_${v}
[[ -n ${!v} ]] && echo "${v}='${!v}'"
done
# dirs and other info
for v in TRAVIS_XCODE_SDK UPX_UCLDIR; do
# directories and other info
for v in TRAVIS_XCODE_SDK UPX_UCLDIR lcov_OUTPUTDIR; do
[[ -n ${!v} ]] && echo "${v}='${!v}'"
done
for var_prefix in ucl upx upx_testsuite zlib; do
@@ -179,5 +185,4 @@ print_settings() {
##env | LC_ALL=C sort
}
true
+40 -23
View File
@@ -16,7 +16,6 @@ argv0="$0"; argv0dir=$(readlink -en -- "$0"); argv0dir=$(dirname "$argv0dir")
fi
source "$argv0dir/travis_init.sh" || exit 1
# BM_T is TESTSUITE_FLAGS
if [[ $BM_T =~ (^|\+)SKIP($|\+) ]]; then
echo "UPX testsuite SKIPPED."
exit 0
@@ -58,32 +57,33 @@ testsuite_check_sha() {
diff -u $1/.sha256sums.expected $1/.sha256sums.current || true
#exit 1
exit_code=1
let num_errors+=1 || true
fi
echo
}
testsuite_run_compress() {
testsuite_header $testdir
local f ff
for f in $upx_testsuite_SRCDIR/files/packed/*/upx-3.91*; do
local f
for f in t01_decompressed/*/*; do
testsuite_split_f $f
[[ -z $fb ]] && continue
mkdir -p $testdir/$fsubdir
ff=t01_decompressed/$fsubdir/$fb
$upx_exe --prefer-ucl "$@" $ff -o $testdir/$fsubdir/$fb
$upx_run --prefer-ucl "$@" $f -o $testdir/$fsubdir/$fb
done
testsuite_check_sha $testdir
$upx_exe -l $testdir/*/*
$upx_exe --file-info $testdir/*/*
$upx_exe -t $testdir/*/*
$upx_run -l $testdir/*/*
$upx_run --file-info $testdir/*/*
$upx_run -t $testdir/*/*
}
# /***********************************************************************
# // init
# ************************************************************************/
#set -x
#set -x # debug
exit_code=0
num_errors=0
if [[ $BM_T =~ (^|\+)ALLOW_FAIL($|\+) ]]; then
echo "ALLOW_FAIL"
@@ -93,32 +93,38 @@ fi
[[ -z $upx_exe && -f $upx_BUILDDIR/upx.out ]] && upx_exe=$upx_BUILDDIR/upx.out
[[ -z $upx_exe && -f $upx_BUILDDIR/upx.exe ]] && upx_exe=$upx_BUILDDIR/upx.exe
if [[ -z $upx_exe ]]; then exit 1; fi
upx_run=$upx_exe
if [[ $BM_T =~ (^|\+)qemu($|\+) && -n $upx_qemu ]]; then
upx_exe="$upx_qemu $upx_qemu_flags -- $upx_exe"
upx_run="$upx_qemu $upx_qemu_flags -- $upx_exe"
fi
if [[ $BM_T =~ (^|\+)wine($|\+) && -n $upx_wine ]]; then
upx_exe="$upx_wine $upx_wine_flags $upx_exe"
upx_run="$upx_wine $upx_wine_flags $upx_exe"
fi
if ! $upx_exe --version >/dev/null; then exit 1; fi
if [[ $BM_T =~ (^|\+)valgrind($|\+) ]]; then
valgrind_flags="--leak-check=full --show-reachable=yes"
valgrind_flags="-q --leak-check=no --error-exitcode=1"
valgrind_flags="--leak-check=no --error-exitcode=1"
upx_exe="valgrind $valgrind_flags $upx_exe"
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
if [[ $BM_B =~ (^|\+)coverage($|\+) ]]; then
(cd / && cd $upx_BUILDDIR && lcov -d . --zerocounters)
fi
rm -rf ./testsuite_1
mkdir testsuite_1
cd testsuite_1
export UPX=
export UPX="--no-color --no-progress"
# let's go
if ! $upx_run --version >/dev/null; then exit 1; fi
rm -rf ./testsuite_1
mkbuilddirs testsuite_1
cd testsuite_1 || exit 1
# /***********************************************************************
# // decompression tests
@@ -142,7 +148,7 @@ for f in $upx_testsuite_SRCDIR/files/packed/*/upx-3.91*; do
testsuite_split_f $f
[[ -z $fb ]] && continue
mkdir -p $testdir/$fsubdir
$upx_exe -d $f -o $testdir/$fsubdir/$fb
$upx_run -d $f -o $testdir/$fsubdir/$fb
done
testsuite_check_sha $testdir
@@ -222,10 +228,21 @@ a647ed1aea16f58b544228279ad7159cd3ec5c3533efef1fd2df5a5a59b5d663 *i386-win32.pe/
time testsuite_run_compress --all-methods --no-lzma --no-filter
testsuite_header "UPX testsuite summary"
echo "upx_exe='$upx_exe'"
if [[ $upx_run != $upx_exe ]]; then
echo "upx_run='$upx_run'"
fi
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
if [[ $exit_code == 0 ]]; then
echo "UPX testsuite passed. All done."
else
echo "UPX-ERROR: UPX testsuite FAILED. See log file."
echo "UPX-ERROR: UPX testsuite FAILED with $num_errors error(s). See log file."
fi
exit $exit_code