-
Notifications
You must be signed in to change notification settings - Fork 17
/
checkconfig.sh
executable file
·75 lines (63 loc) · 1.38 KB
/
checkconfig.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
usage () {
cat <<EOF
usage: checkconfig.sh [ <option> ]
-h | --help print this command line option summary
-i | --invalid assume configuration is invalid and should fail
Reads sets of configuration from '<stdin>', for instance
echo "./configure --no-block" | ./checkconfig.sh
one configuration per line, configures the solver with that set of options,
compiles it and then runs 'make test' followed by 'make clean'.
EOF
exit 0
}
if [ -t 1 ]
then
BOLD="\033[1m"
NORMAL="\033[0m"
RED="\033[1;31m"
fi
die () {
echo "${BOLD}checkconfig.sh: ${RED}error: ${NORMAL}$*" 1>&2
exit 1
}
failed () {
echo
die "last command failed"
}
succeeded () {
echo
die "last command succeeded unexpectedly"
}
invalid=no
while [ $# -gt 0 ]
do
case $1 in
-i|--invalid) invalid=yes;;
-h|--help) usage;;
*) die "invalid option '$1' (try '-h')";;
esac
shift
done
if [ $invalid = no ]
then
while IFS= read -r command
do
echo -n "$command"
$command 1>/dev/null 2>/dev/null || failed
echo -n " && make"
make 1>/dev/null 2>/dev/null || failed
echo -n " test"
make test 1>/dev/null 2>/dev/null || failed
echo -n " && make clean"
make clean 1>/dev/null 2>/dev/null || failed
echo
done
else
while IFS= read -r command
do
echo -n "$command"
$command 1>/dev/null 2>/dev/null && succeeded
echo " # failed as expected"
done
fi