-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotest
137 lines (128 loc) · 2.89 KB
/
dotest
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh
test=`echo $1 | cut -d. -f1`
ext=`echo $1 | cut -d. -f2`
case $ext in
ctst) log=clog; out=cout ;;
*) log=log; out=out ;;
esac
valgrind=$2
BASILISK_WIKI=`echo $BASILISK | sed 's:/src$::'`
dir=`echo $PWD | sed "s:$BASILISK_WIKI/::"`
script()
{
cat <<EOF
rm -f $test.c
if test -f fail; then
cat fail
exit 1
fi
cat warn
test -s warn || rm -f warn
echo \[$test.$ext\]
if $valgrind ./$test 2> $log > $out; then
if test -f $test.ref; then
echo diff $log $test.ref > fail
diff $log $test.ref >> fail && rm -f fail
rm -f $test.ref
fi
else
cp -f $log fail
fi
if test -f fail; then
cat fail
exit 1
fi
touch pass
EOF
}
expirecache()
{
rm -f $BASILISK_WIKI/cache/$dir/$test.c.page
}
# run locally
locally()
{
cd $test
rm -f warn pass fail $log $out
cd ..
echo qcc $CFLAGS -o $test/$test $test.c $LIBS -lm;
qcc $CFLAGS -o $test/$test $test.c $LIBS -lm > $test/warn 2>&1 \
|| mv -f $test/warn $test/fail
cd $test
script | sh
expirecache
cd ..
}
# compile/run on a remote "sandbox"
remotely()
{
set -e
rhost=$1
chksum=`$GENSUM $test.s | cut -d' ' -f1`
cd $test
mkdir $chksum
cp -f $test.c $chksum
if test -f $test.ref; then cp -f $test.ref $chksum; fi
(cat <<EOF
#!/bin/sh
rm -f warn pass fail $log $out
\$BASILISK/qcc $CFLAGS -o $test $test.c $LIBS -lm > warn 2>&1 || mv -f warn fail
EOF
script) > $chksum/$test.sh
cat <<EOF >> $chksum/$test.sh
rm -f $test.c $test.sh $test.ref
tar czf \$HOME/$chksum.tgz *
rm -r -f \$HOME/$chksum
EOF
tar czf $chksum.tgz $chksum
rm -r -f $chksum
scp -q $chksum.tgz $rhost: && rm -f $chksum.tgz
ssh $rhost sh -c "\"tar xzf $chksum.tgz && cd $chksum && sh $test.sh\""
scp -q $rhost:$chksum.tgz $chksum.tgz
ssh $rhost rm -r -f $chksum.tgz
tar xzf $chksum.tgz
rm -f $chksum.tgz $test.c $test.ref pid
expirecache
if test -f fail && test -n "$MAINTAINER"; then
(
echo Latest change:
echo
darcs changes --last=1
echo
if test -f ../$test.c.page; then
cat <<EOF
See http://basilisk.fr/$dir/$test.c
EOF
else
cat fail
fi
) | mail -s "basilisk: $test.$ext failed" $MAINTAINER
fi
cd ..
}
set -e
if test -f $test.$ext && $CHECKSUM $test.$ext; then
touch $test.$ext
echo "make: '$test' is up to date."
else
rm -f $test.$ext $test/pass $test/fail $test/warn $test/plot.png
expirecache
mkdir -p $test && cp -f $test.c $test
if test -f $test.ref; then cp -f $test.ref $test; fi
if test -d $BASILISK_WIKI/static -a \
-f $test.c.page -a \
! -L $BASILISK_WIKI/static/$dir/$test; then
ln -s $PWD/$test $BASILISK_WIKI/static/$dir/$test
fi
if test -n "$SANDBOX"; then
echo \[$test.$ext on $SANDBOX\]
( remotely $SANDBOX ) &
echo $! > $test/pid
else
locally
fi
if test -f $test/fail; then
exit 1
fi
$GENSUM $test.s > $test.$ext;
fi