From 79f00f6de07b427ce2fd700c5c5e8b8b84280ca1 Mon Sep 17 00:00:00 2001 From: iaind Date: Nov 11 2012 16:45:59 +0000 Subject: runtests.sh: This checks to see if tests/0_lib/functions.sh exists and if not, exits with status $FAIL. FAIL is defined in functions.sh so the test would exit 0 if functions.sh is missing. Added code to define FAIL=1 before testing for the existence of functions.sh. tests/0_lib/functions.sh : The function t_Process is supposed to filter files begining with _ so that they don't get executed. This wasn't working for tests/p_openssh/_helper_sshd_user_login.expect which was being run and failed under cerain circumstances. This line [[ "${f}" =~ readme|^_ ]] && continue; does the filtering, however, ${f} is for example ./tests/p_openssh/_helper_sshd_user_login.expect which doesn't match ^_. I added a basename to the line [[ "$(basename ${f})" =~ readme|^_ ]] && continue; which fixes this. tests/p_sqlite/sqlite_1-create_db_table.sh This would fail if the test is run more than once without removing the test db/table with Error: table tf_table already exists Added a line to drop the table if it exists prior to running the create table test. --- diff --git a/runtests.sh b/runtests.sh index d3da693..6f4fe6b 100755 --- a/runtests.sh +++ b/runtests.sh @@ -12,6 +12,9 @@ export SKIP_QA_HARNESS=$? LIB_FUNCTIONS='./tests/0_lib/functions.sh' +# Just in case $LIB_FUNCTIONS doesn't exist +export FAIL=1 + [ -f $LIB_FUNCTIONS ] && source $LIB_FUNCTIONS || { echo -e "\n[+] `date` -> Unable to source functions library. Cannot continue\n"; exit $FAIL; } # case insensitive filename matching diff --git a/tests/0_lib/functions.sh b/tests/0_lib/functions.sh index b112151..2a1beb4 100755 --- a/tests/0_lib/functions.sh +++ b/tests/0_lib/functions.sh @@ -53,7 +53,7 @@ function t_Process while read -u 7 f do # skip files named readme or those that start with an _ - [[ "${f}" =~ readme|^_ ]] && continue; + [[ "$(basename ${f})" =~ readme|^_ ]] && continue; # handy tip: chmod -x to disable individual test scripts. [ -x ${f} ] && ${f} diff --git a/tests/p_sqlite/sqlite_1-create_db_table.sh b/tests/p_sqlite/sqlite_1-create_db_table.sh index 85e2b71..2dbd733 100755 --- a/tests/p_sqlite/sqlite_1-create_db_table.sh +++ b/tests/p_sqlite/sqlite_1-create_db_table.sh @@ -3,6 +3,7 @@ t_Log "Running $0 - check that sqlite can create database and tables." +sqlite3 /tmp/tf_test.db 'drop table if exists tf_table;' sqlite3 /tmp/tf_test.db 'create table tf_table(text, id INTEGER);' t_CheckExitStatus $?