summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@src.gnome.org>2003-04-01 21:41:06 +0000
committerDodji Seketeli <dodji@src.gnome.org>2003-04-01 21:41:06 +0000
commit2be8913dcd95577023913e7a1bc331a10b70d5ac (patch)
treef154483bd508ab6c9123c883268353a21ef13690
parentbbd278d70458559b8aa323e0494d2673898caf7d (diff)
downloadlibcroco-2be8913dcd95577023913e7a1bc331a10b70d5ac.tar.gz
Went forward on the testctl front.
Can now run non regression tests and get simple ok/ko report. Dodji.
-rw-r--r--tests/test2-main.c6
-rw-r--r--tests/test3-main.c6
-rw-r--r--tests/test4-main.c7
-rw-r--r--tests/test5-main.c8
-rw-r--r--tests/test6-main.c6
-rw-r--r--tests/test7-main.c6
-rwxr-xr-xtests/testctl202
7 files changed, 149 insertions, 92 deletions
diff --git a/tests/test2-main.c b/tests/test2-main.c
index ee255d1..1b060e9 100644
--- a/tests/test2-main.c
+++ b/tests/test2-main.c
@@ -635,11 +635,7 @@ main (int argc, char ** argv)
status = test_cr_parser_parse (options.files_list[0]) ;
- if (status == CR_OK)
- {
- fprintf (stdout,"OK\n") ;
- }
- else
+ if (status != CR_OK)
{
fprintf (stdout,"KO\n") ;
}
diff --git a/tests/test3-main.c b/tests/test3-main.c
index ee0bd3a..6c8d77f 100644
--- a/tests/test3-main.c
+++ b/tests/test3-main.c
@@ -635,11 +635,7 @@ main (int argc, char ** argv)
status = test_cr_parser_parse (options.files_list[0]) ;
- if (status == CR_OK)
- {
- fprintf (stdout,"OK\n") ;
- }
- else
+ if (status != CR_OK)
{
fprintf (stdout,"KO\n") ;
}
diff --git a/tests/test4-main.c b/tests/test4-main.c
index ddcfb94..91a5757 100644
--- a/tests/test4-main.c
+++ b/tests/test4-main.c
@@ -146,11 +146,8 @@ main (int argc, char ** argv)
status = test_cr_parser_parse (options.files_list[0]) ;
- if (status == CR_OK)
- {
- g_print ("\nOK\n") ;
- }
- else
+
+ if (status != CR_OK)
{
g_print ("\nKO\n") ;
}
diff --git a/tests/test5-main.c b/tests/test5-main.c
index c8e0a69..1912027 100644
--- a/tests/test5-main.c
+++ b/tests/test5-main.c
@@ -273,13 +273,9 @@ main (int argc, char ** argv)
status = test_sel_eng (options.files_list[0]) ;
- if (status == CR_OK)
+ if (status != CR_OK)
{
- g_printerr ("\nOK\n") ;
- }
- else
- {
- g_printerr ("\nKO\n") ;
+ g_print ("\nKO\n") ;
}
return 0 ;
diff --git a/tests/test6-main.c b/tests/test6-main.c
index 24ec53b..4e534bf 100644
--- a/tests/test6-main.c
+++ b/tests/test6-main.c
@@ -80,11 +80,7 @@ main (int argc, char ** argv)
status = test_cr_parser_parse () ;
- if (status == CR_OK)
- {
- g_print ("\nOK\n") ;
- }
- else
+ if (status != CR_OK)
{
g_print ("\nKO\n") ;
}
diff --git a/tests/test7-main.c b/tests/test7-main.c
index 627c162..24271bd 100644
--- a/tests/test7-main.c
+++ b/tests/test7-main.c
@@ -143,11 +143,7 @@ main (int argc, char **argv)
status = test_cr_lay_eng_build_annotated_tree () ;
- if (status == CR_OK)
- {
- g_print ("\nOK\n") ;
- }
- else
+ if (status != CR_OK)
{
g_print ("\nKO\n") ;
}
diff --git a/tests/testctl b/tests/testctl
index e674109..8ba6806 100755
--- a/tests/testctl
+++ b/tests/testctl
@@ -5,6 +5,8 @@
#libcroco, saves their result, diff them
#against a set of reference results and
#displays OK/KO.
+#To use it as a tester, the best way is
+#just to run 'testctl run' and see the result.
####################################
#the directory that contains the tests
@@ -17,10 +19,14 @@ TEST_PROG_LIST=
TEST_INPUT_DIR=test-inputs
#the reference test output dirs.
-TEST_OUTPUT_DIR=test-outputs
+TEST_OUT_REF_DIR=test-output-refs
#temporary test result dir
-TEMP_RES_DIR_NAME=tmp-test-results
+TEST_OUTPUT_DIR=test-outputs
+
+ERROR_REPORT_FILE=tests-error.log
+COMMAND_LIST=
+COMMAND=
EGREP=`which egrep`
if test "empty$EGREP" = "empty" ; then
@@ -28,8 +34,69 @@ if test "empty$EGREP" = "empty" ; then
echo "Please, install it first"
fi
-COMMAND_LIST=
-COMMAND=
+DIFF=`which diff`
+if test "empty$DIFF" = "empty" ; then
+ echo "You don't have the diff program installed"
+ echo "Please, install is first"
+fi
+
+display_usage ()
+{
+ echo ""
+ echo "usage: $0 [options] <command>"
+ echo ""
+ echo "where options are:"
+ echo "===================="
+ echo "-h|--help displays this help"
+ echo ""
+ echo "commands are:"
+ echo "=============="
+ echo "run run the tests and display their result"
+ echo "mkref run the tests but saves their output as a reference"
+ echo "mkcleanup removes the tmp directories that may have been created"
+}
+
+
+parse_command_line ()
+{
+ if test "empty$1" = "empty" ; then
+ display_usage ;
+ exit -1
+ fi
+
+ while true ; do
+ arg=$1
+
+ if test "empty$arg" = "empty" ; then
+ break ;
+ fi
+
+ case "$arg" in
+ -h|--help)
+ display_usage $@
+ exit 0
+ ;;
+
+ -*)
+ echo "$0: unknown option: $arg"
+ display_usage $@
+ exit 0
+ ;;
+
+ run|mkref|mkcleanup)
+ COMMAND_LIST=$arg
+ shift
+ break ;
+ ;;
+
+ *)
+ display_usage $@
+ exit 0
+ ;;
+ esac
+ done
+}
+
#builds the list of available test functions.
build_tests_list ()
@@ -54,102 +121,107 @@ run_test_prog ()
OUTPUT_DIR=
OUTPUT_SUFFIX=
+ TEST_INPUT_LIST=
for TEST_INPUT in `ls -1 $HERE/$TEST_INPUT_DIR | egrep ^${TEST_PROG}\([\.0-9]\)+\css\$` ; do
- echo "test input: $TEST_INPUT"
TEST_INPUT_LIST="$TEST_INPUT_LIST $TEST_INPUT"
done
- if test "$REFERENCE" = "yes" ; then
- OUTPUT_DIR=$HERE/$TEST_OUTPUT_DIR
- OUTPUT_SUFFIX=.ref
+ if test "$REFERENCE" = "yes" ; then
+ OUTPUT_DIR=$HERE/$TEST_OUT_REF_DIR
+ OUTPUT_SUFFIX=.out
+
+ if test ! -d $HERE/$OUTPUT_DIR ; then
+ mkdir $HERE/$OUTPUT_DIR
+ fi
else
- if test ! -d $HERE/$TEMP_RES_DIR_NAME/ ; then
- echo "creating tmp directory $$HERE/$TEMP_RES_DIR_NAME ..."
- mkdir $HERE/$TEMP_RES_DIR_NAME ;
+ if test ! -d $HERE/$TEST_OUTPUT_DIR/ ; then
+ echo "creating tmp directory $$HERE/$TEST_OUTPUT_DIR ..."
+ mkdir $HERE/$TEST_OUTPUT_DIR ;
echo "done"
fi
- OUTPUT_DIR=$HERE/$TEMP_RES_DIR_NAME
+ OUTPUT_DIR=$HERE/$TEST_OUTPUT_DIR
OUTPUT_SUFFIX=.out
fi
if test "empty$TEST_INPUT_LIST" != "empty" ; then
for TEST_INPUT in $TEST_INPUT_LIST ; do
- echo "$HERE/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT > $OUTPUT_DIR/${TEST_INPUT}${OUTPUT_SUFFIX}"
+ #launch the test with the test input file, and save the output.
+ echo "executing $HERE/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT > $OUTPUT_DIR/${TEST_INPUT}${OUTPUT_SUFFIX} ..."
$HERE/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT > $OUTPUT_DIR/${TEST_INPUT}${OUTPUT_SUFFIX}
+ echo "done"
+ echo ""
done
+ else
+ echo "executing $HERE/$TEST_PROG > $OUTPUT_DIR/${TEST_INPUT}${OUTPUT_SUFFIX} ..."
+ $HERE/$TEST_PROG > $OUTPUT_DIR/${TEST_PROG}${OUTPUT_SUFFIX}
+ echo "done"
fi
}
cleanup_tests ()
{
- if test -d $HERE/$TEMP_RES_DIR_NAME ; then
- echo "removing $HERE/$TEMP_RES_DIR_NAME"
- rm -rf
+ if test -d $HERE/$TEST_OUTPUT_DIR ; then
+ echo "removing $HERE/$TEST_OUTPUT_DIR"
+ rm -rf $HERE/$TEST_OUTPUT_DIR/*
fi
}
-
-display_usage ()
-{
- echo ""
- echo "usage: $0 [options] <command>"
- echo ""
- echo "where options are:"
- echo "===================="
- echo "-h|--help displays this help"
- echo ""
- echo "commands are:"
- echo "=============="
- echo "run run the tests and display their result"
- echo "mkref run the tests but saves their output as a reference"
- echo "mkcleanup removes the tmp directories that may have been created"
-}
-
-parse_command_line ()
+run_test_report ()
{
- while true ; do
+ diff -Nur --exclude=*CVS* $HERE/$TEST_OUT_REF_DIR $HERE/$TEST_OUTPUT_DIR > /tmp/toto$$
+ NB_DIFF=`cat /tmp/toto$$ | wc -l`
- arg=$1 ;
-
- case "$arg" in
-
- -h|--help)
- display_usage $@
- exit 0
- ;;
- -*)
- echo "$0: unknown option: $arg"
- display_usage $@
- exit 0
- ;;
-
- run|mkref|mkcleanup)
- COMMAND_LIST="$COMMAND_LIST $arg"
- shift
- ;;
-
- *)
- display_usage $@
- exit 0
- ;;
- esac
- done
+ if test "$NB_DIFF" -eq 0 ; then
+ echo "/////////////ALL THE TESTS ARE OK :) //////////////////"
+ rm /tmp/toto$$
+ else
+ echo "SOME TESTS ARE KO :("
+ mv /tmp/toto$$ $HERE/$ERROR_REPORT_FILE
+ echo "See $HERE/$ERROR_REPORT_FILE to see what's going on"
+ fi
}
+
execute_command ()
{
arg=$1 ;
- case "$arg"in
+ case "$arg" in
+
run)
+ build_tests_list ;
+ if test "empty$TEST_PROG_LIST" = "empty" ; then
+ echo "could not find any test to run"
+ exit
+ fi
+
+ for TEST in $TEST_PROG_LIST ; do
+ run_test_prog $TEST no;
+ done
+
+ run_test_report ;
;;
mkref)
+ build_tests_list ;
+ if test "empty$TEST_PROG_LIST" = "empty" ; then
+ echo "could not find any test to run"
+ exit
+ fi
+
+ for TEST in $TEST_PROG_LIST ; do
+ run_test_prog $TEST yes;
+ done
;;
mkcleanup)
+ rm -f $HERE/$TEST_OUTPUT_DIR/*
+
+ if test -f $HERE/$ERROR_REPORT_FILE ; then
+ rm $HERE/$ERROR_REPORT_FILE
+ fi
;;
*)
@@ -158,9 +230,17 @@ execute_command ()
esac
}
+
main ()
{
parse_command_line $@
+
+ if test "empty$COMMAND_LIST" = "empty" ; then
+ echo "no test command to execute"
+ exit
+ fi
+
+ execute_command $COMMAND_LIST
}
main $@