forked from drogonframework/drogon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·166 lines (131 loc) · 3.35 KB
/
test.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env bash
drogon_ctl_exec=`pwd`/build/drogon_ctl/drogon_ctl
echo ${drogon_ctl_exec}
cd build/examples/
make_program=make
make_flags=''
cmake_gen=''
parallel=1
# simulate ninja's parallelism
case $(nproc) in
1)
parallel=$(( $(nproc) + 1 ))
;;
2)
parallel=$(( $(nproc) + 1 ))
;;
*)
parallel=$(( $(nproc) + 2 ))
;;
esac
if [ -f /bin/ninja ]; then
make_program=ninja
cmake_gen='-G Ninja'
else
make_flags="$make_flags -j$parallel"
fi
#Make webapp run as a daemon
sed -i -e "s/\"run_as_daemon.*$/\"run_as_daemon\": true\,/" config.example.json
sed -i -e "s/\"relaunch_on_error.*$/\"relaunch_on_error\": true\,/" config.example.json
sed -i -e "s/\"threads_num.*$/\"threads_num\": 0\,/" config.example.json
sed -i -e "s/\"use_brotli.*$/\"use_brotli\": true\,/" config.example.json
if [ ! -f "webapp" ]; then
echo "Build failed"
exit -1
fi
if [ ! -f "webapp_test" ]; then
echo "Build failed"
exit -1
fi
killall -9 webapp
./webapp
sleep 4
echo "Test http requests and responses."
./webapp_test
if [ $? -ne 0 ]; then
echo "Error in testing http requests"
exit -1
fi
#Test WebSocket
echo "Test the WebSocket"
./websocket_test -t
if [ $? -ne 0 ]; then
echo "Error in testing WebSocket"
exit -1
fi
#Test pipelining
echo "Test the pipelining"
./pipelining_test
if [ $? -ne 0 ]; then
echo "Error in testing pipelining"
exit -1
fi
killall -9 webapp
#Test drogon_ctl
echo "Test the drogon_ctl"
rm -rf drogon_test
${drogon_ctl_exec} create project drogon_test
cd drogon_test/controllers
${drogon_ctl_exec} create controller Test::SimpleCtrl
${drogon_ctl_exec} create controller -h Test::HttpCtrl
${drogon_ctl_exec} create controller -w Test::WebsockCtrl
${drogon_ctl_exec} create controller SimpleCtrl
${drogon_ctl_exec} create controller -h HttpCtrl
${drogon_ctl_exec} create controller -w WebsockCtrl
if [ ! -f "Test_SimpleCtrl.h" -o ! -f "Test_SimpleCtrl.cc" -o ! -f "Test_HttpCtrl.h" -o ! -f "Test_HttpCtrl.cc" -o ! -f "Test_WebsockCtrl.h" -o ! -f "Test_WebsockCtrl.cc" ]; then
echo "Failed to create controllers"
exit -1
fi
if [ ! -f "SimpleCtrl.h" -o ! -f "SimpleCtrl.cc" -o ! -f "HttpCtrl.h" -o ! -f "HttpCtrl.cc" -o ! -f "WebsockCtrl.h" -o ! -f "WebsockCtrl.cc" ]; then
echo "Failed to create controllers"
exit -1
fi
cd ../filters
${drogon_ctl_exec} create filter Test::TestFilter
if [ ! -f "Test_TestFilter.h" -o ! -f "Test_TestFilter.cc" ]; then
echo "Failed to create filters"
exit -1
fi
cd ../plugins
${drogon_ctl_exec} create plugin Test::TestPlugin
if [ ! -f "Test_TestPlugin.h" -o ! -f "Test_TestPlugin.cc" ]; then
echo "Failed to create plugins"
exit -1
fi
cd ../views
echo "Hello, world!" >> hello.csp
cd ../build
cmake .. $cmake_gen
if [ $? -ne 0 ]; then
echo "Error in testing"
exit -1
fi
$make_program $make_flags
if [ $? -ne 0 ]; then
echo "Error in testing"
exit -1
fi
if [ ! -f "drogon_test" ]; then
echo "Failed to build drogon_test"
exit -1
fi
cd ../../
rm -rf drogon_test
if [ "$1" = "-t" ]; then
#unit testing
cd ../
echo "Unit testing"
$make_program $make_flags test
if [ $? -ne 0 ]; then
echo "Error in unit testing"
exit -1
fi
echo "Test database"
./orm_lib/tests/db_test
if [ $? -ne 0 ]; then
echo "Error in testing"
exit -1
fi
fi
echo "Everything is ok!"
exit 0