1#!/bin/bash
2
3cd `dirname $0`
4echo '-------build unit test----------'
5
6echo 'start a test http server'
7NODE=`which nodejs`
8
9if [ "$NODE" ]
10then
11  echo ''
12else
13NODE=`which node`
14fi
15
16echo 'node binary path: ' $NODE
17
18server=`ps -ef | grep http_test_server | grep -v grep`
19echo "check server: " $server
20if [ "$server" ]
21then
22  echo "server is on"
23else
24  echo "server is off, start it"
25  cd test/httpserver
26  npm i
27  nohup $NODE http_test_server.js &
28  cd -
29fi
30
31MAKE=make
32if command -v python > /dev/null ; then
33  MAKE="make -j $(python -c 'import multiprocessing as mp; print(int(mp.cpu_count()))')"
34fi
35
36echo $MAKE
37
38UT_BUILD_DIR=ut_build
39rm -rf $UT_BUILD_DIR
40mkdir $UT_BUILD_DIR
41cd $UT_BUILD_DIR
42cmake -DBUILD_FUNCTION_TESTS=OFF -DBUILD_UNIT_TESTS=ON -DENABLE_COVERAGE=ON ..
43$MAKE core_ut
44
45echo '------- run unit test -----------'
46
47ctest --verbose
48