aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-04-30 12:48:13 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-04-30 12:48:13 +0300
commitb9c36055e855163e5bf2fc065d8f7ee7b9efa64c (patch)
treee06a1eb4e7c8c6dbc59f334d3615c7bac3145f44
parent584a9b642a689b6dccc5c66a518b9fc91a6fa733 (diff)
downloadck-b9c36055e855163e5bf2fc065d8f7ee7b9efa64c.tar.gz
ck-b9c36055e855163e5bf2fc065d8f7ee7b9efa64c.tar.bz2
ck-b9c36055e855163e5bf2fc065d8f7ee7b9efa64c.zip
Update tests
-rwxr-xr-xres/check_ck30
-rw-r--r--tests/add108
-rwxr-xr-xtests/init4
3 files changed, 67 insertions, 75 deletions
diff --git a/res/check_ck b/res/check_ck
index fc80bd2..fbb5ef7 100755
--- a/res/check_ck
+++ b/res/check_ck
@@ -1,9 +1,37 @@
#!/bin/bash
+BIN=@CMAKE_BINARY_DIR@
+TEST_LOCATION=@PROJECT_TESTING_GROUNDS@
+
+function running {
+ echo "--[TESTING $1]--"
+}
+
+function init {
+ running $1
+ mkdir -p $TEST_LOCATION/vc
+ mkdir $TEST_LOCATION/sec
+
+ exec $BIN/ck conf $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec > /dev/null &
+ wait $!
+}
+
+function clear_tests {
+ rm $BIN/ckrc
+ rm $BIN/ckdb
+ rm $BIN/test*.conf
+ rm -rf $TEST_LOCATION
+}
+
+if [ "$1" = "-c" ]; then
+ clear_tests
+ exit 0
+fi
+
DIR=@BIN_TESTS_DIR@
for i in $( ls $DIR ); do
ERROR="TEST "$i" FAILED:"
- PASS="TEST "$i" PASSED"
+ PASS="--[TEST "$i" PASSED]--\n"
source $DIR/$i
wait $!
done
diff --git a/tests/add b/tests/add
index e65cc77..77ff759 100644
--- a/tests/add
+++ b/tests/add
@@ -1,81 +1,45 @@
#!/bin/bash
-BIN=@CMAKE_BINARY_DIR@
-# initialize
-TEST_LOCATION=@PROJECT_TESTING_GROUNDS@
-mkdir -p $TEST_LOCATION/vc
-mkdir $TEST_LOCATION/sec
-
-exec $BIN/ck conf $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec &
-wait $!
+init add
# setup test configs
echo "Test 1" > $BIN/test1.conf
echo "Test 2" > $BIN/test2.conf
echo "Test 3" > $BIN/test3.conf
-# add configs to ck
-exec $BIN/ck conf $BIN add prog1 $BIN/test1.conf -p &
-wait $!
-
-# check db
-if [ $(sqlite3 $BIN/ckdb "select name from program where name = 'prog1'" | wc -l) -ne 1 ]; then
- echo -e $ERROR"prog1 is not in the db"
- exit 1
-fi
-
-if [ $(sqlite3 $BIN/ckdb "select path from config where path = '"$BIN"/test1.conf'" | wc -l) -ne 1 ]; then
- echo -e $ERROR"test1.conf is not in the db"
- exit 1
-fi
-
-# check files
-if [ ! -f $TEST_LOCATION/vc/prog1_test1.conf ]; then
- echo -e $ERROR"test1.conf failed (add -p)"
- exit 1
-fi
-
-# repeat
-exec $BIN/ck conf $BIN add prog2 $BIN/test2.conf -s &
-wait $!
-
-if [ ! -f $TEST_LOCATION/sec/prog2_test2.conf ]; then
- echo -e $ERROR"test2.conf failed (add -s)"
- exit 1
-fi
-
-if [ $(sqlite3 $BIN/ckdb "select name from program where name = 'prog2'" | wc -l) -ne 1 ]; then
- echo -e $ERROR"prog2 is not in the db"
- exit 1
-fi
-
-if [ $(sqlite3 $BIN/ckdb "select path from config where path = '"$BIN"/test2.conf'" | wc -l) -ne 1 ]; then
- echo -e $ERROR"test2.conf is not in the db"
- exit 1
-fi
-
-exec $BIN/ck conf $BIN add prog3 $BIN/test3.conf -p -s &
-wait $!
-
-if [ ! -f $TEST_LOCATION/sec/prog3_test3.conf ]; then
- echo -e $ERROR"test3.conf failed (add -p -s)"
- exit 1
-fi
-
-if [ $(sqlite3 $BIN/ckdb "select name from program where name = 'prog3'" | wc -l) -ne 1 ]; then
- echo -e $ERROR"prog3 is not in the db"
- exit 1
-fi
-
-if [ $(sqlite3 $BIN/ckdb "select path from config where path = '"$BIN"/test3.conf'" | wc -l) -ne 1 ]; then
- echo -e $ERROR"test3.conf is not in the db"
- exit 1
-fi
-
-rm $BIN/ckrc
-rm $BIN/ckdb
-rm $BIN/test1.conf
-rm $BIN/test2.conf
-rm $BIN/test3.conf
-rm -rf $TEST_LOCATION
+function run_add {
+ # add configs to ck
+ exec $BIN/ck conf $BIN add $1 $BIN/$2 $3 $4 &
+ wait $!
+
+ # 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"
+ 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"
+ exit 1
+ fi
+
+ FOLDER=vc
+
+ # check files
+ 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")"
+ exit 1
+ fi
+}
+
+run_add prog1 test1.conf -p
+run_add prog2 test2.conf -s
+run_add prog3 test3.conf -p -s
+
+
+clear_tests
echo -e $PASS
diff --git a/tests/init b/tests/init
index 5dedc21..44a8143 100755
--- a/tests/init
+++ b/tests/init
@@ -1,7 +1,7 @@
#!/bin/bash
-BIN=@CMAKE_BINARY_DIR@
-TEST_LOCATION=@PROJECT_TESTING_GROUNDS@
+running init
+
mkdir -p $TEST_LOCATION/vc
mkdir $TEST_LOCATION/sec