Merge branch 'maint-0.4.8'
[tor.git] / scripts / maint / checkSpaceTest.sh
blobe1d207a1a825c0e2f14a9d3659d230ed5cef44e6
1 #!/bin/sh
2 # Copyright 2019, The Tor Project, Inc.
3 # See LICENSE for licensing information
5 # Integration test for checkSpace.pl, which we want to rewrite.
7 umask 077
8 set -e
10 # Skip this test if we're running on Windows; we expect line-ending
11 # issues in that case.
12 case "$(uname -s)" in
13 CYGWIN*) WINDOWS=1;;
14 MINGW*) WINDOWS=1;;
15 MSYS*) WINDOWS=1;;
16 *) WINDOWS=0;;
17 esac
18 if test "$WINDOWS" = 1; then
19 # This magic value tells automake that the test has been skipped.
20 exit 77
23 # make a safe space for temporary files
24 DATA_DIR=$(mktemp -d -t tor_checkspace_tests.XXXXXX)
25 trap 'rm -rf "$DATA_DIR"' 0
27 RECEIVED_FNAME="${DATA_DIR}/got.txt"
29 cd "$(dirname "$0")/checkspace_tests"
31 # we expect this to give an error code.
32 ../checkSpace.pl -C ./*.[ch] ./*/*.[ch] > "${RECEIVED_FNAME}" && exit 1
34 diff -u expected.txt "${RECEIVED_FNAME}" || exit 1
36 echo "OK"