-
Notifications
You must be signed in to change notification settings - Fork 0
/
testfile.sh
126 lines (109 loc) · 2.57 KB
/
testfile.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
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
#!/bin/bash
if [[ $# != 2 ]]; then
echo "usa $0 unix_path dir_name"
exit 1
fi
# registro un po' di nickname
./client -l $1 -c pippo &
./client -l $1 -c pluto &
./client -l $1 -c minni &
./client -l $1 -c topolino &
./client -l $1 -c paperino &
./client -l $1 -c qui &
./client -l $1 -c quo &
./client -l $1 -c qua &
wait
# minni deve ricevere 8 messaggi prima di terminare
./client -l $1 -k minni -R 8 &
pid=$!
# aspetto un po' per essere sicuro che il client sia partito
sleep 1
# primo messaggio
./client -l $1 -k topolino -S "ciao da topolino":minni
if [[ $? != 0 ]]; then
exit 1
fi
# secondo e terzo
./client -l $1 -k paperino -S "ciao da paperino":minni -S "ciao ciao!!!":minni
if [[ $? != 0 ]]; then
exit 1
fi
# quarto
./client -l $1 -k qui -S "ciao a tutti":
if [[ $? != 0 ]]; then
exit 1
fi
# quinto e sesto
./client -l $1 -k quo -S "ciao a tutti": -S "ciao da quo":minni
if [[ $? != 0 ]]; then
exit 1
fi
# settimo ed ottavo
./client -l $1 -k qua -S "ciao a tutti": -S "ciao da qua":minni -p
if [[ $? != 0 ]]; then
exit 1
fi
wait $pid
if [[ $? != 0 ]]; then
echo "ESCO8"
exit 1
fi
# messaggio di errore che mi aspetto
OP_NICK_ALREADY=26
# provo a ri-registrare pippo
./client -l $1 -c pippo
e=$?
if [[ $((256-e)) != $OP_NICK_ALREADY ]]; then
echo "Errore non corrispondente $e"
exit 1
fi
# deregistro pippo
./client -l $1 -k pippo -C pippo
if [[ $? != 0 ]]; then
exit 1
fi
# deregistro pluto
./client -l $1 -k pluto -C pluto
if [[ $? != 0 ]]; then
exit 1
fi
# registro pippo
./client -l $1 -c pippo
if [[ $? != 0 ]]; then
exit 1
fi
# registro pluto
./client -l $1 -c pluto
if [[ $? != 0 ]]; then
exit 1
fi
# pippo e pluto si scambiano files
./client -l $1 -k pippo -S "Ti mando un file":pluto -s ./client:pluto
if [[ $? != 0 ]]; then
exit 1
fi
./client -l $1 -k pluto -S "Ti mando un file":pippo -s ./chatty:pippo -s ./libchatty.a:pippo
if [[ $? != 0 ]]; then
exit 1
fi
# controllo che i file siano arrivati al server e che siano corretti
md51=$(md5sum ./client | cut -d " " -f 1)
md52=$(md5sum ./chatty | cut -d " " -f 1)
md53=$(md5sum ./libchatty.a | cut -d " " -f 1)
md5client=$(md5sum $2/client | cut -d " " -f 1)
md5chatty=$(md5sum $2/chatty | cut -d " " -f 1)
md5lib=$(md5sum $2/libchatty.a | cut -d " " -f 1)
if [[ $md5client != $md51 ]]; then
echo "./client e $2/client differiscono!"
exit 1
fi
if [[ $md5chatty != $md52 ]]; then
echo "./chatty e $2/chatty differiscono!"
exit 1
fi
if [[ $md5lib != $md53 ]]; then
echo "./libchatty.a e $2/libchatty.a differiscono!"
exit 1
fi
echo "Test OK!"
exit 0