chiark / gitweb /
changelog: start 0.6.8
[secnet.git] / comprehensive-test
1 #!/bin/bash
2 # This file is part of secnet.
3 # See LICENCE and this file CREDITS for full list of copyright holders.
4 # SPDX-License-Identifier: GPL-3.0-or-later
5 # There is NO WARRANTY.
6
7 set -e
8 set -o pipefail
9
10 oot_rel=oot-rel.tmp~
11 oot_abs=$(cd .. && pwd)/oot-comprehensive-test.tmp~
12
13 nproc=$(nproc || echo 1)
14 mflags=-j$nproc
15
16 for arg in "$@"; do
17     case "$arg" in
18         --oot-abs=*) oot_abs=${arg%*=} ;;
19         *) echo >&2 "unknown arg/option $1"; exit 1;;
20     esac
21 done
22
23 case "${OLD_SECNET_DIR-:?must be set, perhaps to the empty string}" in
24     ''|/*)
25         ;;
26     ../*)
27         OLD_SECNET_DIR="${PWD%/*}/${OLD_SECNET_DIR#../}"
28         echo >&2 "x OLD_SECNET_DIR=$OLD_SECNET_DIR"
29         ;;
30     *)
31         echo >&2 "relative non-.. OLD_SECNET_DIR $OLD_SECNET_DIR !";
32         exit 1
33         ;;
34 esac
35
36 x () { echo >&2 "x $*"; "$@"; }
37
38 srcdir=$(pwd)
39
40 build_and_test () {
41     cd "$srcdir"
42     x git clean -xdff
43     if [ "x$1" != x. ]; then
44         rm -rf "$1"
45         mkdir "$1"
46     fi
47     x ./autogen.sh
48     x cd "$1"
49     x "$srcdir/configure" CFLAGS='-O0 -g'
50     x make $mflags all check
51     for t in mtest/check stest/check; do
52         x make $mflags clean
53         x make $mflags $t
54     done
55     x make $mflags clean
56     if [ "x$1" != x. ]; then
57          find -type f
58      else
59          git-ls-files -o
60     fi | perl -ne '
61         s{^\./}{};
62         s{^}{/};
63         next if m{^/ct-files$};
64         next if m{^/autom4te\.cache/};
65         next if m{/Makefile$};
66         next if m{\.mk$};
67         next if m{^/common\.make$};
68         next if m{^/(?:config|\.makefiles)\.stamp$};
69         next if m{^/config\.(?:log|status|h)$};
70         warn "clean in '"$1"' missed $_";
71         $bad=1;
72         END { exit $bad; }
73     '
74     cd "$srcdir"
75 }
76
77 build_and_test .
78 build_and_test "$oot_rel"
79 build_and_test "$oot_abs"
80
81 echo "----- $0 ok -----"