-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-120.sh
64 lines (50 loc) · 1.03 KB
/
test-120.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
#!/bin/sh
#
# Tests de detection de changement
#
TEST=$(basename $0 .sh)
TMP=/tmp/$TEST
LOG=$TEST.log
V=${VALGRIND} # appeler avec la var. VALGRIND à "" ou "valgrind -q"
exec 2> $LOG
set -x
rm -f *.tmp
fail ()
{
echo "==> Échec du test '$TEST' sur '$1'."
echo "==> Log : '$LOG'."
echo "==> Exit"
exit 1
}
# test de changement
cat > script.tmp <<'EOF'
#!/bin/sh
# script pour faire un changement à chaque fois
F=f1.tmp
if [ -f $F ]
then echo "present" ; rm $F ; r=1
else echo "absent" ; touch $F ; r=0
fi
exit $r
EOF
chmod +x script.tmp
N=5
for i in $(seq 1 $N)
do
echo absent
echo present
done > f3.tmp
rm -f f1.tmp
$V ./detecter -i1 -l$((N*2)) ./script.tmp > f2.tmp \
&& cmp -s f2.tmp f3.tmp || fail "present-absent"
# test de changement avec code retour
for i in $(seq 1 $N)
do
echo absent
echo exit 0
echo present
echo exit 1
done > f3.tmp
$V ./detecter -c -i1 -l$((N*2)) ./script.tmp > f2.tmp \
&& cmp -s f2.tmp f3.tmp || fail "present-absent -c"
exit 0