#!/bin/bash BASE_DIR="${BASE_DIR:-/usr/local/src/kamailio-config-tests}" BIN_DIR="${BASE_DIR}/bin" LOG_DIR="${BASE_DIR}/log" RESULT_DIR="${BASE_DIR}/result" PROFILE="CE" DOMAIN="spce.test" LOGGER="" error_flag=0 function usage { echo "Usage: run_test.sh [-p PROFILE] [-c] [-t]" echo "-p CE|PRO default is CE" echo "-c skips configuration of the environment" echo "-t skips tests" echo "-g generate route flow graphs" echo "-h this help" } while getopts 'hctp:' opt; do case $opt in h) usage; exit 0;; c) SKIP=1;; t) TEST=1;; p) PROFILE=$OPTARG;; g) GRAPH="-G" esac done shift $(($OPTIND - 1)) if [[ $# -ne 0 ]]; then echo "Wrong number or arguments" usage exit 1 fi if [ "${PROFILE}" != "CE" ] && [ "${PROFILE}" != "PRO" ]; then echo "PROFILE ${PROFILE} unknown" usage exit 2 fi if [ -z $SKIP ]; then echo "$(date) - Setting config debug on" ${BIN_DIR}/config_debug.pl -p ${PROFILE} on ${DOMAIN} ngcpcfg apply echo "$(date) - Setting config debug on. Done." fi for i in ${LOG_DIR} ${RESULT_DIR}; do rm -rf $i done for t in $(find ${BASE_DIR}/scenarios/ -depth -maxdepth 1 -mindepth 1 -type d | sort); do echo "$(date) - Run[${PROFILE}]: $(basename $t) =================================================" if [ -z $TEST ]; then ${BIN_DIR}/check.sh ${GRAPH} -d ${DOMAIN} -p ${PROFILE} $(basename $t) if [ $? -ne 0 ]; then error_flag=1 fi fi echo "$(date) - =================================================================================" done if [ -z $SKIP ]; then echo "$(date) - Setting config debug off" ${BIN_DIR}/config_debug.pl -p ${PROFILE} off ${DOMAIN} ngcpcfg apply echo "$(date) - Setting config debug off. Done." fi exit $error_flag