Files
mgmt/test/test-reproducible.sh
Johan Bloemberg b34b359860 test: Streamline test suite a little
This change aims to streamline the integrationtest suite and reduce friction when running (parts of) test suites.

Changes:
- add `test-testname` to makefile to easily run one suite
- made skipping tests first class citizen in test.sh (all available testsuites and the reasons they are skipped are now better exposed and discovered)
- suppress some output of gotest unless there is an error
- no longer build binary for examples and gotest suites
- removed .SILENT from makefile as it being applied to only some targets makes it feel weird (I just learned about this option btw, feel free to comment on this change)
- move individual tests out of `test.sh` and into `test-misc.sh`
- introduced the concept of testsuites to `test.sh`
2018-02-15 17:21:49 +01:00

40 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# simple test for reproducibility, probably needs major improvements
echo running "$0"
set -o errexit
set -o pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" # dir!
cd "$DIR" >/dev/null # work from main mgmt directory
make build
T=`$mktemp --tmpdir -d tmp.X'X'X` # add quotes to avoid matching three X's
cp -a ./mgmt "$T"/mgmt.1
make clean
make build
cp -a ./mgmt "$T"/mgmt.2
# size comparison test
[ `stat -c '%s' "$T"/mgmt.1` -eq `stat -c '%s' "$T"/mgmt.2` ] || failures="Size of binary was not reproducible"
# sha1sum test
sha1sum "$T"/mgmt.1 > "$T"/mgmt.SHA1SUMS.1
sha1sum "$T"/mgmt.2 > "$T"/mgmt.SHA1SUMS.2
cat "$T"/mgmt.SHA1SUMS.1 | sed 's/mgmt\.1/mgmt\.X/' > "$T"/mgmt.SHA1SUMS.1X
cat "$T"/mgmt.SHA1SUMS.2 | sed 's/mgmt\.2/mgmt\.X/' > "$T"/mgmt.SHA1SUMS.2X
diff -q "$T"/mgmt.SHA1SUMS.1X "$T"/mgmt.SHA1SUMS.2X || failures=$( [ -n "${failures}" ] && echo "$failures" ; echo "SHA1SUM of binary was not reproducible" )
# clean up
if [ "$T" != '' ]; then
rm -rf "$T"
fi
make clean
# display errors
if [[ -n "${failures}" ]]; then
echo 'FAIL'
echo 'The following tests failed:'
echo "${failures}"
exit 1
fi
echo 'PASS'