From 934fa2ab35547bc858df7f769ef9a5362272580c Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Sat, 13 Mar 2004 21:19:05 +0000 Subject: *** empty log message *** --- tests/Makefile.am | 4 + tests/global-vars.sh | 10 ++ tests/test-inputs/Makefile.am | 13 ++- tests/test-inputs/prop-vendor-ident.css | 3 + tests/test-inputs/unknown-at-rule.css | 3 + tests/test-inputs/unknown-at-rule2.css | 3 + tests/test-output-refs/Makefile.am | 26 ++--- tests/test-output-refs/test-prop-ident.out | 3 + tests/test-output-refs/test-unknown-at-rule.out | 1 + tests/test-output-refs/test-unknown-at-rule2.out | 2 + tests/test-output-refs/test5.1.css.out | 28 ------ tests/test-prop-ident.sh | 6 ++ tests/test-unknown-at-rule.sh | 6 ++ tests/test-unknown-at-rule2.sh | 6 ++ tests/test1-main.c | 4 +- tests/test2-main.c | 4 +- tests/test4-main.c | 5 +- tests/test5-main.c | 5 +- tests/testctl | 120 ++++++++++++++++++----- tests/vg.supp | 57 +++++++++++ 20 files changed, 231 insertions(+), 78 deletions(-) create mode 100644 tests/global-vars.sh create mode 100644 tests/test-inputs/prop-vendor-ident.css create mode 100644 tests/test-inputs/unknown-at-rule.css create mode 100644 tests/test-inputs/unknown-at-rule2.css create mode 100644 tests/test-output-refs/test-prop-ident.out create mode 100644 tests/test-output-refs/test-unknown-at-rule.out create mode 100644 tests/test-output-refs/test-unknown-at-rule2.out create mode 100755 tests/test-prop-ident.sh create mode 100755 tests/test-unknown-at-rule.sh create mode 100755 tests/test-unknown-at-rule2.sh create mode 100644 tests/vg.supp (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index e17e2fa..3f5ecfe 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,8 @@ SUBDIRS=test-inputs test-output-refs +EXTRA_DIST=testctl vg.supp global-vars.sh\ +test-prop-ident.sh \ +test-unknown-at-rule.sh \ +test-unknown-at-rule2.sh #the list of all possible tests goes here. diff --git a/tests/global-vars.sh b/tests/global-vars.sh new file mode 100644 index 0000000..2fc8473 --- /dev/null +++ b/tests/global-vars.sh @@ -0,0 +1,10 @@ +TEST_INPUTS_DIR=$HERE_DIR/test-inputs +CSSLINT=$HERE_DIR/../csslint/.libs/csslint +if ! test -x $CSSLINT ; then + echo "Aarg Could not find an executable csslint. I was looking for $CSSLINT" + echo $ +fi + +if ! test x"$VALGRIND" = x ; then + CSSLINT="$VALGRIND $CSSLINT" +fi diff --git a/tests/test-inputs/Makefile.am b/tests/test-inputs/Makefile.am index 62d0338..53ee855 100644 --- a/tests/test-inputs/Makefile.am +++ b/tests/test-inputs/Makefile.am @@ -1,11 +1,14 @@ -EXTRA_DIST=test0.1.css \ -test1.css \ +EXTRA_DIST= prop-vendor-ident.css \ +test0.1.css \ +test1.css \ test2.1.css \ test2.2.css \ -test2.css \ +test2.css \ test3.1.css \ test3.2.css \ -test3.css \ +test3.css \ test4.1.css \ test4.2.css \ -test5.1.css +test5.1.css \ +unknown-at-rule2.css \ +unknown-at-rule.css diff --git a/tests/test-inputs/prop-vendor-ident.css b/tests/test-inputs/prop-vendor-ident.css new file mode 100644 index 0000000..f7aa8b5 --- /dev/null +++ b/tests/test-inputs/prop-vendor-ident.css @@ -0,0 +1,3 @@ +:-foo-pseudo { + -foo-bar-prop: -foobar-value +} diff --git a/tests/test-inputs/unknown-at-rule.css b/tests/test-inputs/unknown-at-rule.css new file mode 100644 index 0000000..7680999 --- /dev/null +++ b/tests/test-inputs/unknown-at-rule.css @@ -0,0 +1,3 @@ +@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace +to +HTML */ \ No newline at end of file diff --git a/tests/test-inputs/unknown-at-rule2.css b/tests/test-inputs/unknown-at-rule2.css new file mode 100644 index 0000000..0c4a191 --- /dev/null +++ b/tests/test-inputs/unknown-at-rule2.css @@ -0,0 +1,3 @@ +@namespace url(http://www.w3.org/1999/xhtml); dummyrule { } /* set +default +namespace to HTML */ \ No newline at end of file diff --git a/tests/test-output-refs/Makefile.am b/tests/test-output-refs/Makefile.am index 9e678b5..0b1b528 100644 --- a/tests/test-output-refs/Makefile.am +++ b/tests/test-output-refs/Makefile.am @@ -1,13 +1,15 @@ EXTRA_DIST=test0.1.css.out \ -test1.css.out \ -test2.1.css.out \ -test2.2.css.out \ -test2.css.out \ -test3.1.css.out \ -test3.2.css.out \ -test3.css.out \ -test4.1.css.out \ -test4.2.css.out \ -test5.1.css.out \ -test6.out \ -test7.out \ No newline at end of file +test1.css.out \ +test2.1.css.out \ +test2.2.css.out \ +test2.css.out \ +test3.1.css.out \ +test3.2.css.out \ +test3.css.out \ +test4.1.css.out \ +test4.2.css.out \ +test6.out \ +test-prop-ident.out \ +test-unknown-at-rule.out \ +test-unknown-at-rule2.out \ +test5.1.css.out diff --git a/tests/test-output-refs/test-prop-ident.out b/tests/test-output-refs/test-prop-ident.out new file mode 100644 index 0000000..149e8f5 --- /dev/null +++ b/tests/test-output-refs/test-prop-ident.out @@ -0,0 +1,3 @@ +:-foo-pseudo { + -foo-bar-prop : -foobar-value +} diff --git a/tests/test-output-refs/test-unknown-at-rule.out b/tests/test-output-refs/test-unknown-at-rule.out new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tests/test-output-refs/test-unknown-at-rule.out @@ -0,0 +1 @@ + diff --git a/tests/test-output-refs/test-unknown-at-rule2.out b/tests/test-output-refs/test-unknown-at-rule2.out new file mode 100644 index 0000000..a356a7d --- /dev/null +++ b/tests/test-output-refs/test-unknown-at-rule2.out @@ -0,0 +1,2 @@ +dummyrule { +} diff --git a/tests/test-output-refs/test5.1.css.out b/tests/test-output-refs/test5.1.css.out index 75b17d0..2f0bc54 100644 --- a/tests/test-output-refs/test5.1.css.out +++ b/tests/test-output-refs/test5.1.css.out @@ -1,8 +1,6 @@ ''''''''''''''''''''''''' xml start element: document - - :first-child { first-child-prop : first-child-value } @@ -12,13 +10,9 @@ xml end element: document ''''''''''''''''''''''''' xml start element: E0 - - :first-child { first-child-prop : first-child-value } - - E0 { prop0 : val0 } @@ -28,8 +22,6 @@ xml end element: E0 ''''''''''''''''''''''''' xml start element: E1 - - E0+E1 { pro1 : val1 } @@ -39,23 +31,15 @@ xml end element: E1 ''''''''''''''''''''''''' xml start element: E1-1 - - :first-child { first-child-prop : first-child-value } - - E1 E1-1 { prop2 : val2 } - - E1>E1-1 { prop3 : val3 } - - document E1-1 { prop4 : val4 } @@ -65,13 +49,9 @@ xml end element: E1-1 ''''''''''''''''''''''''' xml start element: E2 - - [attr2="val2"] { prop5 : val5 } - - E2[attr2="val2"] { prop8 : val8 } @@ -81,8 +61,6 @@ xml end element: E2 ''''''''''''''''''''''''' xml start element: E3 - - [attr3~="val3_2"] { prop6 : val6 } @@ -92,8 +70,6 @@ xml end element: E3 ''''''''''''''''''''''''' xml start element: E4 - - [attr4|="val4"] { prop7 : val7 } @@ -112,8 +88,6 @@ xml end element: E5 ''''''''''''''''''''''''' xml start element: E6 - - #id6 { prop9 : val9 } @@ -123,8 +97,6 @@ xml end element: E6 ''''''''''''''''''''''''' xml start element: E7 - - :lang(fr) { lang-prop : lang-value } diff --git a/tests/test-prop-ident.sh b/tests/test-prop-ident.sh new file mode 100755 index 0000000..e07005d --- /dev/null +++ b/tests/test-prop-ident.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +HERE_DIR=`dirname $0` +. $HERE_DIR/global-vars.sh + +$CSSLINT $TEST_INPUTS_DIR/prop-vendor-ident.css diff --git a/tests/test-unknown-at-rule.sh b/tests/test-unknown-at-rule.sh new file mode 100755 index 0000000..a9de6c8 --- /dev/null +++ b/tests/test-unknown-at-rule.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +HERE_DIR=`dirname $0` +. $HERE_DIR/global-vars.sh + +$CSSLINT $TEST_INPUTS_DIR/unknown-at-rule.css diff --git a/tests/test-unknown-at-rule2.sh b/tests/test-unknown-at-rule2.sh new file mode 100755 index 0000000..8b421ad --- /dev/null +++ b/tests/test-unknown-at-rule2.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +HERE_DIR=`dirname $0` +. $HERE_DIR/global-vars.sh + +$CSSLINT $TEST_INPUTS_DIR/unknown-at-rule2.css diff --git a/tests/test1-main.c b/tests/test1-main.c index 019e6dc..b7e657f 100644 --- a/tests/test1-main.c +++ b/tests/test1-main.c @@ -3,8 +3,6 @@ /* * This file is part of The Croco Library * - * Copyright (C) 2002-2003 Dodji Seketeli - * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2.1 of the GNU Lesser General Public * License as published by the Free Software Foundation. @@ -18,6 +16,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA + * + * See COPYRIGHTS file for copyright information */ /* diff --git a/tests/test2-main.c b/tests/test2-main.c index d64071c..fc991cd 100644 --- a/tests/test2-main.c +++ b/tests/test2-main.c @@ -3,8 +3,6 @@ /* * This file is part of The Croco Library * - * Copyright (C) 2002-2003 Dodji Seketeli - * * This program is free software; you can redistribute it and/or * modify it under the terms * of version 2.1 of the GNU Lesser General Public @@ -20,6 +18,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA + * + * See COPYRIGHTS file for copyright information. */ /* diff --git a/tests/test4-main.c b/tests/test4-main.c index 5880cc5..78501dc 100644 --- a/tests/test4-main.c +++ b/tests/test4-main.c @@ -140,9 +140,9 @@ test_cr_statement_at_page_rule_parse_from_buf (void) stmt = cr_statement_at_page_rule_parse_from_buf (gv_at_page_buf, CR_UTF_8) ; if (!stmt) { - return CR_ERROR ; - + return CR_ERROR ; } + cr_statement_destroy (stmt) ; return CR_OK ; } @@ -237,7 +237,6 @@ test_cr_statement_ruleset_parse (void) cr_statement_destroy (stmt); stmt = NULL; } - return CR_OK; } diff --git a/tests/test5-main.c b/tests/test5-main.c index 59d81aa..1610382 100644 --- a/tests/test5-main.c +++ b/tests/test5-main.c @@ -192,7 +192,10 @@ test_sel_eng (guchar * a_file_uri) cr_stylesheet_destroy (stylesheet); stylesheet = NULL; } - + if (selection_engine) { + cr_sel_eng_destroy (selection_engine) ; + selection_engine = NULL ; + } xmlCleanupParser (); return status; diff --git a/tests/testctl b/tests/testctl index 96a541b..18ec9ed 100755 --- a/tests/testctl +++ b/tests/testctl @@ -27,7 +27,13 @@ TEST_OUTPUT_DIR=test-outputs ERROR_REPORT_FILE=tests-error.log COMMAND_LIST= COMMAND= -RUN_VALGRIND=no +if test x$RUN_VALGRIND = x ; then + RUN_VALGRIND=no +else + RUN_VALGRIND=yes +fi +VALGRIND_LOGS_DIR=valgrind-logs +VALGRIND= TEST_PROG= EGREP=`which egrep` if test "empty$EGREP" = "empty" ; then @@ -53,8 +59,8 @@ display_usage () 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" + echo "ref run the tests but saves their output as a reference" + echo "cleanup removes the tmp directories that may have been created" echo "" echo "run command options:" echo "--valgrind runs the test using valgrind" @@ -87,7 +93,7 @@ parse_command_line () exit 0 ;; - run|mkref|mkcleanup) + run|ref|cleanup) COMMAND_LIST=$arg REMAINING_ARGS=$@ echo "REMAINING_ARGS=$REMAINING_ARGS" @@ -106,8 +112,9 @@ parse_command_line () #builds the list of available test functions. build_tests_list () { - for TEST_PROG in `ls -1 $HERE | egrep ^test\([0-9]\)+$` ; do - echo "$un test: $TEST_PROG" + for TEST_PROG in `find $HERE -type f -print | egrep ^$HERE/test\(\([-0-9a-zA-Z_]\)+\)?\(\.sh\)?$ | grep -v testctl` ; do + TEST_PROG=`basename $TEST_PROG` + echo "run test: $TEST_PROG" TEST_PROG_LIST="$TEST_PROG_LIST $TEST_PROG" done } @@ -123,16 +130,38 @@ run_test_prog () TEST_PROG=$1 REFERENCE=$2 DISPLAY_ON_STDOUT=$3 - OUTPUT_DIR= OUTPUT_SUFFIX= TEST_INPUT_LIST= + VALGRIND_OPTIONS="--error-limit=no --num-callers=100 --logfile=$HERE/$VALGRIND_LOGS_DIR/$TEST_PROG-valgrind.log --leak-check=yes --show-reachable=yes --quiet --suppressions=$HERE/vg.supp" + if test x$RUN_VALGRIND = xno ; then + VALGRIND= + else + VALGRIND=`which valgrind` + if test x$VALGRIND = x ; then + echo "Could not find valgrind in your path" + else + VALGRIND="$VALGRIND $VALGRIND_OPTIONS" + echo "Gonna run the tests with valgrind, using the following options: $VALGRIND_OPTIONS" + fi + fi + export VALGRIND + is_shell_script=`echo $TEST_PROG | egrep "(.*)?.sh"` + if test x$is_shell_script = x ; then + is_shell_script=no + else + is_shell_script=yes + fi + + if ! test -d $HERE/$VALGRIND_LOGS_DIR ; then + mkdir $HERE/$VALGRIND_LOGS_DIR + fi for TEST_INPUT in `ls -1 $HERE/$TEST_INPUT_DIR | egrep ^${TEST_PROG}\([\.0-9]\)+\css\$` ; do TEST_INPUT_LIST="$TEST_INPUT_LIST $TEST_INPUT" done - if test "$REFERENCE" = "yes" ; then + if test "$REFERENCE" = "yes" ; then OUTPUT_DIR=$HERE/$TEST_OUT_REF_DIR OUTPUT_SUFFIX=.out @@ -151,37 +180,52 @@ run_test_prog () if test "empty$TEST_INPUT_LIST" != "empty" ; then for TEST_INPUT in $TEST_INPUT_LIST ; do + TEST_INPUT_NAME=`basename $TEST_INPUT .sh` if test "$DISPLAY_ON_STDOUT" = "yes" ; then echo "###############################################" - echo "launching $HERE/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT".... - echo "###############################################" - $HERE/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT + echo "launching $VALGRIND $HERE/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT".... + echo "###############################################" + if test x$is_shell_script = xyes ; then + $HERE/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT + else + $VALGRIND $HERE/.libs/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT + fi echo "###############################################" echo "done" echo "###############################################" echo "" else - 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 "executing $VALGRIND $HERE/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT > $OUTPUT_DIR/${TEST_INPUT_NAME}${OUTPUT_SUFFIX} ..." + $VALGRIND $HERE/.libs/$TEST_PROG $HERE/$TEST_INPUT_DIR/$TEST_INPUT > $OUTPUT_DIR/${TEST_INPUT_NAME}${OUTPUT_SUFFIX} echo "done" fi done else if test "$DISPLAY_ON_STDOUT" = "yes" ; then echo "####################################################" - echo "launching $HERE/$TEST_PROG ..." + echo "launching $VALGRIND $HERE/$TEST_PROG ..." echo "####################################################" - $HERE/$TEST_PROG + if test x$is_shell_script = xyes ; then + $HERE/$TEST_PROG + else + $VALGRIND $HERE/.libs/$TEST_PROG + fi echo "####################################################" echo "done" echo "####################################################" echo "" else - echo "executing $HERE/$TEST_PROG > $OUTPUT_DIR/${TEST_INPUT}${OUTPUT_SUFFIX} ..." - $HERE/$TEST_PROG > $OUTPUT_DIR/${TEST_PROG}${OUTPUT_SUFFIX} + TEST_INPUT_NAME=`basename $TEST_PROG .sh` + echo "executing $VALGRIND $HERE/$TEST_PROG > $OUTPUT_DIR/${TEST_PROG}${OUTPUT_SUFFIX} ..." + if test x$is_shell_script = xyes ; then + $HERE/$TEST_PROG > $OUTPUT_DIR/${TEST_INPUT_NAME}${OUTPUT_SUFFIX} + else + $VALGRIND $HERE/.libs/$TEST_PROG > $OUTPUT_DIR/${TEST_INPUT_NAME}${OUTPUT_SUFFIX} + fi echo "done" fi fi + unset VALGRIND } cleanup_tests () @@ -189,12 +233,16 @@ cleanup_tests () if test -d $HERE/$TEST_OUTPUT_DIR ; then echo "removing $HERE/$TEST_OUTPUT_DIR" rm -rf $HERE/$TEST_OUTPUT_DIR/* + rm -rf $HERE/$VALGRIND_LOGS_DIR + fi + if test -f $HERE/$ERROR_REPORT_FILE ; then + rm $HERE/$ERROR_REPORT_FILE fi } run_test_report () { - diff -ur --exclude=*CVS* --exclude=*cvs* --exclude=Makefile* $HERE/$TEST_OUT_REF_DIR $HERE/$TEST_OUTPUT_DIR > /tmp/toto$$ + diff -ur --exclude=*CVS* --exclude=*cvs* --exclude=Makefile* --exclude=.arch-ids $HERE/$TEST_OUT_REF_DIR $HERE/$TEST_OUTPUT_DIR > /tmp/toto$$ NB_DIFF=`cat /tmp/toto$$ | wc -l` if test "$NB_DIFF" -eq 0 ; then @@ -205,6 +253,32 @@ run_test_report () mv /tmp/toto$$ $HERE/$ERROR_REPORT_FILE echo "See $HERE/$ERROR_REPORT_FILE to see what's going on" fi + + ################### + #Valgrind errors # + ################### + memleaks=no + for vg_log in `find $HERE/$VALGRIND_LOGS_DIR -name "*-valgrind.log*" -print` ; do + if test -s $vg_log ; then + leaks=`cat $vg_log | grep -i leak | grep -v no` + errors=`cat $vg_log | grep -w Invalid` + if test "x$leaks" = "x" -a "x$errors" = "x" ; then + rm -f $vg_log ; + else + echo "valgrind reported some memory leaks/corruptions in $vg_log" + memleaks=yes + fi + else + rm $vg_log + fi + done + if test "x$RUN_VALGRIND" = "xyes" ; then + if test "x$memleaks" = "xno" ; then + echo "Oh, YESSSSSS!, VALGRIND DID NOT DETECT ANY MEMLEAK !! You can go have a beer." + else + echo "Please report these leaks by sending the valgrind logs to the authors of libcroco." + fi + fi } ############################ @@ -286,7 +360,7 @@ execute_command () execute_run_cmd $@ ;; - mkref) + ref) build_tests_list ; if test "empty$TEST_PROG_LIST" = "empty" ; then echo "could not find any test to run" @@ -298,12 +372,8 @@ execute_command () done ;; - mkcleanup) - rm -f $HERE/$TEST_OUTPUT_DIR/* - - if test -f $HERE/$ERROR_REPORT_FILE ; then - rm $HERE/$ERROR_REPORT_FILE - fi + cleanup) + cleanup_tests ;; *) diff --git a/tests/vg.supp b/tests/vg.supp new file mode 100644 index 0000000..5a3d109 --- /dev/null +++ b/tests/vg.supp @@ -0,0 +1,57 @@ +{ + g_print_ALLOC_LEAK + Memcheck:Leak + fun:malloc + fun:realloc + fun:g_realloc + fun:g_array_maybe_expand + fun:g_array_set_size + fun:g_static_private_set + fun:g_get_charset + fun:g_print +} + +{ + g_slist_prepend_LEAK + Memcheck:Leak + fun:calloc + fun:g_malloc0 + fun:g_allocator_new + fun:_g_slist_alloc + fun:g_slist_prepend +} + +{ + g_print_CONVERT_LEAK + Memcheck:Leak + fun:malloc + obj:*libc-2.3.3.so + fun:iconv_open + fun:try_conversion + fun:g_iconv_open + fun:open_converter + fun:g_convert + fun:g_convert_with_fallback + fun:strdup_convert + fun:g_print +} + +{ + g_string_new_CHUNCK_LEAK + Memcheck:Leak + fun:malloc + fun:g_malloc + fun:g_mem_chunk_new + fun:g_string_sized_new + fun:g_string_new +} + +{ + g_list_prepend_LEAK + Memcheck:Leak + fun:calloc + fun:g_malloc0 + fun:g_allocator_new + fun:_g_list_alloc + fun:g_list_prepend +} -- cgit v1.2.1