From dd385d401304aab8a3d92f5034fc65d5973eab37 Mon Sep 17 00:00:00 2001 From: Markus Kauppila Date: Wed, 20 Jul 2011 19:32:34 +0300 Subject: [PATCH 1/4] Using SDL timer to kill hung tests. --- test/test-automation/runner.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/test/test-automation/runner.c b/test/test-automation/runner.c index 5de61d3b5..09eaf6f4c 100644 --- a/test/test-automation/runner.c +++ b/test/test-automation/runner.c @@ -585,29 +585,39 @@ LoadCountFailedAssertsFunction(void *suite) { * \param timeout Timeout interval in seconds! * \param callback Function that will be called after timeout has elapsed */ -void SetTestTimeout(int timeout, void (*callback)(int)) +void +SetTestTimeout(int timeout, void (*callback)(int)) { if(callback == NULL) { fprintf(stderr, "Error: timeout callback can't be NULL"); } + if(timeout < 0) { fprintf(stderr, "Error: timeout value must be bigger than zero."); } -#if 0 + int tm = (timeout > universal_timeout ? timeout : universal_timeout); + +#if 1 + /* Init SDL timer if not initialized before */ + if(SDL_WasInit(SDL_INIT_TIMER) == 0) { + if(SDL_InitSubSystem(SDL_INIT_TIMER)) { + fprintf(stderr, "Error: Failed to init timer subsystem"); + fprintf(stderr, "%s\n", SDL_GetError()); + } + } + /* Note: * SDL_Init(SDL_INIT_TIMER) should be successfully called before using this */ - int timeoutInMilliseconds = timeout * 1000; + int timeoutInMilliseconds = tm * 1000; + SDL_TimerID timerID = SDL_AddTimer(timeoutInMilliseconds, callback, 0x0); if(timerID == NULL) { fprintf(stderr, "Error: Creation of SDL timer failed.\n"); - fprintf(stderr, "%s\n", SDL_GetError()); + fprintf(stderr, "Error: %s\n", SDL_GetError()); } #else - - int tm = (timeout > universal_timeout ? timeout : universal_timeout); - signal(SIGALRM, callback); alarm((unsigned int) tm); #endif @@ -1075,5 +1085,8 @@ main(int argc, char *argv[]) RunEnded(totalTestPassCount + totalTestFailureCount, suiteCounter, totalTestPassCount, totalTestFailureCount, totalTestSkipCount, time(0), totalRunTime); + // Some SDL subsystem might be init'ed so shut them down + SDL_Quit(); + return (totalTestFailureCount ? 1 : 0); } From 9a121a3f4ab0616c5c1dfb1fda942d5a8a10ffba Mon Sep 17 00:00:00 2001 From: Markus Kauppila Date: Wed, 20 Jul 2011 19:57:42 +0300 Subject: [PATCH 2/4] Fixing linking issues using shared object. --- test/test-automation/Makefile.am | 9 ++++++++- test/test-automation/testdummy/Makefile.am | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/test-automation/Makefile.am b/test/test-automation/Makefile.am index b76e3a186..c77ec1fbc 100644 --- a/test/test-automation/Makefile.am +++ b/test/test-automation/Makefile.am @@ -3,10 +3,17 @@ ACLOCAL_AMFLAGS = -I acinclude -I build-scripts SUBDIRS = testdummy testrect testplatform testaudio testsurface bin_PROGRAMS = runner -runner_SOURCES = runner.c SDL_test.c xml_logger.c plain_logger.c xml.c logger_helpers.c support.c +runner_SOURCES = runner.c support.c runner_CLAGS = -W -Wall -Wextra -g `sdl-config --cflags` -DSDL_NO_COMPAT +runner_LDADD = libtest.la runner_LDFLAGS = `sdl-config --libs` +lib_LTLIBRARIES = libtest.la +libtest_la_SOURCES = SDL_test.c logger_helpers.c plain_logger.c xml_logger.c xml.c \ + common/common.c common/img_blit.c common/img_blitblend.c common/img_face.c common/img_primitives.c common/img_primitivesblend.c +libtest_la_CLAGS = -fPIC -g +libtest_la_LDFLAGS = `sdl-config --libs` + install: install-tests install-tests: $(SHELL) build-scripts/install-tests.sh diff --git a/test/test-automation/testdummy/Makefile.am b/test/test-automation/testdummy/Makefile.am index afe805d23..a2734afea 100644 --- a/test/test-automation/testdummy/Makefile.am +++ b/test/test-automation/testdummy/Makefile.am @@ -1,4 +1,5 @@ lib_LTLIBRARIES = libtestdummy.la -libtestdummy_la_SOURCES = testdummy.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c +libtestdummy_la_SOURCES = testdummy.c libtestdummy_la_CLAGS = -fPIC -g +libtestdummy_la_LIBADD = ../libtest.la libtestdummy_la_LDFLAGS = `sdl-config --libs` From 24ca1fde390725109071441772bf00a915126ab6 Mon Sep 17 00:00:00 2001 From: Markus Kauppila Date: Wed, 20 Jul 2011 23:37:58 +0300 Subject: [PATCH 3/4] Fixed linking issue concerning test suites. Fixed linux build (it compiles and runs properly). --- test/test-automation/Makefile.am | 4 ++++ test/test-automation/configure.ac | 2 +- test/test-automation/testaudio/Makefile.am | 4 ++-- test/test-automation/testdummy/Makefile.am | 3 +-- test/test-automation/testdummy/testdummy.c | 2 +- test/test-automation/testplatform/Makefile.am | 4 ++-- test/test-automation/testrect/Makefile.am | 4 ++-- test/test-automation/testsurface/Makefile.am | 5 ++--- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/test/test-automation/Makefile.am b/test/test-automation/Makefile.am index c77ec1fbc..d4959f47a 100644 --- a/test/test-automation/Makefile.am +++ b/test/test-automation/Makefile.am @@ -14,6 +14,10 @@ libtest_la_SOURCES = SDL_test.c logger_helpers.c plain_logger.c xml_logger.c xml libtest_la_CLAGS = -fPIC -g libtest_la_LDFLAGS = `sdl-config --libs` +libtest: libtest.la + echo "Test library compiled." + +all-local: install-tests install: install-tests install-tests: $(SHELL) build-scripts/install-tests.sh diff --git a/test/test-automation/configure.ac b/test/test-automation/configure.ac index 3865547e3..4b7468604 100644 --- a/test/test-automation/configure.ac +++ b/test/test-automation/configure.ac @@ -44,4 +44,4 @@ echo "" echo "========================================" echo "" echo "./configure ready!" -echo "you're ready to run: 'make && make install'" +echo "you're ready to run: 'make libtest && make'" diff --git a/test/test-automation/testaudio/Makefile.am b/test/test-automation/testaudio/Makefile.am index e888033a7..ee9a0d14d 100644 --- a/test/test-automation/testaudio/Makefile.am +++ b/test/test-automation/testaudio/Makefile.am @@ -1,4 +1,4 @@ lib_LTLIBRARIES = libtestaudio.la -libtestaudio_la_SOURCES = testaudio.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c +libtestaudio_la_SOURCES = testaudio.c libtestaudio_la_CLAGS = -fPIC -g -libtestaudio_la_LDFLAGS = `sdl-config --libs` +libtestaudio_la_LDFLAGS = `sdl-config --libs` -I ../.libs/libtest.la diff --git a/test/test-automation/testdummy/Makefile.am b/test/test-automation/testdummy/Makefile.am index a2734afea..cfd098c17 100644 --- a/test/test-automation/testdummy/Makefile.am +++ b/test/test-automation/testdummy/Makefile.am @@ -1,5 +1,4 @@ lib_LTLIBRARIES = libtestdummy.la libtestdummy_la_SOURCES = testdummy.c libtestdummy_la_CLAGS = -fPIC -g -libtestdummy_la_LIBADD = ../libtest.la -libtestdummy_la_LDFLAGS = `sdl-config --libs` +libtestdummy_la_LDFLAGS = `sdl-config --libs` -I ../.libs/libtest.la diff --git a/test/test-automation/testdummy/testdummy.c b/test/test-automation/testdummy/testdummy.c index a4f740bc6..ec2dcbfdf 100644 --- a/test/test-automation/testdummy/testdummy.c +++ b/test/test-automation/testdummy/testdummy.c @@ -95,7 +95,7 @@ void dummycase2(void *arg) { char *msg = "eello"; - msg[0] = 'H'; + //msg[0] = 'H'; AssertTrue(1, "Assert message"); } diff --git a/test/test-automation/testplatform/Makefile.am b/test/test-automation/testplatform/Makefile.am index 08d823495..82818e719 100644 --- a/test/test-automation/testplatform/Makefile.am +++ b/test/test-automation/testplatform/Makefile.am @@ -1,4 +1,4 @@ lib_LTLIBRARIES = libtestplatform.la -libtestplatform_la_SOURCES = testplatform.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c +libtestplatform_la_SOURCES = testplatform.c libtestplatform_la_CLAGS = -fPIC -g -libtestplatform_la_LDFLAGS = `sdl-config --libs` +libtestplatform_la_LDFLAGS = `sdl-config --libs` -I ../.libs/libtest.la diff --git a/test/test-automation/testrect/Makefile.am b/test/test-automation/testrect/Makefile.am index e79e85ef0..27219bea2 100644 --- a/test/test-automation/testrect/Makefile.am +++ b/test/test-automation/testrect/Makefile.am @@ -1,4 +1,4 @@ lib_LTLIBRARIES = libtestrect.la -libtestrect_la_SOURCES = testrect.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c +libtestrect_la_SOURCES = testrect.c libtestrect_la_CLAGS = -fPIC -g -libtestrect_la_LDFLAGS = `sdl-config --libs` +libtestrect_la_LDFLAGS = `sdl-config --libs` -I ../.libs/libtest.la diff --git a/test/test-automation/testsurface/Makefile.am b/test/test-automation/testsurface/Makefile.am index 38f54d26c..27826d5d8 100644 --- a/test/test-automation/testsurface/Makefile.am +++ b/test/test-automation/testsurface/Makefile.am @@ -1,5 +1,4 @@ lib_LTLIBRARIES = libtestsurface.la -libtestsurface_la_SOURCES = testsurface.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c \ - ../common/common.c ../common/img_blit.c ../common/img_blitblend.c ../common/img_face.c ../common/img_primitives.c ../common/img_primitivesblend.c +libtestsurface_la_SOURCES = testsurface.c libtestsurface_la_CLAGS = -fPIC -g -libtestsurface_la_LDFLAGS = `sdl-config --libs` +libtestsurface_la_LDFLAGS = `sdl-config --libs` -I ../.libs/libtest.la From 2d1a635550314f366533f54ea557b05740f222e2 Mon Sep 17 00:00:00 2001 From: Markus Kauppila Date: Thu, 21 Jul 2011 13:57:55 +0300 Subject: [PATCH 4/4] Added count of skipped tests to default xsl style. --- test/test-automation/Makefile.am | 2 +- test/test-automation/style.xsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-automation/Makefile.am b/test/test-automation/Makefile.am index d4959f47a..fe88cf2f3 100644 --- a/test/test-automation/Makefile.am +++ b/test/test-automation/Makefile.am @@ -15,7 +15,7 @@ libtest_la_CLAGS = -fPIC -g libtest_la_LDFLAGS = `sdl-config --libs` libtest: libtest.la - echo "Test library compiled." + echo "Test library compiled." all-local: install-tests install: install-tests diff --git a/test/test-automation/style.xsl b/test/test-automation/style.xsl index 69515f4f7..52ca9aa6a 100644 --- a/test/test-automation/style.xsl +++ b/test/test-automation/style.xsl @@ -181,7 +181,7 @@ div, h1 { Statistics:
Executed test suites.
- Tests in total: (passed: , failed: ) + Tests in total: (passed: , failed: , skipped: )