aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xres/check_ck12
-rw-r--r--tests/00_init13
-rw-r--r--tests/01_add15
-rw-r--r--tests/02_list9
-rw-r--r--tests/03_delete11
-rw-r--r--tests/04_search2
-rw-r--r--tests/05_search23
7 files changed, 25 insertions, 60 deletions
diff --git a/res/check_ck b/res/check_ck
index d4683ce..437b39b 100755
--- a/res/check_ck
+++ b/res/check_ck
@@ -24,8 +24,7 @@ function add_config {
wait $!
if [ $? -ne 0 ]; then
- echo -e $ERROR" ck crashed."
- exit 1
+ err "ck crashed."
fi
}
@@ -56,6 +55,13 @@ function regression_tests {
done
}
+function err {
+ echo -e "$ERROR $1"
+ clear_tests
+ exit 1
+}
+
+
function run {
unit_tests
regression_tests
@@ -68,7 +74,7 @@ function print_help {
echo -e " -u, --unit\t\trun only the unit tests"
echo -e " -r, --regression\trun only the regression tests"
echo -e " -c, --clear\t\tremove test files"
- echo -e " \t\t use it if the tests fail"
+ echo -e " \t\t use if the tests crush unexpectedly"
echo -e " -h, --help, *\t\tprint this"
exit
}
diff --git a/tests/00_init b/tests/00_init
index 2c5724e..9ea2f1c 100644
--- a/tests/00_init
+++ b/tests/00_init
@@ -9,21 +9,16 @@ exec $BIN/ck conf $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec > /dev/null &
wait $!
if [ $? -ne 0 ]; then
- echo -e $ERROR" ck crashed."
- exit 1
+ err "ck crashed."
fi
if [ ! -f $BIN/ckrc ]; then
- echo -e $ERROR" Config file not created."
- exit 1
+ err "Config file not created."
fi
if [ ! -f $BIN/ckdb ]; then
- echo -e $ERROR" DB file not created."
- exit 1
+ err "DB file not created."
fi
-rm $BIN/ckrc
-rm $BIN/ckdb
-rm -rf $TEST_LOCATION
+clear_tests 2&>1 /dev/null
echo -e $PASS
diff --git a/tests/01_add b/tests/01_add
index 15ff2b0..74c9558 100644
--- a/tests/01_add
+++ b/tests/01_add
@@ -13,19 +13,16 @@ function run_add {
wait $!
if [ $? -ne 0 ]; then
- echo -e $ERROR" ck crashed."
- exit 1
+ err "ck crashed."
fi
# check 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
+ err "$1 is not in the db."
fi
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
+ err "$2 is not in the db."
fi
# check files
@@ -35,13 +32,11 @@ function run_add {
fi
if [ ! -f $TEST_LOCATION/$FOLDER/$1/$2 ]; then
- echo -e $ERROR$2" No move (add "$3" "$4")"
- exit 1
+ err "$2 No move (add $3 $4)"
fi
if [ ! -L $BIN/$2 ]; then
- echo -e $ERROR$2" No symlink (add "$3" "$4")"
- exit 1
+ err "$2 No symlink (add $3 $4)"
fi
}
diff --git a/tests/02_list b/tests/02_list
index 014ae62..35bf1ee 100644
--- a/tests/02_list
+++ b/tests/02_list
@@ -2,11 +2,6 @@
init list
-# 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
path1=$BIN/test1.conf
path2=$BIN/test2.conf
@@ -18,13 +13,13 @@ add_config prog3 $path3
for i in $($BIN/ck conf $BIN list paths); do
if [[ "$i" != "$path1" ]] && [[ "$i" != "$path2" ]] && [[ "$i" != "$path3" ]]; then
- echo "path good";
+ err "Listing paths"
fi
done
for i in $($BIN/ck conf $BIN list programs); do
if [[ "$i" != "prog1" ]] && [[ "$i" != "prog2" ]] && [[ "$i" != "prog3" ]]; then
- echo "program good";
+ err "Listing programs"
fi
done
diff --git a/tests/03_delete b/tests/03_delete
index 6cc0dbc..ee1cdd6 100644
--- a/tests/03_delete
+++ b/tests/03_delete
@@ -20,7 +20,7 @@ wait $!
for i in $($BIN/ck conf $BIN list paths); do
if [[ "$i" == "$path1" ]]; then
- echo -e $ERROR" Couldn't delete path."
+ err "Couldn't delete path."
exit 1
fi
done
@@ -31,8 +31,7 @@ wait $!
for i in $($BIN/ck conf $BIN list programs); do
if [[ "$i" == "prog1" ]]; then
- echo -e $ERROR" Removing all configs should delete the correspondig program."
- exit 1
+ err "Removing all configs should delete the correspondig program."
fi
done
@@ -42,15 +41,13 @@ wait $!
for i in $($BIN/ck conf $BIN list paths); do
if [[ "$i" == "$path3" ]] || [[ "$i" == "$path4" ]]; then
- echo -e $ERROR" Removing the program should delete all it's configs."
- exit 1
+ err "Removing the program should delete all it's configs."
fi
done
for i in $($BIN/ck conf $BIN list programs); do
if [[ "$i" == "prog1" ]]; then
- echo -e $ERROR" Couldn't remove program."
- exit 1
+ err "Couldn't remove program."
fi
done
diff --git a/tests/04_search b/tests/04_search
index a72d97a..9f3d2e5 100644
--- a/tests/04_search
+++ b/tests/04_search
@@ -15,7 +15,7 @@ add_config prog3 $path4 "search-term"
# delete path1
if [[ $($BIN/ck conf $BIN search search-term | wc -l) != 4 ]]; then
- echo -e $ERROR" search failed."
+ err "search failed."
fi
clear_tests
diff --git a/tests/05_search b/tests/05_search
deleted file mode 100644
index 82772b3..0000000
--- a/tests/05_search
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-init search
-
-# setup test configs
-path1=$BIN/test1.conf
-path2=$BIN/test2.conf
-path3=$BIN/test3.conf
-path4=$BIN/test4.conf
-
-add_config prog1 $path1 "search-term"
-add_config prog1 $path2 "search-term"
-add_config prog2 $path3 "search-term"
-add_config prog3 $path4 "search-term"
-
-# delete path1
-if [[ $($BIN/ck conf $BIN search search-term | wc -l) != 4 ]]; then
- echo -e $ERROR" search failed."
-fi
-done
-
-clear_tests
-echo -e $PASS