test-all.sh 17.3 KB
Newer Older
1 2
#!/bin/bash

3 4
# set -x

5 6 7 8 9 10 11 12 13 14 15 16
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'

ulimit -c unlimited
tests_dir=`pwd`
IN_TDINTERNAL="community"

function stopTaosd {
17
  echo "Stop taosd"
18 19
  sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail'
  PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
20 21
  while [ -n "$PID" ]
  do
22 23
    pkill -TERM -x taosd
    sleep 1
24 25
    PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
  done
26 27 28
}

function dohavecore(){
29
  [ -d $corepath ] && corefile=`find $corepath -mmin 1` || return 1
30 31 32 33 34 35 36 37 38 39 40 41 42 43
  if [ -n "$corefile" ];then
    core_file=`echo $corefile|cut -d " " -f2`
    proc=`file $core_file|awk -F "execfn:"  '/execfn:/{print $2}'|tr -d \' |awk '{print $1}'|tr -d \,`
    echo 'taosd or taos has generated core'
    rm case.log
    if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]] && [[ $1 == 1 ]]; then
      cd ../../../
      tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz debug/build/bin/taosd debug/build/bin/tsim debug/build/lib/libtaos*so*
      if [[ $2 == 1 ]];then
        cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S"`
      else
        cd community
        cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" `
      fi
44
    else
45
      cd ../../
46
      if [[ $1 == 1 ]];then
47 48 49 50 51 52 53 54 55 56 57 58 59 60
        #tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz debug
        cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" `
      fi
    fi
    if [[ $1 == 1 ]];then
      echo '\n'|gdb $proc $core_file -ex "bt 10" -ex quit
      exit 8
    fi
  fi
}

function runSimCaseOneByOne {
  while read -r line; do
    if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
61 62
      case=`echo $line | grep sim$ |awk '{print $NF}'`
      start_time=`date +%s`
63 64 65
      date +%F\ %T | tee -a out.log
      if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
        echo -n $case
66 67 68
        ./test.sh -f $case > /dev/null 2>&1 \
            && ([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log  ||  echo -e "${GREEN} success${NC}" | tee -a out.log ) \
            || ( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log )  || \
69 70 71 72
        echo -e "${RED} failed${NC}" | tee -a out.log
      else
        echo -n $case
        ./test.sh -f $case > /dev/null 2>&1 && \
73 74
        ([ -f ../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log  ||  echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
        ([ -f ../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log )  || \
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
        echo -e "${RED} failed${NC}" | tee -a out.log
      fi
      out_log=`tail -1 out.log  `
      # if [[ $out_log =~ 'failed' ]];then
      #   exit 8
      # fi
      end_time=`date +%s`
      echo execution time of $case was `expr $end_time - $start_time`s. | tee -a out.log
    fi
  done < $1
}

function runSimCaseOneByOnefq {

  start=`sed -n "/$1-start/=" jenkins/basic.txt`
90
  end=`sed -n "/$1-end/=" jenkins/basic.txt`
91 92 93
  for ((i=$start;i<=$end;i++)) ; do
    line=`sed -n "$i"p jenkins/basic.txt`
    if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
P
plum-lihui 已提交
94 95
      #case=`echo $line | grep sim$ |awk '{print $NF}'`
      case=`echo $line | grep -o ".*\.sim" |awk '{print $NF}'`
T
tangfangzhi 已提交
96
      echo "$line    running ..."
97

98
      start_time=`date +%s`
99 100
      date +%F\ %T | tee -a out.log
      if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
P
plum-lihui 已提交
101 102 103
        #echo -n $case
        echo -n $line
        $line > case.log 2>&1 \
104 105 106
            && \
        ([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log  ||  echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
        ([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log )  || \
107 108
        ( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log )
      else
P
plum-lihui 已提交
109 110 111
        #echo -n $case
        echo -n $line
        $line > ../../sim/case.log 2>&1 && \
112 113
        ([ -f ../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log  ||  echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
        ([ -f ../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log )  || \
114 115
        ( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' &&  pwd && cat ../../sim/case.log )
      fi
116

117 118 119 120 121
      out_log=`tail -1 out.log  `
      if [[ $out_log =~ 'failed' ]];then
        rm case.log
        if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
          cp -r ../../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S"`
122
        else
123 124 125 126 127 128 129 130 131 132 133
          cp -r ../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" `
        fi
        dohavecore $2 1
        if [[ $2 == 1 ]];then
          exit 8
        fi
      fi
      end_time=`date +%s`
      echo execution time of $case was `expr $end_time - $start_time`s. | tee -a out.log
      dohavecore $2 1
    fi
134
  done
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
  rm -rf ../../../sim/case.log
  rm -rf ../../sim/case.log
}

function runPyCaseOneByOne {
  while read -r line; do
    if [[ $line =~ ^python.* ]]; then
      if [[ $line != *sleep* ]]; then
        if [[ $line =~ '-r' ]];then
          case=`echo $line|awk '{print $4}'`
        else
          case=`echo $line|awk '{print $NF}'`
        fi
        start_time=`date +%s`
        date +%F\ %T | tee -a pytest-out.log
        echo -n $case
        $line > /dev/null 2>&1 && \
          echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \
          echo -e "${RED} failed${NC}" | tee -a pytest-out.log
        end_time=`date +%s`
        out_log=`tail -1 pytest-out.log  `
        # if [[ $out_log =~ 'failed' ]];then
        #   exit 8
        # fi
        echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log
      else
        $line > /dev/null 2>&1
      fi
    fi
  done < $1
}

function runPyCaseOneByOnefq() {
  cd $tests_dir/pytest
  if [[ $1 =~ full ]] ; then
    start=1
    end=`sed -n '$=' fulltest.sh`
  else
    start=`sed -n "/$1-start/=" fulltest.sh`
    end=`sed -n "/$1-end/=" fulltest.sh`
  fi
  for ((i=$start;i<=$end;i++)) ; do
    line=`sed -n "$i"p fulltest.sh`
    if [[ $line =~ ^python.* ]]; then
      if [[ $line != *sleep* ]]; then
        if [[ $line =~ '-r' ]];then
          case=`echo $line|awk '{print $4}'`
        else
          case=`echo $line|awk '{print $NF}'`
        fi
        start_time=`date +%s`
        date +%F\ %T | tee -a pytest-out.log
        echo -n $case
        if [[ $1 =~ full ]] ; then
          line=$line" -s"
        fi
        $line > case.log 2>&1 && \
          echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \
193
          echo -e "${RED} failed${NC}" | tee -a pytest-out.log
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
        end_time=`date +%s`
        out_log=`tail -1 pytest-out.log  `
        if [[ $out_log =~ 'failed' ]];then
          cp -r ../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" `
          echo '=====================log===================== '
          cat case.log
          rm -rf case.log
          dohavecore $2 2
          if [[ $2 == 1 ]];then
            exit 8
          fi
        fi
        echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log
      else
        $line > /dev/null 2>&1
      fi
      dohavecore $2 2
    fi
212
  done
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
  rm -rf ../../sim/case.log
}

######################
# main entry
######################

unameOut="$(uname -s)"
case "${unameOut}" in
    Linux*)     OS=Linux;;
    Darwin*)    OS=Darwin;;
    CYGWIN*)    OS=Windows;;
    *)          OS=Unknown;;
esac

case "${OS}" in
    Linux*)     TAOSLIB=libtaos.so;;
    Darwin*)    TAOSLIB=libtaos.dylib;;
    Windows*)    TAOSLIB=taos.dll;;
    Unknown)          TAOSLIB="UNKNOWN:${unameOut}";;
esac

echo TAOSLIB is ${TAOSLIB}

totalFailed=0
totalPyFailed=0
totalJDBCFailed=0
totalUnitFailed=0
totalExampleFailed=0

if [ "${OS}" == "Linux" ]; then
    corepath=`grep -oP '.*(?=core_)' /proc/sys/kernel/core_pattern||grep -oP '.*(?=core-)' /proc/sys/kernel/core_pattern`
    if [ -z "$corepath" ];then
246 247 248
        [ -d /coredump ] || mkdir /coredump || echo -e "failed to mdkir /coredump"
        [ -d /coredump ] \
            && echo "/coredump/core_%e_%p_%t" > /proc/sys/kernel/core_pattern || echo "Permission denied"
249 250 251 252 253 254 255 256
      corepath="/coredump/"
    fi
fi

if [ "$2" != "jdbc" ] && [ "$2" != "python" ] && [ "$2" != "unit" ]  && [ "$2" != "example" ]; then
  echo "### run TSIM test case ###"
  cd $tests_dir/script

257
  [ -d ../../sim ] || mkdir ../../sim || echo -e "failed to mkdir ../../sim"
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
  [ -f out.log ] && rm -f out.log
  if [ "$1" == "cron" ]; then
    echo "### run TSIM regression test ###"
    runSimCaseOneByOne regressionSuite.sim
  elif [ "$1" == "full" ]; then
    echo "### run TSIM full test ###"
    runSimCaseOneByOne jenkins/basic.txt
  elif [ "$1" == "b1" ]; then
    echo "### run TSIM b1 test ###"
    runSimCaseOneByOnefq b1 0
    runSimCaseOneByOnefq b4 0
    runSimCaseOneByOnefq b7 0
  elif [ "$1" == "b2" ]; then
    echo "### run TSIM b2 test ###"
    runSimCaseOneByOnefq b2 0
    runSimCaseOneByOnefq b5 0
  elif [ "$1" == "b3" ]; then
    echo "### run TSIM b3 test ###"
    runSimCaseOneByOnefq b3 0
    runSimCaseOneByOnefq b6 0
  elif [ "$1" == "b1fq" ]; then
    echo "### run TSIM b1 test ###"
    runSimCaseOneByOnefq b1 1
  elif [ "$1" == "b2fq" ]; then
    echo "### run TSIM b2 test ###"
    runSimCaseOneByOnefq b2 1
  elif [ "$1" == "b3fq" ]; then
    echo "### run TSIM b3 test ###"
    runSimCaseOneByOnefq b3 1
  elif [ "$1" == "b4fq" ]; then
    echo "### run TSIM b4 test ###"
    runSimCaseOneByOnefq b4 1
  elif [ "$1" == "b5fq" ]; then
    echo "### run TSIM b5 test ###"
    runSimCaseOneByOnefq b5 1
  elif [ "$1" == "b6fq" ]; then
    echo "### run TSIM b6 test ###"
    runSimCaseOneByOnefq b6 1
  elif [ "$1" == "b7fq" ]; then
    echo "### run TSIM b7 test ###"
    runSimCaseOneByOnefq b7 1
  elif [ "$1" == "smoke" ] || [ -z "$1" ]; then
    echo "### run TSIM smoke test ###"
    runSimCaseOneByOne basicSuite.sim
  fi

  totalSuccess=`grep 'success' out.log | wc -l`
  totalBasic=`grep success out.log | grep Suite | wc -l`

  if [ "$totalSuccess" -gt "0" ]; then
    totalSuccess=`expr $totalSuccess - $totalBasic`
  fi

  echo -e "\n${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}"

  totalFailed=`grep 'failed\|fault' out.log | wc -l`
# echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}"

  if [ "$totalFailed" -ne "0" ]; then
    echo -e "\n${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}"

#  exit $totalFailed
  fi
fi

if [ "$2" != "sim" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ]  && [ "$2" != "example" ]; then
  echo "### run Python test case ###"

  cd $tests_dir

  if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
    cd ../..
  else
    cd ../
  fi

  TOP_DIR=`pwd`
  TAOSLIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1`
  if [[ "$TAOSLIB_DIR" == *"$IN_TDINTERNAL"* ]]; then
    LIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1|cut -d '/' -f 2,3,4,5`
  else
    LIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1|cut -d '/' -f 2,3,4`
  fi

  export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR:$LD_LIBRARY_PATH

  cd $tests_dir/pytest

  [ -f pytest-out.log ] && rm -f pytest-out.log

  if [ "$1" == "cron" ]; then
    echo "### run Python regression test ###"
    runPyCaseOneByOne regressiontest.sh
  elif [ "$1" == "full" ]; then
    echo "### run Python full test ###"
    runPyCaseOneByOne fulltest.sh
  elif [ "$1" == "pytest" ]; then
    echo "### run Python full test ###"
    runPyCaseOneByOne fulltest.sh
  elif [ "$1" == "pytestfq" ]; then
    echo "### run Python full test ###"
    runPyCaseOneByOnefq full 0
  elif [ "$1" == "p1" ]; then
    echo "### run Python_1 test ###"
    runPyCaseOneByOnefq p1 1
  elif [ "$1" == "p2" ]; then
    echo "### run Python_2 test ###"
    runPyCaseOneByOnefq p2 1
  elif [ "$1" == "p3" ]; then
    echo "### run Python_3 test ###"
368
    runPyCaseOneByOnefq p3 1
369 370 371 372 373 374 375 376 377 378
  elif [ "$1" == "p4" ]; then
    echo "### run Python_4 test ###"
    runPyCaseOneByOnefq p4 1
  elif [ "$1" == "b2" ] || [ "$1" == "b3" ]; then
    exit $(($totalFailed + $totalPyFailed))
  elif [ "$1" == "smoke" ] || [ -z "$1" ]; then
    echo "### run Python smoke test ###"
    runPyCaseOneByOne smoketest.sh
  fi

379 380 381 382 383
  if [ -f pytest-out.log ]; then
    totalPySuccess=`grep 'success' pytest-out.log | wc -l`
    if [ "$totalPySuccess" -gt "0" ]; then
        echo -e "\n${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}"
    fi
384

385 386 387 388 389 390 391
    totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l`
    if [ "$totalPyFailed" -ne "0" ]; then
        echo -e "\n${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}"
        #  exit $totalPyFailed
    fi
  else
    echo -e "pytest-out.log not found!"
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
  fi
fi


if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "unit" ]  && [ "$2" != "example" ] && [ "$1" == "full" ]; then
  echo "### run JDBC test cases ###"

  cd $tests_dir

  if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
    cd ../../
  else
    cd ../
  fi

  pwd
  cd debug/
409

410 411 412 413
  stopTaosd
  rm -rf /var/lib/taos/*
  nohup build/bin/taosd -c /etc/taos/ > /dev/null 2>&1 &
  sleep 30
414 415 416

  cd $tests_dir/../src/connector/jdbc

417 418 419 420 421 422 423 424 425
  mvn test > jdbc-out.log 2>&1
  tail -n 20 jdbc-out.log

  cases=`grep 'Tests run' jdbc-out.log | awk 'END{print $3}'`
  totalJDBCCases=`echo ${cases/%,}`
  failed=`grep 'Tests run' jdbc-out.log | awk 'END{print $5}'`
  JDBCFailed=`echo ${failed/%,}`
  error=`grep 'Tests run' jdbc-out.log | awk 'END{print $7}'`
  JDBCError=`echo ${error/%,}`
426

427 428 429 430 431 432
  totalJDBCFailed=`expr $JDBCFailed + $JDBCError`
  totalJDBCSuccess=`expr $totalJDBCCases - $totalJDBCFailed`

  if [ "$totalJDBCSuccess" -gt "0" ]; then
    echo -e "\n${GREEN} ### Total $totalJDBCSuccess JDBC case(s) succeed! ### ${NC}"
  fi
433

434 435 436 437 438 439 440
  if [ "$totalJDBCFailed" -ne "0" ]; then
    echo -e "\n${RED} ### Total $totalJDBCFailed JDBC case(s) failed! ### ${NC}"
  fi
  dohavecore 1
fi

if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ]  && [ "$2" != "example" ]  && [ "$1" == "full" ]; then
441
  echo "### run Unit tests ###"
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456

  stopTaosd
  cd $tests_dir

  if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
    cd ../../
  else
    cd ../
  fi

  pwd
  cd debug/build/bin
  rm -rf /var/lib/taos/*
  nohup ./taosd -c /etc/taos/ > /dev/null 2>&1 &
  sleep 30
457

458 459 460 461
  pwd
  ./queryTest > unittest-out.log 2>&1
  tail -n 20 unittest-out.log

462
  totalUnitTests=`grep "Running" unittest-out.log | awk '{print $3}'`
463 464 465 466 467 468
  totalUnitSuccess=`grep 'PASSED' unittest-out.log | awk '{print $4}'`
  totalUnitFailed=`expr $totalUnitTests - $totalUnitSuccess`

  if [ "$totalUnitSuccess" -gt "0" ]; then
    echo -e "\n${GREEN} ### Total $totalUnitSuccess Unit test succeed! ### ${NC}"
  fi
469

470 471 472 473 474 475 476
  if [ "$totalUnitFailed" -ne "0" ]; then
    echo -e "\n${RED} ### Total $totalUnitFailed Unit test failed! ### ${NC}"
  fi
  dohavecore 1
fi

if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ] && [ "$1" == "full" ]; then
477
  echo "### run Example tests ###"
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493

  stopTaosd
  cd $tests_dir

  if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
    cd ../../
  else
    cd ../
  fi

  pwd
  cd debug/build/bin
  rm -rf /var/lib/taos/*
  nohup ./taosd -c /etc/taos/ > /dev/null 2>&1 &
  echo "sleeping for 30 seconds"
  #sleep 30
494

495 496 497 498 499 500 501 502 503 504 505 506
  cd $tests_dir
  echo "current dir: "
  pwd
  cd examples/c
  echo "building applications"
  make > /dev/null
  totalExamplePass=0

  echo "Running tests"
  ./apitest > /dev/null 2>&1
  if [ $? != "0" ]; then
    echo "apitest failed"
507
    totalExampleFailed=`expr $totalExampleFailed + 1`
508 509 510
  else
    echo "apitest pass"
    totalExamplePass=`expr $totalExamplePass + 1`
511
  fi
512 513 514 515

  ./prepare 127.0.0.1 > /dev/null 2>&1
  if [ $? != "0" ]; then
    echo "prepare failed"
516
    totalExampleFailed=`expr $totalExampleFailed + 1`
517 518 519 520 521 522 523 524
  else
    echo "prepare pass"
    totalExamplePass=`expr $totalExamplePass + 1`
  fi

  ./subscribe -test > /dev/null 2>&1
  if [ $? != "0" ]; then
    echo "subscribe failed"
525
    totalExampleFailed=`expr $totalExampleFailed + 1`
526 527 528 529 530 531 532 533
  else
    echo "subscribe pass"
    totalExamplePass=`expr $totalExamplePass + 1`
  fi

  yes |./asyncdemo 127.0.0.1 test 1000 10 > /dev/null 2>&1
  if [ $? != "0" ]; then
    echo "asyncdemo failed"
534
    totalExampleFailed=`expr $totalExampleFailed + 1`
535 536 537 538 539 540 541 542
  else
    echo "asyncdemo pass"
    totalExamplePass=`expr $totalExamplePass + 1`
  fi

  ./demo 127.0.0.1 > /dev/null 2>&1
  if [ $? != "0" ]; then
    echo "demo failed"
543
    totalExampleFailed=`expr $totalExampleFailed + 1`
544 545 546 547
  else
    echo "demo pass"
    totalExamplePass=`expr $totalExamplePass + 1`
  fi
548

549 550 551
  if [ "$totalExamplePass" -gt "0" ]; then
    echo -e "\n${GREEN} ### Total $totalExamplePass examples succeed! ### ${NC}"
  fi
552

553 554 555 556 557 558 559 560 561 562 563
  if [ "$totalExampleFailed" -ne "0" ]; then
    echo -e "\n${RED} ### Total $totalExampleFailed examples failed! ### ${NC}"
  fi

  if [ "${OS}" == "Linux" ]; then
    dohavecore 1
  fi
fi


exit $(($totalFailed + $totalPyFailed + $totalJDBCFailed + $totalUnitFailed + $totalExampleFailed))