-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.sh
More file actions
146 lines (124 loc) · 4.05 KB
/
Copy pathtests.sh
File metadata and controls
146 lines (124 loc) · 4.05 KB
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
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
# function to clean up files and make executables
remake () {
#echo -e "\nCleaning old files and making executables"
make -s >/dev/null 2>&1
make -C test-files/ -s >/dev/null 2>&1
}
# function to check for IPC files
checkclean () {
if [ "$1" = "f" ]; then
if [ "$(find . -type p)" ]; then
#echo "Failed to close FIFORequestChannel - removing for next test"
find . -type p -exec rm {} +
fi
else
echo "something broke"
exit 1
fi
}
echo -e "To remove colour from tests, set COLOUR to 1 in sh file\n"
COLOUR=0
if [[ COLOUR -eq 0 ]]; then
ORANGE='\033[0;33m'
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
else
ORANGE='\033[0m'
GREEN='\033[0m'
RED='\033[0m'
NC='\033[0m'
fi
remake
#echo -e "\nTest cases for BoundedBuffer"
echo -e "\nTesting :: ./test-files/tester < test-files/test_single_msg.txt\n"
if timeout 20 ./test-files/tester < test-files/test_single_msg.txt >/dev/null 2>&1; then
echo -e " ${GREEN}Passed${NC}"
else
echo -e " ${RED}Failed${NC}"
fi
echo -e "\nTesting :: ./test-files/tester < test-files/test_push_synch.txt\n"
if timeout 20 ./test-files/tester < test-files/test_push_synch.txt >/dev/null 2>&1; then
echo -e " ${GREEN}Passed${NC}"
else
echo -e " ${RED}Failed${NC}"
fi
echo -e "\nTesting :: ./test-files/tester < test-files/test_pop_synch.txt\n"
if timeout 40 ./test-files/tester < test-files/test_pop_synch.txt >/dev/null 2>&1; then
echo -e " ${GREEN}Passed${NC}"
else
echo -e " ${RED}Failed${NC}"
fi
echo -e "\nTesting :: ./test-files/tester < test-files/test_both_synch.txt\n"
if timeout 60 ./test-files/tester < test-files/test_both_synch.txt >/dev/null 2>&1; then
echo -e " ${GREEN}Passed${NC}"
else
echo -e " ${RED}Failed${NC}"
fi
remake
#echo -e "\nTest cases for datapoint transfers"
echo -e "\nTesting :: ./client -n 1000 -p 5 -w 100 -h 20 -b 5\n"
N=1000
P=5
./client -n ${N} -p ${P} -w 100 -h 20 -b 5 >out.tst
if [ $(comm -12 <(sort out.tst) <(sort test-files/data1.txt) | wc -l) -eq $(cat test-files/data1.txt | wc -l) ]; then
echo -e " ${GREEN}Passed${NC}"
else
echo -e " ${RED}Failed${NC}"
fi
checkclean "f"
echo -e "\nTesting :: ./client -n 10000 -p 10 -w 100 -h 20 -b 30\n"
N=10000
P=10
./client -n ${N} -p ${P} -w 100 -h 20 -b 30 >out.tst
if [ $(comm -12 <(sort out.tst) <(sort test-files/data2.txt) | wc -l) -eq $(cat test-files/data2.txt | wc -l) ]; then
echo -e " ${GREEN}Passed${NC}"
else
echo -e " ${RED}Failed${NC}"
fi
checkclean "f"
remake
#echo -e "\nTest cases for csv file transfers"
echo -e "\nTesting :: ./client -w 100 -b 30 -f 1.csv; diff -sqwB BIMDC/1.csv received/1.csv\n"
./client -w 100 -b 30 -f 1.csv >/dev/null 2>&1
if test -f "received/1.csv"; then
if diff BIMDC/1.csv received/1.csv >/dev/null; then
echo -e " ${GREEN}Passed${NC}"
else
echo -e " ${RED}Failed${NC}"
fi
else
echo -e " ${ORANGE}No 1.csv in received/ directory${NC}"
fi
checkclean "f"
remake
#echo -e "\nTest cases for binary file transfers"
echo -e "\nTesting :: truncate -s 256K BIMDC/test.bin; ./client -w 100 -b 50 -f test.bin; diff -sqwB BIMDC/test.bin received/test.bin\n"
truncate -s 256K BIMDC/test.bin
./client -w 100 -b 50 -f test.bin >/dev/null 2>&1
if test -f "received/test.bin"; then
if diff BIMDC/test.bin received/test.bin >/dev/null; then
echo -e " ${GREEN}Passed${NC}"
else
echo -e " ${RED}Failed${NC}"
fi
else
echo -e " ${ORANGE}No test.bin in received/ directory${NC}"
fi
checkclean "f"
echo -e "\nTesting :: truncate -s 256K BIMDC/test.bin; ./client -w 100 -b 50 -m 8192 -f test.bin; diff -sqwB BIMDC/test.bin received/test.bin\n"
truncate -s 256K BIMDC/test.bin
./client -w 100 -b 50 -m 8192 -f test.bin >/dev/null 2>&1
if test -f "received/test.bin"; then
if diff BIMDC/test.bin received/test.bin >/dev/null; then
echo -e " ${GREEN}Passed${NC}"
else
echo -e " ${RED}Failed${NC}"
fi
else
echo -e " ${ORANGE}No test.bin in received/ directory${NC}"
fi
checkclean "f"
echo -e "\n"
exit 0