preliminary testbed

master
KatolaZ 7 years ago
parent 8062fc1913
commit 231beb5c3f
  1. 61
      test/create_testbed.sh
  2. 22
      test/destroy_testbed.sh
  3. 56
      test/scorsh_functions
  4. 57
      test/scorsh_testsuite
  5. 27
      test/test_spec

@ -0,0 +1,61 @@
#!/bin/sh
##
## This script is part of the scorsh testbed. It must be executed by
## the scorsh_testsuite script
##
. ./scorsh_functions
### remove the directories if they exist already
[ -d ${REMOTE_REPO} ] && rm -rf ${REMOTE_REPO}
[ -d ${LOCAL_REPO} ] && rm -rf ${LOCAL_REPO}
### create the repository
git init --bare ${REMOTE_REPO}
check "[ $? -eq 0 ]" $0 "create_remote_repo"
### clone it
git clone ${REMOTE_REPO} ${LOCAL_REPO}
check "[ $? -eq 0 ]" $0 "clone_remote_repo"
### create the directory where scorsh will be cloned
mkdir ${SCORSH_REPO}
check "[ $? -eq 0 ]" $0 "create_scorsh_repo_folder"
### clone the scorsh repo
olddir=$(pwd)
cd ${SCORSH_REPO}
git clone ${SCORSH_URL} ./
check "[ $? -eq 0 ]" $0 "clone_scorsh_repo"
cd ${olddir}
### make the scorshd executable
olddir=$(pwd)
cd ${SCORSH_REPO}
make
check "[ $? -eq 0 ]" $0 "make_scorshd"
cd ${olddir}
### create the directory where the scorsh app will run
mkdir ${SCORSH_APP}
check "[ $? -eq 0 ]" $0 "create_scorsh_app_folder"
### create spool directory
mkdir "${SCORSH_APP}/spool"
check "[ -$? -eq 0 ]" $0 "create_spool_folder"
### configure the remote to be used with scorsh
cd ${REMOTE_REPO}
git config -f scorsh scorsh.spooldir $(realpath "${SCORSH_APP}/spool")
check "[ $? -eq 0 ]" $0 "config_remote_repo"
cd -
return_results

@ -0,0 +1,22 @@
#!/bin/sh
. ./scorsh_functions
### kill scroshd, if it's running
if [ -f "${SCORSH_APP}/scorshd.pid" ]; then
kill -9 $(cat "${SCORSH_APP}/scorshd.pid")
fi
### remove all the folders
rm -rf ${SCORSH_REPO}
rm -rf ${SCORSH_APP}
rm -rf ${REMOTE_REPO}
rm -rf ${LOCAL_REPO}
check "[ ! -d \"${SCORSH_REPO}\" ]" $0 "remove_scorsh_repo"
check "[ ! -d \"${SCORSH_APP}\" ]" $0 "remove_scorsh_app"
check "[ ! -d \"${REMOTE_REPO}\" ]" $0 "remove_remote_repo"
check "[ ! -d \"${LOCAL_REPO}\" ]" $0 "remove_local_repo"
return_results

@ -0,0 +1,56 @@
#!/bin/sh
STATUS_FILE=./.exit_status
## func
failed(){
TEST_NAME="$1"
TEST_SECTION="$2"
echo "[\033[31mFAILED\033[0m] -- ${TEST_NAME}:${TEST_SECTION} "
FAILED_TESTS=$((${FAILED_TESTS} + 1))
}
## func
passed(){
TEST_NAME="$1"
TEST_SECTION="$2"
echo "[\033[32mPASSED\033[0m] -- ${TEST_NAME}:${TEST_SECTION} "
PASSED_TESTS=$((${PASSED_TESTS} + 1))
}
## func
check(){
EXPR="$1"
TEST_NAME="$2"
TEST_SECTION="$3"
TOT_TESTS=$((${TOT_TESTS} + 1))
##echo "EXPR: ${EXPR}"
if $(echo ${EXPR}) ; then
passed ${TEST_NAME} ${TEST_SECTION}
else
failed ${TEST_NAME} ${TEST_SECTION}
fi
}
## func
report_results(){
echo -n "TOTAL_TESTS: ${TOT_TESTS} -- "
echo -n "\033[32mPASSED: ${PASSED_TESTS}\033[0m -- "
echo "\033[31mFAILED: ${FAILED_TESTS}\033[0m "
}
# func
return_results(){
echo "TOT_TESTS=${TOT_TESTS};PASSED_TESTS=${PASSED_TESTS};FAILED_TESTS=${FAILED_TESTS};">${STATUS_FILE}
}

@ -0,0 +1,57 @@
#!/bin/sh
####
##
## testsuite for SCORSH
##
if [ $# -lt 1 ]; then
echo "Usage: $0 <spec_file>"
exit 1
fi
. ./scorsh_functions
[ -f "$1" ] || ( echo "Unable to open file $1" && exit 2 )
. "$1"
trap cleanup 0 HUP INT TRAP TERM QUIT
## func
cleanup(){
## do stuff here
rm -rf ${SCORSH_REPO}
rm -rf ${SCORSH_APP}
rm -rf ${REMOTE_REPO}
rm -rf ${LOCAL_REPO}
echo "Exiting..."
}
## func
run_tests(){
for t in $TESTS; do
export PASSED_TESTS FAILED_TESTS TOT_TESTS
echo "\033[4;7;36m-+-+- running tests in $t -+-+-\033[0m"
$t
eval $(cat ${STATUS_FILE})
echo "\033[35m-------------------------------------------------------------\033[0m"
done
export PASSED_TESTS FAILED_TESTS TOT_TESTS
}
## main
export SCORSH_URL SCORSH_REPO SCORSH_APP REMOTE_REPO LOCAL_REPO
PASSED_TESTS=0
FAILED_TESTS=0
TOT_TESTS=0
run_tests
report_results

@ -0,0 +1,27 @@
##
## Definition of constants to be used by the testbed
##
## SCORSH_URL: URL of the git repo for scorsh
SCORSH_URL="http://github.com/dyne/scorsh"
## SCORSH_REPO: folder where the scorsh repo will be cloned
SCORSH_REPO=$(realpath "./scorsh/")
## SCORSH_APP: path where the scorsh app will be installed
SCORSH_APP=$(realpath "./scorsh_app/")
## REMOTE_REPO: path of the folder where the "remote" repo will be
## created
REMOTE_REPO=$(realpath "./testbed_remote.git")
## LOCAL_REPO: folder where REMOTE_REPO will be cloned
LOCAL_REPO=$(realpath "./testbed_repo")
TESTS="\
./create_testbed.sh \
./destroy_testbed.sh \
"
##./destroy_testbed.sh \
Loading…
Cancel
Save