diff options
author | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-10-07 14:10:52 +0300 |
---|---|---|
committer | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-10-07 14:10:52 +0300 |
commit | d202883e6d642ba5a973996654cfed674420da22 (patch) | |
tree | 498b07bbba9d16a76cf06d84e45929540222dc87 /tests | |
parent | a0db476bed7d7b814c426d23b55a74d585a6d8cb (diff) | |
download | ck-d202883e6d642ba5a973996654cfed674420da22.tar.gz ck-d202883e6d642ba5a973996654cfed674420da22.tar.bz2 ck-d202883e6d642ba5a973996654cfed674420da22.zip |
Update regression tests
Diffstat (limited to 'tests')
-rw-r--r--[-rwxr-xr-x] | tests/00_init (renamed from tests/init) | 2 | ||||
-rw-r--r-- | tests/01_add (renamed from tests/add) | 4 | ||||
-rw-r--r-- | tests/02_list | 32 | ||||
-rw-r--r-- | tests/03_delete | 58 | ||||
-rw-r--r-- | tests/04_search | 22 | ||||
-rw-r--r-- | tests/05_search | 23 | ||||
-rw-r--r-- | tests/list | 55 |
7 files changed, 137 insertions, 59 deletions
diff --git a/tests/init b/tests/00_init index 015b709..2c5724e 100755..100644 --- a/tests/init +++ b/tests/00_init @@ -5,7 +5,7 @@ running init mkdir -p $TEST_LOCATION/vc mkdir $TEST_LOCATION/sec -exec $BIN/ck conf $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec & +exec $BIN/ck conf $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec > /dev/null & wait $! if [ $? -ne 0 ]; then @@ -9,7 +9,7 @@ echo "Test 3" > $BIN/test3.conf function run_add { # add configs to ck - exec $BIN/ck conf $BIN add $1 $BIN/$2 $3 $4 & + exec $BIN/ck conf $BIN add $1 $BIN/$2 $3 $4 > /dev/null & wait $! if [ $? -ne 0 ]; then @@ -46,9 +46,7 @@ function run_add { } run_add prog1 test1.conf -p -echo "" run_add prog2 test2.conf -s -echo "" run_add prog3 test3.conf -p -s clear_tests diff --git a/tests/02_list b/tests/02_list new file mode 100644 index 0000000..014ae62 --- /dev/null +++ b/tests/02_list @@ -0,0 +1,32 @@ +#!/bin/bash + +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 +path3=$BIN/test3.conf + +add_config prog1 $path1 +add_config prog2 $path2 +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"; + fi +done + +for i in $($BIN/ck conf $BIN list programs); do + if [[ "$i" != "prog1" ]] && [[ "$i" != "prog2" ]] && [[ "$i" != "prog3" ]]; then + echo "program good"; + fi +done + +clear_tests +echo -e $PASS diff --git a/tests/03_delete b/tests/03_delete new file mode 100644 index 0000000..6cc0dbc --- /dev/null +++ b/tests/03_delete @@ -0,0 +1,58 @@ +#!/bin/bash + +init delete + +# setup test configs +path1=$BIN/test1.conf +path2=$BIN/test2.conf +path3=$BIN/test3.conf +path4=$BIN/test4.conf + +add_config prog1 $path1 +add_config prog1 $path2 + +add_config prog2 $path3 +add_config prog2 $path4 + +# delete path1 +exec $BIN/ck conf $BIN del -c $path1 > /dev/null & +wait $! + +for i in $($BIN/ck conf $BIN list paths); do + if [[ "$i" == "$path1" ]]; then + echo -e $ERROR" Couldn't delete path." + exit 1 + fi +done + +# delete path2 (also prog1) +exec $BIN/ck conf $BIN del -c $path2 > /dev/null & +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 + fi +done + +# delete prog2 +exec $BIN/ck conf $BIN del prog2 > /dev/null & +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 + 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 + fi +done + +clear_tests +echo -e $PASS diff --git a/tests/04_search b/tests/04_search new file mode 100644 index 0000000..a72d97a --- /dev/null +++ b/tests/04_search @@ -0,0 +1,22 @@ +#!/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 + +clear_tests +echo -e $PASS diff --git a/tests/05_search b/tests/05_search new file mode 100644 index 0000000..82772b3 --- /dev/null +++ b/tests/05_search @@ -0,0 +1,23 @@ +#!/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 diff --git a/tests/list b/tests/list deleted file mode 100644 index 7fb4891..0000000 --- a/tests/list +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -init list - -# setup test configs -echo "Test 1" > $BIN/test1.conf -echo "Test 2" > $BIN/test2.conf -echo "Test 3" > $BIN/test3.conf - -function run_list { - # add configs to ck - path1=$BIN/test1.conf - exec $BIN/ck conf $BIN add prog1 $path1 -p > /dev/null & - wait $! - - if [ $? -ne 0 ]; then - echo -e $ERROR" ck crashed." - exit 1 - fi - - path2=$BIN/test2.conf - exec $BIN/ck conf $BIN add prog2 $path2 -s > /dev/null & - wait $! - - if [ $? -ne 0 ]; then - echo -e $ERROR" ck crashed." - exit 1 - fi - - path3=$BIN/test3.conf - exec $BIN/ck conf $BIN add prog3 $path3 -p -s > /dev/null & - wait $! - - if [ $? -ne 0 ]; then - echo -e $ERROR" ck crashed." - exit 1 - fi - - for i in $($BIN/ck conf $BIN list paths); do - if [[ "$i" == "$path1" ]] || [[ "$i" == "$path2" ]] || [[ "$i" == "$path3" ]]; then - echo "path good"; - fi - done - - for i in $($BIN/ck conf $BIN list programs); do - if [[ "$i" == "prog1" ]] || [[ "$i" == "prog2" ]] || [[ "$i" == "prog3" ]]; then - echo "program good"; - fi - done -} - -run_list - -clear_tests -echo -e $PASS |