Repository navigation
Expand file tree
/
Copy pathgradeMe.sh
More file actions
executable file
·144 lines (126 loc) · 3.85 KB
/
Copy pathgradeMe.sh
File metadata and controls
executable file
·144 lines (126 loc) · 3.85 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
#!/bin/bash
# Author Yejiajie geniusye@geniusye.com
# 2nd Version Modifier Zhouyuwei 11302010067@fudan.edu.cn
# 3rd Version Modifier Jixiaofeng 11302010002@fudan.edu.cn
###################################################
# delete all the created file and kill the process
###################################################
function DoReap(){
rm -rf proxy.log
rm -rf tmp >& /dev/null
killall proxy
# kill all the ./proxy process
#ID=`ps -ef | grep "./proxy" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
#for id in $ID
#do
# kill -9 $id >& /dev/null
# #echo "killed $id"
#done
}
score=0;
totalScore=60
partAScore=30
##########################
# Compile the lab
##########################
make clean >& /dev/null
make > /dev/null
#echo $?
if [[ $? != 0 ]]; then
echo ""
echo "[ * _ * ]Compile Error"
echo ""
popd >& /dev/null
exit 1
fi;
DoReap
mkdir -p tmp
export http_proxy=localhost:8005
./proxy 8005 &
echo "Start Grading the lab..."
echo ''
##################################
# Part A: a single-thread proxy
#
# 1. check a simple web page
# 2. check a large page
# 3. check the log
##################################
echo '#####################################'
echo '# Part A - A single-thread proxy'
echo '#####################################'
echo ''
echo "Check for a simple web page"
wget http://www.tcs.fudan.edu.cn/~liy/courses/dm2/index.shtml -O tmp/test1-file -o wget.log
diff tmp/test1-file trace/test1-trace >& tmp/test1-result
if [ -s tmp/test1-result ]; then
echo 'Fail'
else
let score+=10
echo "OK"
fi;
echo "Check for a large file"
wget http://www.jwc.fudan.edu.cn/picture/article/67/b4/a4/193dd881400ea6ed9c84c1a107a3/40e48939-92fc-4bc6-a459-d15ac73aa647.pdf -O tmp/test2-file -o wget.log
diff tmp/test2-file trace/test2-trace >& tmp/test2-result
if [ -s tmp/test2-result ]; then
echo "Fail"
else
let score+=10
echo 'OK'
fi;
echo "Check for the log file"
grep -e " [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\} CST: 127.0.0.1 http://www.tcs.fudan.edu.cn/~liy/courses/dm2/index.shtml" proxy.log -n | tail -n 1 > tmp/test3-result
if [ -s tmp/test3-result ]; then
let score+=5
fi;
grep -e " [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\} CST: 127.0.0.1 http://www.jwc.fudan.edu.cn/picture/article/67/b4/a4/193dd881400ea6ed9c84c1a107a3/40e48939-92fc-4bc6-a459-d15ac73aa647.pdf" proxy.log -n | tail -n 1 >> tmp/test3-result
if [ -s tmp/test3-result ]; then
let score+=5
echo "OK"
else
echo 'Fail'
fi;
echo "# Part A Score: $score/$partAScore"
echo ''
echo ''
####################################
# Part B: a multiple-thread proxy
#
# check for multiple thread
####################################
echo '#####################################'
echo '# Part B - A multiple-thread proxy'
echo '#####################################'
echo ''
echo "Check for a normal web page"
wget https://www.kernel.org/pub/linux/kernel/people/geoff/cell/ps3-linux-docs/CellProgrammingTutorial/BasicsOfSIMDProgramming.html -O tmp/test4-file -o wget.log
diff tmp/test4-file trace/test4-trace >& tmp/test4-result
if [ -s tmp/test4-result ]; then
echo 'Fail'
else
let score+=10
echo "OK"
fi;
echo "Check the multiple request"
let multiple_thread=0
wget http://research.microsoft.com/pubs/192937/Transactions-APSIPA.pdf -O tmp/test5_0-file -o wget.log & >& /dev/null
sleep 1
#start a second request
wget http://www.jwc.fudan.edu.cn/picture/article/67/b7/6e/31c481df49bda3863d89cf80079b/782a3ab9-0bd6-4868-86f2-a035974cf260.pdf -O tmp/test5-file -o wget.log
ID=`ps -ef | grep "http://research.microsoft.com/pubs/192937/Transactions-APSIPA.pdf" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
for id in $ID
do
let multiple_thread=1
#echo "kill the $id"
kill -9 $id >& /dev/null
done
diff tmp/test5-file trace/test5-trace >& tmp/test5-result
if [ -s tmp/test5-result ] || [ $multiple_thread -eq 0 ]; then
echo 'Fail'
else
let score+=20
echo "OK"
fi;
echo "# Total Score: $score / $totalScore"
echo ""
#DoReap