winlin

add utest framework gtest

不能预览此文件类型
@@ -28,6 +28,9 @@ tools/ccache-3.1.9.zip @@ -28,6 +28,9 @@ tools/ccache-3.1.9.zip
28 1.st.arm.Makefile.patch 28 1.st.arm.Makefile.patch
29 st编译脚本补丁,允许用户指定cc编译器。 29 st编译脚本补丁,允许用户指定cc编译器。
30 30
  31 +gtest-1.6.0.zip
  32 + google单元测试框架。
  33 +
31 links: 34 links:
32 ffmpeg: 35 ffmpeg:
33 http://ffmpeg.org/ 36 http://ffmpeg.org/
@@ -53,4 +56,7 @@ links: @@ -53,4 +56,7 @@ links:
53 openssl: 56 openssl:
54 http://www.openssl.org/ 57 http://www.openssl.org/
55 http://www.openssl.org/source/openssl-1.0.1f.tar.gz 58 http://www.openssl.org/source/openssl-1.0.1f.tar.gz
  59 + gtest:
  60 + https://code.google.com/p/googletest
  61 + https://code.google.com/p/googletest/downloads/list
56 62
@@ -405,3 +405,16 @@ if [ $SRS_RESEARCH = YES ]; then @@ -405,3 +405,16 @@ if [ $SRS_RESEARCH = YES ]; then
405 (cd research/ffempty && make && mv ffempty ../../${SRS_OBJS}/research) 405 (cd research/ffempty && make && mv ffempty ../../${SRS_OBJS}/research)
406 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi 406 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi
407 fi 407 fi
  408 +
  409 +#####################################################################################
  410 +# build utest code
  411 +#####################################################################################
  412 +if [ $SRS_UTEST = YES ]; then
  413 + mkdir -p ${SRS_OBJS}/utest
  414 +
  415 + (cd research/hls && make && mv ts_info ../../${SRS_OBJS}/research)
  416 + ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/hls failed, ret=$ret"; exit $ret; fi
  417 +
  418 + (cd research/ffempty && make && mv ffempty ../../${SRS_OBJS}/research)
  419 + ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi
  420 +fi
@@ -16,6 +16,7 @@ SRS_SSL=RESERVED @@ -16,6 +16,7 @@ SRS_SSL=RESERVED
16 SRS_FFMPEG=RESERVED 16 SRS_FFMPEG=RESERVED
17 SRS_HTTP=RESERVED 17 SRS_HTTP=RESERVED
18 SRS_RESEARCH=RESERVED 18 SRS_RESEARCH=RESERVED
  19 +SRS_UTEST=RESERVED
19 20
20 # TODO: remove the default to yes. 21 # TODO: remove the default to yes.
21 SRS_HLS=YES 22 SRS_HLS=YES
@@ -23,6 +24,7 @@ SRS_SSL=YES @@ -23,6 +24,7 @@ SRS_SSL=YES
23 SRS_FFMPEG=YES 24 SRS_FFMPEG=YES
24 SRS_HTTP=YES 25 SRS_HTTP=YES
25 SRS_RESEARCH=NO 26 SRS_RESEARCH=NO
  27 +SRS_UTEST=NO
26 28
27 ##################################################################################### 29 #####################################################################################
28 # parse options 30 # parse options
@@ -46,12 +48,14 @@ do @@ -46,12 +48,14 @@ do
46 --with-ffmpeg) SRS_FFMPEG=YES ;; 48 --with-ffmpeg) SRS_FFMPEG=YES ;;
47 --with-http) SRS_HTTP=YES ;; 49 --with-http) SRS_HTTP=YES ;;
48 --with-research) SRS_RESEARCH=YES ;; 50 --with-research) SRS_RESEARCH=YES ;;
  51 + --with-utest) SRS_UTEST=YES ;;
49 52
50 --without-ssl) SRS_SSL=NO ;; 53 --without-ssl) SRS_SSL=NO ;;
51 --without-hls) SRS_HLS=NO ;; 54 --without-hls) SRS_HLS=NO ;;
52 --without-ffmpeg) SRS_FFMPEG=NO ;; 55 --without-ffmpeg) SRS_FFMPEG=NO ;;
53 --without-http) SRS_HTTP=NO ;; 56 --without-http) SRS_HTTP=NO ;;
54 --without-research) SRS_RESEARCH=NO ;; 57 --without-research) SRS_RESEARCH=NO ;;
  58 + --without-utest) SRS_UTEST=NO ;;
55 59
56 *) 60 *)
57 echo "$0: error: invalid option \"$option\"" 61 echo "$0: error: invalid option \"$option\""
@@ -78,12 +82,14 @@ if [ $help = yes ]; then @@ -78,12 +82,14 @@ if [ $help = yes ]; then
78 srs will call the http hooks, such as: on_connect. 82 srs will call the http hooks, such as: on_connect.
79 --with-ffmpeg enable transcoding with ffmpeg. 83 --with-ffmpeg enable transcoding with ffmpeg.
80 --with-research build the research tools. 84 --with-research build the research tools.
  85 + --with-utest build the utest for srs.
81 86
82 --without-ssl disable rtmp complex handshake. 87 --without-ssl disable rtmp complex handshake.
83 --without-hls disable hls, rtmp streaming only. 88 --without-hls disable hls, rtmp streaming only.
84 --without-http disable http, http hooks callback. 89 --without-http disable http, http hooks callback.
85 --without-ffmpeg disable the ffmpeg transcoding feature. 90 --without-ffmpeg disable the ffmpeg transcoding feature.
86 --without-research do not build the research tools. 91 --without-research do not build the research tools.
  92 + --without-utest do not build the utest for srs.
87 93
88 END 94 END
89 exit 0 95 exit 0
@@ -113,6 +119,10 @@ if [ $SRS_RESEARCH = RESERVED ]; then @@ -113,6 +119,10 @@ if [ $SRS_RESEARCH = RESERVED ]; then
113 echo "you must specifies the research, see: ./configure --help"; 119 echo "you must specifies the research, see: ./configure --help";
114 __check_ok=NO 120 __check_ok=NO
115 fi 121 fi
  122 +if [ $SRS_UTEST = RESERVED ]; then
  123 + echo "you must specifies the utest, see: ./configure --help";
  124 + __check_ok=NO
  125 +fi
116 if [ $__check_ok = NO ]; then 126 if [ $__check_ok = NO ]; then
117 exit 1; 127 exit 1;
118 fi 128 fi
@@ -45,11 +45,17 @@ if [ $SRS_SSL = YES ]; then @@ -45,11 +45,17 @@ if [ $SRS_SSL = YES ]; then
45 SrsLibrtmpSampleEntry="ssl" 45 SrsLibrtmpSampleEntry="ssl"
46 fi 46 fi
47 47
  48 +# utest make entry, (cd utest; make)
  49 +SrsUtestMakeEntry="@echo -e \"\$(YELLOW)ignore utest for it's disabled\$(BLACK)\""
  50 +if [ $SRS_UTEST = YES ]; then
  51 + SrsUtestMakeEntry="(cd utest; make)"
  52 +fi
  53 +
48 # makefile 54 # makefile
49 echo "generate Makefile" 55 echo "generate Makefile"
50 SRS_MAKEFILE="Makefile" 56 SRS_MAKEFILE="Makefile"
51 cat << END > ${SRS_MAKEFILE} 57 cat << END > ${SRS_MAKEFILE}
52 -.PHONY: default help clean server bandwidth librtmp librtmp-sample _prepare_dir 58 +.PHONY: default help clean server bandwidth librtmp librtmp-sample utest _prepare_dir
53 59
54 # linux shell color support. 60 # linux shell color support.
55 RED="\\\\e[31m" 61 RED="\\\\e[31m"
@@ -57,26 +63,29 @@ GREEN="\\\\e[32m" @@ -57,26 +63,29 @@ GREEN="\\\\e[32m"
57 YELLOW="\\\\e[33m" 63 YELLOW="\\\\e[33m"
58 BLACK="\\\\e[0m" 64 BLACK="\\\\e[0m"
59 65
60 -default: server bandwidth librtmp librtmp-sample 66 +default: server bandwidth librtmp librtmp-sample utest
61 @echo -e "\$(GREEN)" 67 @echo -e "\$(GREEN)"
62 @echo -e "build success:" 68 @echo -e "build success:"
63 @echo -e " server: ./objs/srs, the srs server" 69 @echo -e " server: ./objs/srs, the srs server"
64 @echo -e " bandwidth: ./objs/bandwidth, the bandwidth test client" 70 @echo -e " bandwidth: ./objs/bandwidth, the bandwidth test client"
65 @echo -e " librtmp: ./objs/include, ./objs/lib, the srs-librtmp library" 71 @echo -e " librtmp: ./objs/include, ./objs/lib, the srs-librtmp library"
66 @echo -e " librtmp-sample: ./research/librtmp, the srs-librtmp client sample" 72 @echo -e " librtmp-sample: ./research/librtmp, the srs-librtmp client sample"
  73 + @echo -e " utest: ./objs/srs_utest, the utest for srs"
67 @echo -e "\$(BLACK)" 74 @echo -e "\$(BLACK)"
68 75
69 help: 76 help:
70 - @echo "Usage: make <help>|<clean>|<server>|<bandwidth>|<librtmp>|<librtmp-sample>" 77 + @echo "Usage: make <help>|<clean>|<server>|<bandwidth>|<librtmp>|<librtmp-sample>|<utest>"
71 @echo " help display this help menu" 78 @echo " help display this help menu"
72 @echo " clean cleanup project" 79 @echo " clean cleanup project"
73 @echo " server build the srs(simple rtmp server) over st(state-threads)" 80 @echo " server build the srs(simple rtmp server) over st(state-threads)"
74 @echo " bandwidth build the bandwidth test client tool." 81 @echo " bandwidth build the bandwidth test client tool."
75 @echo " librtmp build the client publish/play library." 82 @echo " librtmp build the client publish/play library."
76 @echo " librtmp-sample build the srs-librtmp sample" 83 @echo " librtmp-sample build the srs-librtmp sample"
  84 + @echo " utest build the utest for srs"
77 85
78 clean: 86 clean:
79 - (rm -f Makefile; cd ${SRS_OBJS}; rm -rf srs bandwidth Makefile *.hpp src st_*_load research include lib) 87 + (rm -f Makefile; cd ${SRS_OBJS}; rm -rf srs bandwidth Makefile *.hpp srs_utest)
  88 + (cd ${SRS_OBJS}; rm -rf src research include lib utest)
80 (cd research/librtmp; make clean) 89 (cd research/librtmp; make clean)
81 90
82 server: _prepare_dir 91 server: _prepare_dir
@@ -96,6 +105,11 @@ librtmp-sample: @@ -96,6 +105,11 @@ librtmp-sample:
96 (cd research/librtmp; make ${SrsLibrtmpSampleEntry}) 105 (cd research/librtmp; make ${SrsLibrtmpSampleEntry})
97 @echo "srs-librtmp sample build success" 106 @echo "srs-librtmp sample build success"
98 107
  108 +utest:
  109 + @echo "build the utest for srs"
  110 + ${SrsUtestMakeEntry}
  111 + @echo "utest for srs build success"
  112 +
99 # the ./configure will generate it. 113 # the ./configure will generate it.
100 _prepare_dir: 114 _prepare_dir:
101 @mkdir -p ${SRS_OBJS} 115 @mkdir -p ${SRS_OBJS}