This repository has been archived by the owner on Jun 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun.sh
executable file
·90 lines (75 loc) · 1.68 KB
/
run.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
#!/usr/bin/env bash
set -e
PROJECT_DIR=`pwd`
function usage()
{
echo "usage: run.sh <command> [<args>]"
echo
echo "Command list:"
echo " help print the help info"
echo " build build the system"
echo " test run unit test"
echo
echo "Command 'run.sh <command> -h' will print help for subcommands."
}
#####################
## build
#####################
function run_build() {
pushd ${PROJECT_DIR}
mkdir -p ${PROJECT_DIR}/cmake-build-debug
mkdir -p ${PROJECT_DIR}/output
cd ${PROJECT_DIR}/cmake-build-debug
cmake .. -DCMAKE_INSTALL_PREFIX=${PROJECT_DIR}/output -DCMAKE_BUILD_TYPE=Debug
make -j8 && make install
popd
}
#####################
## unit test
#####################
TEST_DIR=cmake-build-debug/src
function unit_test()
{
echo "===========" $1 "==========="
./$TEST_DIR/$1
if [ $? -ne 0 ]; then
echo "TEST FAILED!!!"
exit 1
fi
}
function run_test() {
unit_test env_test
unit_test coding_test
unit_test background_worker_test
unit_test random_test
unit_test log_writer_test
unit_test log_manager_test
unit_test raft_service_test
unit_test raft_timer_test
unit_test raft_task_executor_test
# unit_test replicated_log_test
}
####################################################################
if [ $# -eq 0 ]; then
usage
exit 0
fi
cmd=$1
case $cmd in
help)
usage
;;
build)
shift
run_build $*
;;
test)
shift
run_test $*
;;
*)
echo "ERROR: unknown command $cmd"
echo
usage
exit -1
esac