Bunch of little fixes.
authorMarkus Kauppila
Sun, 10 Jul 2011 18:42:52 +0300
changeset 5751cbb921210496
parent 5750 337982ee35ac
child 5752 528866846266
Bunch of little fixes.
test/test-automation/SDL_test.c
test/test-automation/SDL_test.h
test/test-automation/common/common.c
test/test-automation/plain_logger.c
test/test-automation/runner.c
test/test-automation/testaudio/Makefile.am
test/test-automation/testaudio/testaudio.c
test/test-automation/testdummy/Makefile.am
test/test-automation/testdummy/testdummy.c
test/test-automation/testplatform/Makefile.am
test/test-automation/testrect/Makefile.am
test/test-automation/testsurface/Makefile.am
test/test-automation/testsurface/testsurface.c
     1.1 --- a/test/test-automation/SDL_test.c	Sat Jul 09 17:55:35 2011 +0300
     1.2 +++ b/test/test-automation/SDL_test.c	Sun Jul 10 18:42:52 2011 +0300
     1.3 @@ -18,9 +18,6 @@
     1.4    3. This notice may not be removed or altered from any source distribution.
     1.5  */
     1.6  
     1.7 -#ifndef _SDL_TEST_C
     1.8 -#define _SDL_TEST_C
     1.9 -
    1.10  #include <stdio.h> /* printf/fprintf */
    1.11  #include <stdarg.h> /* va_list */
    1.12  #include <time.h>
    1.13 @@ -60,15 +57,17 @@
    1.14  }
    1.15  
    1.16  void
    1.17 -AssertEquals(Uint32 expected, Uint32 actual, char* message, ...)
    1.18 +AssertEquals(const int expected, const int actual, char *message, ...)
    1.19  {
    1.20     va_list args;
    1.21     char buf[256];
    1.22  
    1.23 -   if(expected != actual) {
    1.24 -      va_start( args, message );
    1.25 -      SDL_vsnprintf( buf, sizeof(buf), message, args );
    1.26 -      va_end( args );
    1.27 +   va_start( args, message );
    1.28 +   memset(buf, 0, sizeof(buf));
    1.29 +   SDL_vsnprintf( buf, sizeof(buf), message, args );
    1.30 +   va_end( args );
    1.31 +
    1.32 +   if(expected != expected) {
    1.33        AssertWithValues("AssertEquals", 0, buf, actual, expected, time(0));
    1.34  
    1.35        _testReturnValue = 1;
    1.36 @@ -77,6 +76,7 @@
    1.37  	   AssertWithValues("AssertEquals", 1, buf,
    1.38      		  actual, expected, time(0));
    1.39  
    1.40 +      _testReturnValue = 0;
    1.41        _testAssertsPassed++;
    1.42     }
    1.43  }
    1.44 @@ -86,22 +86,19 @@
    1.45  {
    1.46     va_list args;
    1.47     char buf[256];
    1.48 +   va_start( args, message );
    1.49 +   SDL_vsnprintf( buf, sizeof(buf), message, args );
    1.50 +   va_end( args );
    1.51  
    1.52     if (!condition) {
    1.53 -      va_start( args, message );
    1.54 -      SDL_vsnprintf( buf, sizeof(buf), message, args );
    1.55 -      va_end( args );
    1.56 -
    1.57        Assert("AssertTrue", 0, buf, time(0));
    1.58  
    1.59        _testReturnValue = 1;
    1.60        _testAssertsFailed++;
    1.61     } else {
    1.62 -		va_start( args, message );
    1.63 -		SDL_vsnprintf( buf, sizeof(buf), message, args );
    1.64 -		va_end( args );
    1.65 +		Assert("AssertTrue", 1, buf, time(0));
    1.66  
    1.67 -		Assert("AssertTrue", 1, buf, time(0));
    1.68 +		_testReturnValue = 0;
    1.69  		_testAssertsPassed++;
    1.70     }
    1.71  }
    1.72 @@ -118,6 +115,7 @@
    1.73  
    1.74     Assert("AssertPass", 1, buf, time(0));
    1.75  
    1.76 +   _testReturnValue = 0;
    1.77     _testAssertsPassed++;
    1.78  }
    1.79  
    1.80 @@ -133,7 +131,7 @@
    1.81  
    1.82     Assert("AssertFail", 0, buf, time(0));
    1.83  
    1.84 +   _testReturnValue = 1;
    1.85     _testAssertsFailed++;
    1.86  }
    1.87  
    1.88 -#endif
     2.1 --- a/test/test-automation/SDL_test.h	Sat Jul 09 17:55:35 2011 +0300
     2.2 +++ b/test/test-automation/SDL_test.h	Sun Jul 10 18:42:52 2011 +0300
     2.3 @@ -73,8 +73,7 @@
     2.4   * \param actual The actual value of tested variable
     2.5   * \param message Message that will be printed if assert fails
     2.6   */
     2.7 -void AssertEquals(Uint32 expected, Uint32 actual, char *message, ...);
     2.8 -
     2.9 +void AssertEquals(const int expected, const int actual, char *message, ...);
    2.10  /*!
    2.11   *  Assert function. Tests if the given condition is true. True in
    2.12   *  this case means non-zero value. If the condition is true, the
     3.1 --- a/test/test-automation/common/common.c	Sat Jul 09 17:55:35 2011 +0300
     3.2 +++ b/test/test-automation/common/common.c	Sun Jul 10 18:42:52 2011 +0300
     3.3 @@ -7,11 +7,14 @@
     3.4   */
     3.5  
     3.6  
     3.7 -
     3.8  #include "common.h"
     3.9  
    3.10  /**
    3.11 - * @brief Compares a surface and a surface image for equality.
    3.12 + * @brief Compares a surface and a surface image for equality
    3.13 + *
    3.14 + * @param sur Surface used in comparison
    3.15 + * @param img Surface image used in comparison
    3.16 + * @param allowable_error Allowable difference in blending accuracy
    3.17   */
    3.18  int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img, int allowable_error )
    3.19  {
     4.1 --- a/test/test-automation/plain_logger.c	Sat Jul 09 17:55:35 2011 +0300
     4.2 +++ b/test/test-automation/plain_logger.c	Sun Jul 10 18:42:52 2011 +0300
     4.3 @@ -126,7 +126,7 @@
     4.4  void
     4.5  PlainLog(const char *logMessage, time_t eventTime)
     4.6  {
     4.7 -	Output(indentLevel, "%s %d", logMessage, eventTime);
     4.8 +	Output(indentLevel, "%s %d", logMessage, TimestampToString(eventTime));
     4.9  }
    4.10  
    4.11  #endif
     5.1 --- a/test/test-automation/runner.c	Sat Jul 09 17:55:35 2011 +0300
     5.2 +++ b/test/test-automation/runner.c	Sun Jul 10 18:42:52 2011 +0300
     5.3 @@ -516,8 +516,8 @@
     5.4  		returnValue = WEXITSTATUS(stat_lock);
     5.5  	} else if(WIFSIGNALED(stat_lock)) {
     5.6  		int signal = WTERMSIG(stat_lock);
     5.7 -		// \todo add this to logger
     5.8 -		//fprintf(stderr, "FAILURE: test was aborted due to signal no %d\n", signal);
     5.9 +		// \todo add this to logger (add signal number)
    5.10 +		Log("FAILURE: test was aborted due to signal\n", time(0));
    5.11  		returnValue = 1;
    5.12  	}
    5.13  
     6.1 --- a/test/test-automation/testaudio/Makefile.am	Sat Jul 09 17:55:35 2011 +0300
     6.2 +++ b/test/test-automation/testaudio/Makefile.am	Sun Jul 10 18:42:52 2011 +0300
     6.3 @@ -1,4 +1,4 @@
     6.4  lib_LTLIBRARIES = libtestaudio.la
     6.5 -libtestaudio_la_SOURCES = testaudio.c ../SDL_test.c ../logger.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c
     6.6 +libtestaudio_la_SOURCES = testaudio.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c
     6.7  libtestaudio_la_CLAGS = -fPIC -g
     6.8 -libtestaudio_la_LDFLAGS = `sdl-config --libs`
     6.9 \ No newline at end of file
    6.10 +libtestaudio_la_LDFLAGS = `sdl-config --libs`
     7.1 --- a/test/test-automation/testaudio/testaudio.c	Sat Jul 09 17:55:35 2011 +0300
     7.2 +++ b/test/test-automation/testaudio/testaudio.c	Sun Jul 10 18:42:52 2011 +0300
     7.3 @@ -1,22 +1,6 @@
     7.4 -/*
     7.5 -  Copyright (C) 2011 Markus Kauppila <markus.kauppila@gmail.com>
     7.6 -
     7.7 -  This software is provided 'as-is', without any express or implied
     7.8 -  warranty.  In no event will the authors be held liable for any damages
     7.9 -  arising from the use of this software.
    7.10 -
    7.11 -  Permission is granted to anyone to use this software for any purpose,
    7.12 -  including commercial applications, and to alter it and redistribute it
    7.13 -  freely, subject to the following restrictions:
    7.14 -
    7.15 -  1. The origin of this software must not be misrepresented; you must not
    7.16 -     claim that you wrote the original software. If you use this software
    7.17 -     in a product, an acknowledgment in the product documentation would be
    7.18 -     appreciated but is not required.
    7.19 -  2. Altered source versions must be plainly marked as such, and must not be
    7.20 -     misrepresented as being the original software.
    7.21 -  3. This notice may not be removed or altered from any source distribution.
    7.22 -*/
    7.23 +/**
    7.24 + * Original code: automated SDL rect test written by Edgar Simo "bobbens"
    7.25 + */
    7.26  
    7.27  #include <stdio.h>
    7.28  
     8.1 --- a/test/test-automation/testdummy/Makefile.am	Sat Jul 09 17:55:35 2011 +0300
     8.2 +++ b/test/test-automation/testdummy/Makefile.am	Sun Jul 10 18:42:52 2011 +0300
     8.3 @@ -1,4 +1,4 @@
     8.4  lib_LTLIBRARIES = libtestdummy.la
     8.5 -libtestdummy_la_SOURCES = testdummy.c ../SDL_test.c ../logger.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c
     8.6 +libtestdummy_la_SOURCES = testdummy.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c
     8.7  libtestdummy_la_CLAGS = -fPIC -g
     8.8  libtestdummy_la_LDFLAGS = `sdl-config --libs`
     9.1 --- a/test/test-automation/testdummy/testdummy.c	Sat Jul 09 17:55:35 2011 +0300
     9.2 +++ b/test/test-automation/testdummy/testdummy.c	Sun Jul 10 18:42:52 2011 +0300
     9.3 @@ -24,9 +24,6 @@
     9.4   * various asserts and (possible) other utilities.
     9.5   */
     9.6  
     9.7 -#ifndef _TEST_C
     9.8 -#define _TEST_C
     9.9 -
    9.10  #include <stdio.h>
    9.11  
    9.12  #include <SDL/SDL.h>
    9.13 @@ -59,7 +56,7 @@
    9.14  void
    9.15  dummycase1(void *arg)
    9.16  {
    9.17 -	AssertEquals(3, 5, "fails");
    9.18 +	AssertEquals(5, 5, "Assert message");
    9.19  }
    9.20  
    9.21  void
    9.22 @@ -67,13 +64,12 @@
    9.23  {
    9.24  	char *msg = "eello";
    9.25  	//msg[0] = 'H';
    9.26 -	AssertTrue(0, "fails");
    9.27 +	AssertTrue(1, "Assert message");
    9.28  }
    9.29  
    9.30  void
    9.31  dummycase3(void *arg)
    9.32  {
    9.33 -	AssertTrue(1, "passes");
    9.34 +	AssertTrue(1, "Assert message");
    9.35  }
    9.36  
    9.37 -#endif
    10.1 --- a/test/test-automation/testplatform/Makefile.am	Sat Jul 09 17:55:35 2011 +0300
    10.2 +++ b/test/test-automation/testplatform/Makefile.am	Sun Jul 10 18:42:52 2011 +0300
    10.3 @@ -1,4 +1,4 @@
    10.4  lib_LTLIBRARIES = libtestplatform.la
    10.5 -libtestplatform_la_SOURCES = testplatform.c ../SDL_test.c ../logger.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c
    10.6 +libtestplatform_la_SOURCES = testplatform.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c
    10.7  libtestplatform_la_CLAGS = -fPIC -g
    10.8  libtestplatform_la_LDFLAGS = `sdl-config --libs`
    11.1 --- a/test/test-automation/testrect/Makefile.am	Sat Jul 09 17:55:35 2011 +0300
    11.2 +++ b/test/test-automation/testrect/Makefile.am	Sun Jul 10 18:42:52 2011 +0300
    11.3 @@ -1,4 +1,4 @@
    11.4  lib_LTLIBRARIES = libtestrect.la
    11.5 -libtestrect_la_SOURCES = testrect.c ../SDL_test.c ../logger.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c
    11.6 +libtestrect_la_SOURCES = testrect.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c
    11.7  libtestrect_la_CLAGS = -fPIC -g
    11.8  libtestrect_la_LDFLAGS = `sdl-config --libs`
    12.1 --- a/test/test-automation/testsurface/Makefile.am	Sat Jul 09 17:55:35 2011 +0300
    12.2 +++ b/test/test-automation/testsurface/Makefile.am	Sun Jul 10 18:42:52 2011 +0300
    12.3 @@ -1,5 +1,5 @@
    12.4  lib_LTLIBRARIES = libtestsurface.la
    12.5 -libtestsurface_la_SOURCES = testsurface.c ../SDL_test.c ../logger.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c \ 
    12.6 +libtestsurface_la_SOURCES = testsurface.c ../SDL_test.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c \
    12.7  	../common/common.c ../common/img_blit.c ../common/img_blitblend.c ../common/img_face.c ../common/img_primitives.c ../common/img_primitivesblend.c
    12.8  libtestsurface_la_CLAGS = -fPIC -g
    12.9  libtestsurface_la_LDFLAGS = `sdl-config --libs`
    13.1 --- a/test/test-automation/testsurface/testsurface.c	Sat Jul 09 17:55:35 2011 +0300
    13.2 +++ b/test/test-automation/testsurface/testsurface.c	Sun Jul 10 18:42:52 2011 +0300
    13.3 @@ -2,8 +2,6 @@
    13.4   * Original code: automated SDL surface test written by Edgar Simo "bobbens"
    13.5   */
    13.6  
    13.7 -#ifndef _TEST_C
    13.8 -#define _TEST_C
    13.9  #include <stdio.h>
   13.10  
   13.11  #include <SDL/SDL.h>
   13.12 @@ -53,6 +51,9 @@
   13.13  	return testsur;
   13.14  }
   13.15  
   13.16 +/**
   13.17 + * @brief Tests a blend mode.
   13.18 + */
   13.19  int testBlitBlendMode(SDL_Surface *testsur, SDL_Surface *face, int mode)
   13.20  {
   13.21  	int ret;
   13.22 @@ -63,7 +64,7 @@
   13.23  	ret = SDL_FillRect( testsur, NULL,
   13.24  		 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
   13.25  	if(ret == 0)
   13.26 -	  return 1;
   13.27 +		return 1;
   13.28  
   13.29  	/* Steps to take. */
   13.30  	ni     = testsur->w - face->w;
   13.31 @@ -90,7 +91,7 @@
   13.32  	  }
   13.33  	}
   13.34  
   13.35 -	   return 0;
   13.36 +	return 0;
   13.37  }
   13.38  
   13.39  /* Test case functions */
   13.40 @@ -265,13 +266,6 @@
   13.41     SDL_Quit();
   13.42  }
   13.43  
   13.44 -
   13.45 -/**
   13.46 - * @brief Tests a blend mode.
   13.47 - */
   13.48 -
   13.49 -
   13.50 -
   13.51  /**
   13.52   * @brief Tests some more blitting routines.
   13.53   */
   13.54 @@ -327,26 +321,25 @@
   13.55     if (testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE ))
   13.56        return;
   13.57     AssertTrue(surface_compare( testsur, &img_blendNone, 0 ) == 0,
   13.58 -		   "Blitting blending output not the same (using SDL_BLENDMODE_NONE).");
   13.59 -
   13.60 +   		   "Blitting blending output not the same (using SDL_BLENDMODE_NONE).");
   13.61  
   13.62     /* Test Blend. */
   13.63     if (testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND ))
   13.64        return;
   13.65     AssertTrue(surface_compare( testsur, &img_blendBlend, 0 ) == 0,
   13.66 -		   "Blitting blending output not the same (using SDL_BLENDMODE_BLEND).");
   13.67 +   		   "Blitting blending output not the same (using SDL_BLENDMODE_BLEND).");
   13.68  
   13.69     /* Test Add. */
   13.70     if (testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD ))
   13.71        return;
   13.72     AssertTrue(surface_compare( testsur, &img_blendAdd, 0 ) == 0,
   13.73 -		      "Blitting blending output not the same (using SDL_BLENDMODE_ADD).");
   13.74 +   		      "Blitting blending output not the same (using SDL_BLENDMODE_ADD).");
   13.75  
   13.76     /* Test Mod. */
   13.77     if (testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD ))
   13.78        return;
   13.79     AssertTrue(surface_compare( testsur, &img_blendMod, 0 ) == 0,
   13.80 -		      "Blitting blending output not the same (using SDL_BLENDMODE_MOD).");
   13.81 +   		      "Blitting blending output not the same (using SDL_BLENDMODE_MOD).");
   13.82  
   13.83     /* Clear surface. */
   13.84     ret = SDL_FillRect( testsur, NULL,
   13.85 @@ -394,5 +387,3 @@
   13.86  
   13.87     SDL_Quit();
   13.88  }
   13.89 -
   13.90 -#endif