diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-04-30 17:23:00 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-04-30 17:23:00 +0300 |
commit | fdc979dafba2e12d2dc3d46de3b946d6943ed4a3 (patch) | |
tree | c31d046362988b682de3e9f661a466f6395ff66d | |
parent | d40a31f3e1a16e30b46edfd8e903c92afa3d7124 (diff) | |
download | ck-fdc979dafba2e12d2dc3d46de3b946d6943ed4a3.tar.gz ck-fdc979dafba2e12d2dc3d46de3b946d6943ed4a3.tar.bz2 ck-fdc979dafba2e12d2dc3d46de3b946d6943ed4a3.zip |
More test optimisations
-rwxr-xr-x | res/check_ck | 49 | ||||
-rw-r--r-- | tests/add | 26 | ||||
-rwxr-xr-x | tests/init | 9 |
3 files changed, 65 insertions, 19 deletions
diff --git a/res/check_ck b/res/check_ck index fbb5ef7..6e61e5c 100755 --- a/res/check_ck +++ b/res/check_ck @@ -23,15 +23,46 @@ function clear_tests { rm -rf $TEST_LOCATION } -if [ "$1" = "-c" ]; then - clear_tests - exit 0 +function run { + DIR=@BIN_TESTS_DIR@ + for i in $( ls $DIR ); do + ERROR="TEST "$i" FAILED:" + PASS="--[TEST "$i" PASSED]--\n" + source $DIR/$i + wait $! + done +} + +function print_help { + echo -e "ck test suite" + echo -e "run without flags to begin testing" + echo -e "\nflags:" + echo -e " -c, --clear\t\tremove test files" + echo -e " \t\t use it if the tests fail" + echo -e " -h, --help, *\t\tprint this" + exit +} + +if [[ $# -gt 1 ]]; then + print_help fi -DIR=@BIN_TESTS_DIR@ -for i in $( ls $DIR ); do - ERROR="TEST "$i" FAILED:" - PASS="--[TEST "$i" PASSED]--\n" - source $DIR/$i - wait $! +while [[ $# -gt 0 ]] +do + key="$1" + case $key in + -h | --help) + print_help + ;; + -c | --clear) + clear_tests + exit + ;; + *) # unknown option + print_help + exit + ;; + esac done + +run @@ -12,34 +12,44 @@ function run_add { exec $BIN/ck conf $BIN add $1 $BIN/$2 $3 $4 & wait $! + if [ $? -ne 0 ]; then + echo -e $ERROR" ck crashed." + exit 1 + fi + # check db - if [ $(sqlite3 $BIN/ckdb "select name from program where name = '"$1"'" | wc -l) -ne 1 ]; then - echo -e $ERROR$1" is not in the db" + if [ "$(sqlite3 $BIN/ckdb "select name from program where name = '$1'")" != "$1" ]; then + echo -e $ERROR $1" is not in the db." exit 1 fi - if [ $(sqlite3 $BIN/ckdb "select path from config where path = '"$BIN"/"$2"'" | wc -l) -ne 1 ]; then - echo -e $ERROR$2" is not in the db" + if [ "$(sqlite3 $BIN/ckdb "select path from config where path = '$BIN/$2'")" != "$BIN/$2" ]; then + echo -e $ERROR $2" is not in the db." exit 1 fi - FOLDER=vc - # check files + FOLDER=vc if [[ "$3" = "-s" || "$4" = "-s" ]]; then FOLDER=sec fi if [ ! -f $TEST_LOCATION/$FOLDER/$1_$2 ]; then - echo -e $ERROR$2" failed (add "$3" "$4")" + echo -e $ERROR$2" No move (add "$3" "$4")" exit 1 fi + + if [ ! -L $BIN/$2 ]; then + echo -e $ERROR$2" No symlink (add "$3" "$4")" + exit 1 + fi } run_add prog1 test1.conf -p +echo "" run_add prog2 test2.conf -s +echo "" run_add prog3 test3.conf -p -s - clear_tests echo -e $PASS @@ -8,13 +8,18 @@ mkdir $TEST_LOCATION/sec exec $BIN/ck conf $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec & wait $! +if [ $? -ne 0 ]; then + echo -e $ERROR" ck crashed." + exit 1 +fi + if [ ! -f $BIN/ckrc ]; then - echo -e $ERROR"Config file not created." + echo -e $ERROR" Config file not created." exit 1 fi if [ ! -f $BIN/ckdb ]; then - echo -e $ERROR"DB file not created." + echo -e $ERROR" DB file not created." exit 1 fi |