aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt10
-rwxr-xr-xsrc/tests/init23
-rwxr-xr-xtest_ck8
3 files changed, 39 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 508dd3c..a0dca2c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,8 @@
cmake_minimum_required (VERSION 3.5.6)
project(ck C)
-
# Set project directories
-set(PROJECT_SOURCE_DIR ./src)
+set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
# Set source code locations
set(ckBin_src ${PROJECT_SOURCE_DIR}/ck.c)
set(ckLib_src
@@ -42,3 +41,10 @@ add_library (ckLib SHARED
add_executable(ck ${ckBin_src})
target_link_libraries (ck ckLib)
target_link_libraries (ck ${SQLITE3_LIBRARIES})
+
+# copy test file
+set(PROJECT_TEST_DIR ${PROJECT_SOURCE_DIR}/tests)
+set(BIN_TEST_DIR ${CMAKE_BINARY_DIR}/tests)
+set(PROJECT_TESTING_GROUNDS ${CMAKE_BINARY_DIR}/test_files)
+configure_file(${PROJECT_TEST_DIR}/init ${BIN_TEST_DIR}/init @ONLY)
+configure_file(test_ck test_ck @ONLY)
diff --git a/src/tests/init b/src/tests/init
new file mode 100755
index 0000000..2091bdc
--- /dev/null
+++ b/src/tests/init
@@ -0,0 +1,23 @@
+#!/bin/bash
+BIN=/build/ck
+
+TEST_LOCATION=@PROJECT_TESTING_GROUNDS@
+mkdir -p $TEST_LOCATION/vc
+mkdir $TEST_LOCATION/sec
+
+exec $BIN/ck init $TEST_LOCATION/vc $TEST_LOCATION/sec > /dev/null 2>&1 &
+wait $!
+
+if [ ! -f ~/.ck/ckrc ]; then
+ echo -e $ERROR"Config file not created."
+ exit 1
+fi
+
+if [ ! -f ~/.ck/ckdb ]; then
+ echo -e $ERROR"DB file not created."
+ exit 1
+fi
+
+rm -rf $HOME/.ck
+rm -rf $TEST_LOCATION
+echo -e $PASS
diff --git a/test_ck b/test_ck
new file mode 100755
index 0000000..e222c3c
--- /dev/null
+++ b/test_ck
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+DIR=@BIN_TEST_DIR@
+for i in $( ls $DIR ); do
+ ERROR="TEST "$i" FAILED:\n"
+ PASS="TEST "$i" PASSED\n"
+ source $DIR/$i
+done