aboutsummaryrefslogtreecommitdiffstats
path: root/res/check_ck
blob: 6e61e5c1e21edb86e8df3b86c4c35d714f4230f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/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
}

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

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