From 335b650d0b74d02266dcabf3ba55422ecd613a39 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 17 Dec 2008 13:59:56 +0000 Subject: [PATCH] [tests] Create a real file for each test unit Currently, the conformance test suite creates symbolic links pointing to a wrapper script that just parses the name used to invoke it and calls the gtester with the correct path. Unfortunately, this presents two issues: - it does not really work on file systems that do not support symbolic links - it leaves behind the symbolic links, which cannot be automatically cleaning by 'make clean' Both can be solved by creating a small script that invokes the wrapper one with the test unit path. The Makefile will use test-conform to extract the unit test paths and generate a list that will be iterated over to create the executable name (using the "test-name" convention also used by the interactive tests, instead of "test_name"); the executable is then just a simple shell script that invokes the wrapper script passing the unit test path on the command line. The wrapper script will use the first argument to work correctly, so it could be simply executed like: ./test-wrapper.sh /path/to/unit_test Which is another improvement over the current implementation, where the wrapper script does not work when invoked directly. --- .gitignore | 68 ++++++++++++------------ tests/conform/Makefile.am | 96 ++++++++++++++++++++-------------- tests/conform/test-launcher.sh | 24 +++++++++ tests/conform/wrapper.sh | 18 ------- 4 files changed, 115 insertions(+), 91 deletions(-) create mode 100755 tests/conform/test-launcher.sh delete mode 100755 tests/conform/wrapper.sh diff --git a/.gitignore b/.gitignore index dba281eaa..74d271604 100644 --- a/.gitignore +++ b/.gitignore @@ -118,40 +118,40 @@ stamp-h1 /tests/conform/test-conformance-results.html /tests/conform/test-conformance-results-dn.xml /tests/conform/test-conformance-results-dn.html -/tests/conform/test_entry_append_some -/tests/conform/test_entry_cursor -/tests/conform/test_entry_delete_chars -/tests/conform/test_entry_delete_text -/tests/conform/test_entry_empty -/tests/conform/test_entry_event -/tests/conform/test_entry_insert -/tests/conform/test_entry_prepend_some -/tests/conform/test_entry_set_empty -/tests/conform/test_entry_set_text -/tests/conform/test_entry_utf8_validation -/tests/conform/test_fixed_constants -/tests/conform/test_initial_state -/tests/conform/test_label_cache -/tests/conform/test_mapped -/tests/conform/test_path -/tests/conform/test_pick -/tests/conform/test_realized -/tests/conform/test_rect_set_color -/tests/conform/test_rect_set_size -/tests/conform/test_show_on_set_parent -/tests/conform/test_timeline -/tests/conform/test_timeline_dup_frames -/tests/conform/test_timeline_interpolate -/tests/conform/test_timeline_rewind -/tests/conform/test_timeline_smoothness -/tests/conform/test_label_opacity -/tests/conform/test_mesh_contiguous -/tests/conform/test_mesh_interleved -/tests/conform/test_mesh_mutability -/tests/conform/test_paint_opacity -/tests/conform/test_rectangle_opacity -/tests/conform/test_backface_culling -/tests/conform/test_binding_pool +/tests/conform/test-entry-append-some +/tests/conform/test-entry-cursor +/tests/conform/test-entry-delete-chars +/tests/conform/test-entry-delete-text +/tests/conform/test-entry-empty +/tests/conform/test-entry-event +/tests/conform/test-entry-insert +/tests/conform/test-entry-prepend-some +/tests/conform/test-entry-set-empty +/tests/conform/test-entry-set-text +/tests/conform/test-entry-utf8-validation +/tests/conform/test-fixed-constants +/tests/conform/test-initial-state +/tests/conform/test-label-cache +/tests/conform/test-mapped +/tests/conform/test-path +/tests/conform/test-pick +/tests/conform/test-realized +/tests/conform/test-rect-set-color +/tests/conform/test-rect-set-size +/tests/conform/test-show-on-set-parent +/tests/conform/test-timeline +/tests/conform/test-timeline-dup-frames +/tests/conform/test-timeline-interpolate +/tests/conform/test-timeline-rewind +/tests/conform/test-timeline-smoothness +/tests/conform/test-label-opacity +/tests/conform/test-mesh-contiguous +/tests/conform/test-mesh-interleved +/tests/conform/test-mesh-mutability +/tests/conform/test-paint-opacity +/tests/conform/test-rectangle-opacity +/tests/conform/test-backface-culling +/tests/conform/test-binding-pool /tests/micro-bench/test-text /tests/tools/disable-npots.sh /clutter/x11/clutter-x11-enum-types.[ch] diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am index 985d74125..95be101dd 100644 --- a/tests/conform/Makefile.am +++ b/tests/conform/Makefile.am @@ -1,36 +1,57 @@ +NULL = + noinst_PROGRAMS = test-conformance -test_conformance_SOURCES = \ - test-conform-main.c \ - test-conform-common.c \ - test-conform-common.h \ +test_conformance_SOURCES = \ + test-conform-main.c \ + test-conform-common.c \ + test-conform-common.h \ \ - test-timeline-dup-frames.c \ - test-timeline-interpolate.c \ - test-timeline-rewind.c \ - test-timeline-smoothness.c \ - test-timeline.c \ - test-mesh-contiguous.c \ - test-mesh-interleved.c \ - test-mesh-mutability.c \ - test-path.c \ - test-pick.c \ - test-label-cache.c \ - test-clutter-entry.c \ - test-clutter-rectangle.c \ - test-clutter-fixed.c \ - test-actor-invariants.c \ - test-paint-opacity.c \ - test-backface-culling.c \ - test-binding-pool.c + test-timeline-dup-frames.c \ + test-timeline-interpolate.c \ + test-timeline-rewind.c \ + test-timeline-smoothness.c \ + test-timeline.c \ + test-mesh-contiguous.c \ + test-mesh-interleved.c \ + test-mesh-mutability.c \ + test-path.c \ + test-pick.c \ + test-label-cache.c \ + test-clutter-entry.c \ + test-clutter-rectangle.c \ + test-clutter-fixed.c \ + test-actor-invariants.c \ + test-paint-opacity.c \ + test-backface-culling.c \ + test-binding-pool.c \ + $(NULL) # For convenience, this provides a way to easily run individual unit tests: -.PHONY: wrappers +.PHONY: wrappers clean-wrappers + +UNIT_TESTS = `./test-conformance -l -m thorough | $(GREP) '^/'` + wrappers: test-conformance$(EXEEXT) - for i in `./test-conformance -l -m thorough|grep '^/'`; \ + @for i in $(UNIT_TESTS); \ do \ - ln -sf $(top_srcdir)/tests/conform/wrapper.sh `basename $$i`; \ + unit=`basename $$i | sed -e s/_/-/g`; \ + echo "GEN $$unit"; \ + ( echo "#!/bin/sh" ; echo "./test-launcher.sh '$$i'" ) > $$unit$(EXEEXT) ; \ + chmod +x $$unit$(EXEEXT); \ done + +clean-wrappers: + @for i in $(UNIT_TESTS); \ + do \ + unit=`basename $$i | sed -e s/_/-/g`; \ + echo "RM $$unit"; \ + rm -f $$unit$(EXEEXT) ; \ + done + +# we override the clean-generic target to clean up the wrappers +clean-generic: clean-wrappers + # NB: BUILT_SOURCES here a misnomer. We aren't building source, just inserting # a phony rule that will generate symlink scripts for running individual tests BUILT_SOURCES = wrappers @@ -48,56 +69,53 @@ test_conformance_LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@C .PHONY: full-report-generate test: - gtester -o=test-conformance-results.xml ./test-conformance + @gtester -o=test-conformance-results.xml ./test-conformance test-report-normal: - gtester -o=test-conformance-results.xml -k ./test-conformance \ + @gtester -o=test-conformance-results.xml -k ./test-conformance \ && ( gtester-report test-conformance-results.xml \ | sed 's/>GTester Unit Test ReportGTester Unit Test Report (normal) test-conformance-results.html ) \ + > test-conformance-results.html ) \ && gnome-open ./test-conformance-results.html test-report-disable-npots: - ../tools/disable-npots.sh \ + @../tools/disable-npots.sh \ gtester -o=test-conformance-results-dn.xml -k ./test-conformance \ && ( gtester-report test-conformance-results-dn.xml \ | sed 's/>GTester Unit Test ReportGTester Unit Test Report (no NPOTs) test-conformance-results-dn.html ) \ + > test-conformance-results-dn.html ) \ && gnome-open ./test-conformance-results-dn.html test-report: test-report-normal full-report-normal: - gtester -o=test-conformance-results.xml -k -m=slow ./test-conformance \ + @gtester -o=test-conformance-results.xml -k -m=slow ./test-conformance \ && ( gtester-report test-conformance-results.xml \ | sed 's/>GTester Unit Test ReportGTester Unit Test Report (normal) test-conformance-results.html ) + > test-conformance-results.html ) full-report-disable-npots: - ../tools/disable-npots.sh \ + @../tools/disable-npots.sh \ gtester -o=test-conformance-results-dn.xml -k -m=slow ./test-conformance \ && ( gtester-report test-conformance-results-dn.xml \ | sed 's/>GTester Unit Test ReportGTester Unit Test Report (no NPOTs) test-conformance-results-dn.html ) + > test-conformance-results-dn.html ) REPORTS = test-conformance-results.html if HAVE_LIBDL REPORTS += test-conformance-results-dn.html - full-report-generate: full-report-normal full-report-disable-npots else - full-report-generate: full-report-normal endif full-report: full-report-generate - for x in $(REPORTS); do \ + @for x in $(REPORTS); do \ gnome-open "$$x"; \ done -EXTRA_DIST = ADDING_NEW_TESTS - +EXTRA_DIST = ADDING_NEW_TESTS test-wrapper.sh diff --git a/tests/conform/test-launcher.sh b/tests/conform/test-launcher.sh new file mode 100755 index 000000000..b1f863962 --- /dev/null +++ b/tests/conform/test-launcher.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +UNIT_TEST_PATH=$1 + +test -z ${UNIT_TEST_PATH} && { + echo "Usage: $0 /path/to/unit_test" + exit 1 +} + +UNIT_TEST=`basename ${UNIT_TEST_PATH}` + +echo "Running: gtester -p ${UNIT_TEST_PATH} ./test-conformance" +echo "" +gtester -p ${UNIT_TEST_PATH} ./test-conformance + +echo "" +echo "NOTE: For debugging purposes, you can run this single test as follows:" +echo "$ libtool --mode=execute \\" +echo " gdb --eval-command=\"b ${UNIT_TEST}\" \\" +echo " --args ./test-conformance -p ${UNIT_TEST_PATH}" +echo "or:" +echo "$ env G_SLICE=always-malloc \\" +echo " libtool --mode=execute \\" +echo " valgrind ./test-conformance -p ${UNIT_TEST_PATH}" diff --git a/tests/conform/wrapper.sh b/tests/conform/wrapper.sh deleted file mode 100755 index 06d6a29e5..000000000 --- a/tests/conform/wrapper.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -UNIT_TEST=`basename $0` -UNIT_TEST_PATH=`./test-conformance -l -m thorough |grep '^/'|grep "$UNIT_TEST\$"` - -echo "Running: gtester -p $UNIT_TEST_PATH ./test-conformance" -echo "" -gtester -p $UNIT_TEST_PATH ./test-conformance - -echo "" -echo "NOTE: For debugging purposes, you can run this single test as follows:" -echo "$ libtool --mode=execute \\" -echo " gdb --eval-command=\"b $UNIT_TEST\" \\" -echo " --args ./test-conformance -p $UNIT_TEST_PATH" -echo "or:" -echo "$ env G_SLICE=always-malloc \\" -echo " libtool --mode=execute \\" -echo " valgrind ./test-conformance -p $UNIT_TEST_PATH"