#!/bin/bash BIN=$(realpath @CMAKE_BINARY_DIR@) # solve symlink problems TEST_LOCATION=$(realpath @PROJECT_TESTING_GROUNDS@) # used in regression tests function running { echo "--[TESTING $1]--" } # used in regression tests 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 unit_tests { echo -e "################################" echo -e "########## Unit Tests ##########" echo -e "################################" ./ck-test } function regression_tests { echo -e "######################################" echo -e "########## Regression Tests ##########" echo -e "######################################" 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 run { unit_tests regression_tests } function print_help { echo -e "ck test suite" echo -e "use without flags to run all tests" echo -e "\nflags:" 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 " -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 ;; -u | --unit) unit_tests exit ;; -r | --regression) regression_tests exit ;; *) # unknown option print_help exit ;; esac done run