diff options
author | Dodji Seketeli <dodji@src.gnome.org> | 2003-04-03 06:54:40 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2003-04-03 06:54:40 +0000 |
commit | 3b7d9f10818a0cb4e70864f8d1a5ecbf7ba3e0b0 (patch) | |
tree | d48ff986f43c9e0ee6db5b1a5be0942bf226878e /tests | |
parent | 9ea5d95b1149270cb7277ec1d83a78d0018190dd (diff) | |
download | libcroco-3b7d9f10818a0cb4e70864f8d1a5ecbf7ba3e0b0.tar.gz |
more work on the test framework.
made sure to build rpms via a new "make rpm" target.
Dodji.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test4-main.c | 2 | ||||
-rwxr-xr-x | tests/testctl | 146 | ||||
-rw-r--r-- | tests/valgrind.log | 166 | ||||
-rwxr-xr-x | tests/vg | 11 |
4 files changed, 147 insertions, 178 deletions
diff --git a/tests/test4-main.c b/tests/test4-main.c index 91a5757..9f68c43 100644 --- a/tests/test4-main.c +++ b/tests/test4-main.c @@ -30,7 +30,7 @@ /** *@file - *Some test facilities for the #CRParser class. + *Some test facilities for the #CROMParser class. */ CRDocHandler * gv_test_handler = {0} ; diff --git a/tests/testctl b/tests/testctl index 8ba6806..a9001fe 100755 --- a/tests/testctl +++ b/tests/testctl @@ -27,7 +27,8 @@ TEST_OUTPUT_DIR=test-outputs ERROR_REPORT_FILE=tests-error.log COMMAND_LIST= COMMAND= - +RUN_VALGRIND=no +TEST_PROG= EGREP=`which egrep` if test "empty$EGREP" = "empty" ; then echo "You don't have the egrep program installed" @@ -43,9 +44,9 @@ fi display_usage () { echo "" - echo "usage: $0 [options] <command>" + echo "usage: $0 [general options] <command> [command option]" echo "" - echo "where options are:" + echo "where general options are:" echo "====================" echo "-h|--help displays this help" echo "" @@ -54,9 +55,12 @@ display_usage () 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 "" + echo "run command options:" + echo "--valgrind runs the test using valgrind" + echo "--testprog <test program>" } - parse_command_line () { if test "empty$1" = "empty" ; then @@ -83,9 +87,10 @@ parse_command_line () exit 0 ;; - run|mkref|mkcleanup) + run|mkref|mkcleanup) COMMAND_LIST=$arg - shift + REMAINING_ARGS=$@ + echo "REMAINING_ARGS=$REMAINING_ARGS" break ; ;; @@ -105,11 +110,10 @@ build_tests_list () echo "$un test: $TEST_PROG" TEST_PROG_LIST="$TEST_PROG_LIST $TEST_PROG" done - } #runs a test programs. -#usage run_test_prog <test-name> <reference> +#usage run_test_prog <test-name> <reference> <display-on-stdout> #where "test-name" is the name of the test program to run #"reference" is a boolean value: yes/no. (the string "yes" or the string no) #if yes, means that the output of the test is to be saved as a reference. @@ -118,7 +122,8 @@ run_test_prog () { TEST_PROG=$1 REFERENCE=$2 - + DISPLAY_ON_STDOUT=$3 + OUTPUT_DIR= OUTPUT_SUFFIX= TEST_INPUT_LIST= @@ -140,23 +145,42 @@ run_test_prog () mkdir $HERE/$TEST_OUTPUT_DIR ; echo "done" fi - OUTPUT_DIR=$HERE/$TEST_OUTPUT_DIR OUTPUT_SUFFIX=.out - fi + fi if test "empty$TEST_INPUT_LIST" != "empty" ; then for TEST_INPUT in $TEST_INPUT_LIST ; do - #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 "" + 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 "###############################################" + 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 "done" + fi done else - echo "executing $HERE/$TEST_PROG > $OUTPUT_DIR/${TEST_INPUT}${OUTPUT_SUFFIX} ..." - $HERE/$TEST_PROG > $OUTPUT_DIR/${TEST_PROG}${OUTPUT_SUFFIX} - echo "done" + if test "$DISPLAY_ON_STDOUT" = "yes" ; then + echo "####################################################" + echo "launching $HERE/$TEST_PROG ..." + echo "####################################################" + $HERE/$TEST_PROG + 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} + echo "done" + fi fi } @@ -183,7 +207,75 @@ run_test_report () fi } +############################ +#Executes the "run" command along with +#it's command options. +#For the sake of safety checking +############################ +execute_run_cmd () +{ + args=$@ + + if test "$1" != "run" ; then + echo "internal error: first argument should be \'run\'" + return + fi + shift + + while true ; do + cur_arg=$1 + echo "cur_arg=$cur_arg" + + case $cur_arg in + --valgrind) + RUN_VALGRIND=yes + shift + ;; + + "--testprog") + shift + if test "empty$1" = "empty" ; then + echo "--testprog should be followed by a prog name" + display_usage + exit + fi + TEST_PROG=$1 + echo "TEST_PROG=$TEST_PROG" + shift + ;; + + *) + break + ;; + esac + done + + if test "empty$TEST_PROG" = "empty"; then + 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 no; + done + run_test_report ; + else + #run the test and display result on stdout + run_test_prog $TEST_PROG no yes ; + fi +} +############################## +#Analyzes a command string "<command> [command option]" +#and runs the necessary commands. +# +#Must be called with the command line +#starting with a command name. +#all the previous general argument must +#have been stripped away. +############################# execute_command () { arg=$1 ; @@ -191,17 +283,7 @@ execute_command () 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 ; + execute_run_cmd $@ ;; mkref) @@ -212,7 +294,7 @@ execute_command () fi for TEST in $TEST_PROG_LIST ; do - run_test_prog $TEST yes; + run_test_prog $TEST yes no; done ;; @@ -240,7 +322,7 @@ main () exit fi - execute_command $COMMAND_LIST + execute_command $REMAINING_ARGS } main $@ diff --git a/tests/valgrind.log b/tests/valgrind.log index 7e68e8f..e7a7730 100644 --- a/tests/valgrind.log +++ b/tests/valgrind.log @@ -1,144 +1,22 @@ -==31389== valgrind-1.0.4, a memory error detector for x86 GNU/Linux. -==31389== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward. -==31389== Startup, with flags: -==31389== --suppressions=/usr/local/lib/valgrind/default.supp -==31389== -v -==31389== --num-callers=100 -==31389== --leak-check=yes -==31389== --show-reachable=yes -==31389== Reading suppressions file: /usr/local/lib/valgrind/default.supp -==31389== Reading syms from /home/dodji/dev/libcroco/tests/.libs/test4 -==31389== Reading syms from /lib/ld-2.2.5.so -==31389== Reading syms from /usr/local/lib/valgrind/valgrind.so -==31389== Reading syms from /usr/lib/libglib-2.0.so.0.0.6 -==31389== object doesn't have any debug info -==31389== Reading syms from /usr/local/lib/libcroco.so.0.0.1 -==31389== Reading syms from /lib/i686/libc-2.2.5.so -==31389== object doesn't have any debug info -==31389== Estimated CPU clock rate is 364 MHz -==31389== -==31389== -==31389== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) -==31389== malloc/free: in use at exit: 38298 bytes in 19 blocks. -==31389== malloc/free: 2510 allocs, 2491 frees, 125800 bytes allocated. -==31389== -==31389== searching for pointers to 19 not-freed blocks. -==31389== checked 4075548 bytes. -==31389== -==31389== definitely lost: 0 bytes in 0 blocks. -==31389== possibly lost: 0 bytes in 0 blocks. -==31389== still reachable: 38298 bytes in 19 blocks. -==31389== -==31389== 20 bytes in 1 blocks are still reachable in loss record 1 of 6 -==31389== at 0x4003BF5B: calloc (vg_clientfuncs.c:239) -==31389== by 0x4025FF5D: g_allocator_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40254B16: (within /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40253F7F: g_list_append (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x402BB93D: cr_parser_parse_import (cr-parser.c:3170) -==31389== by 0x402BD9A2: cr_parser_parse_stylesheet (cr-parser.c:4494) -==31389== by 0x402BE6BF: cr_parser_parse (cr-parser.c:5086) -==31389== by 0x402BE8B4: cr_parser_parse_from_file (cr-parser.c:5144) -==31389== by 0x402C2E74: cr_om_parser_parse_file (cr-om-parser.c:847) -==31389== by 0x804880E: test_cr_parser_parse (test4-main.c:100) -==31389== by 0x80488DA: main (test4-main.c:142) -==31389== by 0x402E1082: __libc_start_main (in /lib/i686/libc-2.2.5.so) -==31389== by 0x80485F1: cr_om_parser_parse_file (in /home/dodji/dev/libcroco/tests/.libs/test4) -==31389== -==31389== 80 bytes in 1 blocks are still reachable in loss record 2 of 6 -==31389== at 0x4003BAB5: malloc (vg_clientfuncs.c:100) -==31389== by 0x402E1BFA: (within /lib/i686/libc-2.2.5.so) -==31389== by 0x402E1865: iconv_open (in /lib/i686/libc-2.2.5.so) -==31389== by 0x402439E3: (within /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40241D2D: g_convert (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x4024221C: g_convert_with_fallback (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40261F26: g_print (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x402BF7EA: cr_statement_dump_charset (cr-statement.c:259) -==31389== by 0x402C1226: cr_statement_dump (cr-statement.c:1196) -==31389== by 0x402C14CF: cr_stylesheet_dump (cr-stylesheet.c:74) -==31389== by 0x804882B: test_cr_parser_parse (test4-main.c:104) -==31389== by 0x80488DA: main (test4-main.c:142) -==31389== by 0x402E1082: __libc_start_main (in /lib/i686/libc-2.2.5.so) -==31389== by 0x80485F1: cr_om_parser_parse_file (in /home/dodji/dev/libcroco/tests/.libs/test4) -==31389== -==31389== 208 bytes in 4 blocks are still reachable in loss record 3 of 6 -==31389== at 0x4003BAB5: malloc (vg_clientfuncs.c:100) -==31389== by 0x4025EAF2: g_mem_chunk_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40271523: g_string_sized_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40271588: g_string_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x402B021D: cr_tknzr_parse_string (cr-tknzr.c:768) -==31389== by 0x402B44E5: cr_tknzr_get_next_token (cr-tknzr.c:2713) -==31389== by 0x402B8247: cr_parser_try_to_skip_spaces_and_comments (cr-parser.c:832) -==31389== by 0x402BB4A7: cr_parser_parse_charset (cr-parser.c:3026) -==31389== by 0x402BD767: cr_parser_parse_stylesheet (cr-parser.c:4408) -==31389== by 0x402BE6BF: cr_parser_parse (cr-parser.c:5086) -==31389== by 0x402BE8B4: cr_parser_parse_from_file (cr-parser.c:5144) -==31389== by 0x402C2E74: cr_om_parser_parse_file (cr-om-parser.c:847) -==31389== by 0x804880E: test_cr_parser_parse (test4-main.c:100) -==31389== by 0x80488DA: main (test4-main.c:142) -==31389== by 0x402E1082: __libc_start_main (in /lib/i686/libc-2.2.5.so) -==31389== by 0x80485F1: cr_om_parser_parse_file (in /home/dodji/dev/libcroco/tests/.libs/test4) -==31389== -==31389== 230 bytes in 8 blocks are still reachable in loss record 4 of 6 -==31389== at 0x4003BAB5: malloc (vg_clientfuncs.c:100) -==31389== by 0x4025F739: g_malloc (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x4027842A: g_tree_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x4025EC1E: g_mem_chunk_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40271523: g_string_sized_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40271588: g_string_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x402B021D: cr_tknzr_parse_string (cr-tknzr.c:768) -==31389== by 0x402B44E5: cr_tknzr_get_next_token (cr-tknzr.c:2713) -==31389== by 0x402B8247: cr_parser_try_to_skip_spaces_and_comments (cr-parser.c:832) -==31389== by 0x402BB4A7: cr_parser_parse_charset (cr-parser.c:3026) -==31389== by 0x402BD767: cr_parser_parse_stylesheet (cr-parser.c:4408) -==31389== by 0x402BE6BF: cr_parser_parse (cr-parser.c:5086) -==31389== by 0x402BE8B4: cr_parser_parse_from_file (cr-parser.c:5144) -==31389== by 0x402C2E74: cr_om_parser_parse_file (cr-om-parser.c:847) -==31389== by 0x804880E: test_cr_parser_parse (test4-main.c:100) -==31389== by 0x80488DA: main (test4-main.c:142) -==31389== by 0x402E1082: __libc_start_main (in /lib/i686/libc-2.2.5.so) -==31389== by 0x80485F1: cr_om_parser_parse_file (in /home/dodji/dev/libcroco/tests/.libs/test4) -==31389== -==31389== 5120 bytes in 4 blocks are still reachable in loss record 5 of 6 -==31389== at 0x4003BAB5: malloc (vg_clientfuncs.c:100) -==31389== by 0x4025F05F: g_mem_chunk_alloc (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40271457: g_string_sized_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40271588: g_string_new (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x402B021D: cr_tknzr_parse_string (cr-tknzr.c:768) -==31389== by 0x402B44E5: cr_tknzr_get_next_token (cr-tknzr.c:2713) -==31389== by 0x402B8247: cr_parser_try_to_skip_spaces_and_comments (cr-parser.c:832) -==31389== by 0x402BB4A7: cr_parser_parse_charset (cr-parser.c:3026) -==31389== by 0x402BD767: cr_parser_parse_stylesheet (cr-parser.c:4408) -==31389== by 0x402BE6BF: cr_parser_parse (cr-parser.c:5086) -==31389== by 0x402BE8B4: cr_parser_parse_from_file (cr-parser.c:5144) -==31389== by 0x402C2E74: cr_om_parser_parse_file (cr-om-parser.c:847) -==31389== by 0x804880E: test_cr_parser_parse (test4-main.c:100) -==31389== by 0x80488DA: main (test4-main.c:142) -==31389== by 0x402E1082: __libc_start_main (in /lib/i686/libc-2.2.5.so) -==31389== by 0x80485F1: cr_om_parser_parse_file (in /home/dodji/dev/libcroco/tests/.libs/test4) -==31389== -==31389== 32640 bytes in 1 blocks are still reachable in loss record 6 of 6 -==31389== at 0x4003BAB5: malloc (vg_clientfuncs.c:100) -==31389== by 0x402E1CFF: (within /lib/i686/libc-2.2.5.so) -==31389== by 0x402E1865: iconv_open (in /lib/i686/libc-2.2.5.so) -==31389== by 0x402439E3: (within /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40241D2D: g_convert (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x4024221C: g_convert_with_fallback (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x40261F26: g_print (in /usr/lib/libglib-2.0.so.0.0.6) -==31389== by 0x402BF7EA: cr_statement_dump_charset (cr-statement.c:259) -==31389== by 0x402C1226: cr_statement_dump (cr-statement.c:1196) -==31389== by 0x402C14CF: cr_stylesheet_dump (cr-stylesheet.c:74) -==31389== by 0x804882B: test_cr_parser_parse (test4-main.c:104) -==31389== by 0x80488DA: main (test4-main.c:142) -==31389== by 0x402E1082: __libc_start_main (in /lib/i686/libc-2.2.5.so) -==31389== by 0x80485F1: cr_om_parser_parse_file (in /home/dodji/dev/libcroco/tests/.libs/test4) -==31389== -==31389== LEAK SUMMARY: -==31389== definitely lost: 0 bytes in 0 blocks. -==31389== possibly lost: 0 bytes in 0 blocks. -==31389== still reachable: 38298 bytes in 19 blocks. -==31389== ---31389-- lru: 50 epochs, 0 clearings. ---31389-- translate: new 5784 (81473 -> 1079851), discard 0 (0 -> 0). ---31389-- dispatch: 2500000 basic blocks, 52/15905 sched events, 10797 tt_fast misses. ---31389-- reg-alloc: 1906 t-req-spill, 196526+11325 orig+spill uis, 29392 total-reg-r. ---31389-- sanity: 53 cheap, 3 expensive checks. +--8511-- FATAL: unhandled syscall: 252 +--8511-- Do not panic. You may be able to fix this easily. +--8511-- Read the file README_MISSING_SYSCALL_OR_IOCTL. +==8511== +==8511== Valgrind detected that your program requires +==8511== the following unimplemented functionality: +==8511== no wrapper for the above system call +==8511== This may be because the functionality is hard to implement, +==8511== or because no reasonable program would behave this way, +==8511== or because nobody has yet needed it. In any case, let me know +==8511== (jseward@acm.org) and/or try to work around the problem, if you can. +==8511== +==8511== Valgrind has to exit now. Sorry. Bye! +==8511== + +sched status: + +Thread 1: status = Runnable, associated_mx = 0x0, associated_cv = 0x0 +==8511== at 0x4046BCD3: _exit (in /lib/i686/libc-2.3.1.so) +==8511== by 0x403D37FF: __libc_start_main (in /lib/i686/libc-2.3.1.so) +==8511== by 0x8048721: cr_parser_new (in /home/dodji/dev/gnome/libcroco/tests/.libs/test2) + @@ -1,8 +1,12 @@ #!/bin/sh +### +# +### + OUTPUT_FILE=valgrind.log VG=`which valgrind` -VG_OPTIONS="-v --num-callers=100 --leak-check=yes --show-reachable=yes" +VG_OPTIONS="-q --num-callers=100 --leak-check=yes --show-reachable=yes" #Some sanity checks if test "empty$VG" = "empty" ; then @@ -12,4 +16,9 @@ if test "empty$VG" = "empty" ; then exit fi + +if test "empty$1" != "empty" ; then + OUTPUT_FILE="$1".vg +fi + exec $VG $VG_OPTIONS $@ 2>$OUTPUT_FILE
\ No newline at end of file |