Add a simple test for reproducibility

It probably needs environment changes and other differences to be more
effective, but if anything it adds a placeholder for improvement, and
shows some solidarity with the reproducible builds project that was
started in debian.
This commit is contained in:
James Shubin
2016-02-08 11:50:08 -05:00
parent 6e6614808b
commit 028fb1c258
2 changed files with 41 additions and 0 deletions

View File

@@ -28,3 +28,5 @@ fi
if env | grep -q -e '^JENKINS_URL=' -e '^BUILD_TAG=jenkins'; then
./test/test-omv.sh
fi
./test/test-reproducible.sh

39
test/test-reproducible.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
# simple test for reproducibility, probably needs major improvements
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.XXX`
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