2019-03-26 07:25:22 +00:00
|
|
|
#!/bin/bash
|
2019-12-07 09:43:00 +00:00
|
|
|
|
2020-01-25 03:58:20 +00:00
|
|
|
drogon_ctl_exec=`pwd`/build/drogon_ctl/drogon_ctl
|
|
|
|
echo ${drogon_ctl_exec}
|
2019-03-26 07:25:22 +00:00
|
|
|
cd build/examples/
|
|
|
|
|
2020-03-16 16:54:30 +00:00
|
|
|
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
|
|
|
|
|
2019-03-26 07:25:22 +00:00
|
|
|
#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
|
2019-10-03 02:17:54 +00:00
|
|
|
sed -i -e "s/\"threads_num.*$/\"threads_num\": 0\,/" config.example.json
|
2019-03-26 07:25:22 +00:00
|
|
|
|
|
|
|
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
|
2019-04-07 04:15:02 +00:00
|
|
|
|
|
|
|
sleep 4
|
|
|
|
|
2019-04-08 08:37:24 +00:00
|
|
|
echo "Test http requests and responses."
|
2019-03-26 07:25:22 +00:00
|
|
|
./webapp_test
|
|
|
|
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2020-01-25 03:58:20 +00:00
|
|
|
echo "Error in testing http requests"
|
2019-03-26 07:25:22 +00:00
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2019-04-06 15:06:38 +00:00
|
|
|
#Test WebSocket
|
2019-04-08 08:37:24 +00:00
|
|
|
echo "Test the WebSocket"
|
2019-04-06 15:06:38 +00:00
|
|
|
./websocket_test -t
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2020-01-25 03:58:20 +00:00
|
|
|
echo "Error in testing WebSocket"
|
2019-04-07 04:15:02 +00:00
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Test pipelining
|
2019-04-08 08:37:24 +00:00
|
|
|
echo "Test the pipelining"
|
2019-04-07 04:15:02 +00:00
|
|
|
./pipelining_test
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2020-01-25 03:58:20 +00:00
|
|
|
echo "Error in testing pipelining"
|
2019-04-06 15:06:38 +00:00
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2019-03-30 16:27:12 +00:00
|
|
|
killall -9 webapp
|
|
|
|
|
|
|
|
#Test drogon_ctl
|
2019-04-08 08:37:24 +00:00
|
|
|
echo "Test the drogon_ctl"
|
2019-04-06 15:06:38 +00:00
|
|
|
rm -rf drogon_test
|
|
|
|
|
2020-01-25 03:58:20 +00:00
|
|
|
${drogon_ctl_exec} create project drogon_test
|
2019-03-30 16:27:12 +00:00
|
|
|
|
|
|
|
cd drogon_test/controllers
|
|
|
|
|
2020-01-25 03:58:20 +00:00
|
|
|
${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
|
2019-03-30 16:27:12 +00:00
|
|
|
|
2019-12-07 09:43:00 +00:00
|
|
|
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
|
2019-03-30 16:27:12 +00:00
|
|
|
echo "Failed to create controllers"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2019-12-07 09:43:00 +00:00
|
|
|
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
|
2019-10-06 01:43:08 +00:00
|
|
|
echo "Failed to create controllers"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2019-03-30 16:27:12 +00:00
|
|
|
cd ../filters
|
|
|
|
|
2020-01-25 03:58:20 +00:00
|
|
|
${drogon_ctl_exec} create filter Test::TestFilter
|
2019-03-30 16:27:12 +00:00
|
|
|
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ ! -f "Test_TestFilter.h" -o ! -f "Test_TestFilter.cc" ]; then
|
2019-03-30 16:27:12 +00:00
|
|
|
echo "Failed to create filters"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2019-05-05 07:43:17 +00:00
|
|
|
cd ../plugins
|
|
|
|
|
2020-01-25 03:58:20 +00:00
|
|
|
${drogon_ctl_exec} create plugin Test::TestPlugin
|
2019-05-05 07:43:17 +00:00
|
|
|
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ ! -f "Test_TestPlugin.h" -o ! -f "Test_TestPlugin.cc" ]; then
|
2019-05-05 07:43:17 +00:00
|
|
|
echo "Failed to create plugins"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2019-03-30 16:27:12 +00:00
|
|
|
cd ../build
|
2020-03-16 16:54:30 +00:00
|
|
|
cmake .. $cmake_gen
|
2019-03-30 16:27:12 +00:00
|
|
|
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2019-03-30 16:27:12 +00:00
|
|
|
echo "Error in testing"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2020-03-16 16:54:30 +00:00
|
|
|
$make_program $make_flags
|
2019-03-30 16:27:12 +00:00
|
|
|
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2019-03-30 16:27:12 +00:00
|
|
|
echo "Error in testing"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ ! -f "drogon_test" ]; then
|
2019-03-30 16:27:12 +00:00
|
|
|
echo "Failed to build drogon_test"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2019-03-31 10:30:06 +00:00
|
|
|
cd ../../
|
|
|
|
rm -rf drogon_test
|
|
|
|
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ "$1" = "-t" ]; then
|
|
|
|
#unit testing
|
2019-08-16 15:41:03 +00:00
|
|
|
cd ../
|
2019-12-07 09:43:00 +00:00
|
|
|
echo "Unit testing"
|
2020-03-16 16:54:30 +00:00
|
|
|
$make_program $make_flags test
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Error in unit testing"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
echo "Test database"
|
2019-08-16 15:41:03 +00:00
|
|
|
./orm_lib/tests/db_test
|
2019-12-07 09:43:00 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2019-08-16 15:41:03 +00:00
|
|
|
echo "Error in testing"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-03-30 16:27:12 +00:00
|
|
|
echo "Everything is ok!"
|
2019-03-26 07:25:22 +00:00
|
|
|
exit 0
|