changeset 3753:5b48a529fd8a gsoc2009_unit_tests

More debugging information when test fails.
author Edgar Simo <bobbens@gmail.com>
date Thu, 06 Aug 2009 08:39:42 +0000
parents f47658c8f87a
children 09d4fa3a787a
files test/automated/platform/platform.c test/automated/platform/platform.h test/automated/render/render.c test/automated/testsdl.c
diffstat 4 files changed, 101 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/test/automated/platform/platform.c	Wed Aug 05 18:56:56 2009 +0000
+++ b/test/automated/platform/platform.c	Thu Aug 06 08:39:42 2009 +0000
@@ -132,6 +132,64 @@
 
 
 /**
+ * @brief Gets the name of the platform.
+ */
+const char *platform_getPlatform (void)
+{
+   return
+#if __AIX__   
+      "AIX"
+#elif __BEOS__
+      "BeOS"
+#elif __BSDI__
+      "BSDI"
+#elif __DREAMCAST__
+      "Dreamcast"
+#elif __FREEBSD__
+
+      "FreeBSD"
+#elif __HPUX__ 
+      "HP-UX"
+#elif __IRIX__ 
+      "Irix"
+#elif __LINUX__
+      "Linux"
+#elif __MINT__
+      "Atari MiNT"
+#elif __MACOS__
+      "MacOS Classic"
+#elif __MACOSX__
+      "Mac OS X"
+#elif __NETBSD__
+      "NetBSD"
+#elif __OPENBSD__
+      "OpenBSD"
+#elif __OS2__ 
+      "OS/2"
+#elif __OSF__ 
+      "OSF/1"
+#elif __QNXNTO__
+      "QNX Neutrino"
+#elif __RISCOS__
+      "RISC OS"
+#elif __SOLARIS__
+      "Solaris"
+#elif __WIN32__
+#ifdef _WIN32_WCE
+      "Windows CE"
+#else         
+      "Windows"
+#endif
+#elif __IPHONEOS__
+      "iPhone OS"
+#else         
+      "an unknown operating system! (see SDL_platform.h)"
+#endif     
+      ;
+}
+
+
+/**
  * @brief Platform test entrypoint.
  */
 #ifdef TEST_STANDALONE
@@ -147,56 +205,7 @@
    SDL_ATinit( "Platform" );
 
    /* Debug information. */
-   SDL_ATprintVerbose( 1, "%s System detected\n",
-#if __AIX__   
-         "AIX"
-#elif __BEOS__
-         "BeOS"
-#elif __BSDI__
-         "BSDI"
-#elif __DREAMCAST__
-         "Dreamcast"
-#elif __FREEBSD__
-
-         "FreeBSD"
-#elif __HPUX__ 
-         "HP-UX"
-#elif __IRIX__ 
-         "Irix"
-#elif __LINUX__
-         "Linux"
-#elif __MINT__
-         "Atari MiNT"
-#elif __MACOS__
-         "MacOS Classic"
-#elif __MACOSX__
-         "Mac OS X"
-#elif __NETBSD__
-         "NetBSD"
-#elif __OPENBSD__
-         "OpenBSD"
-#elif __OS2__ 
-         "OS/2"
-#elif __OSF__ 
-         "OSF/1"
-#elif __QNXNTO__
-         "QNX Neutrino"
-#elif __RISCOS__
-         "RISC OS"
-#elif __SOLARIS__
-         "Solaris"
-#elif __WIN32__
-#ifdef _WIN32_WCE
-         "Windows CE"
-#else         
-         "Windows"
-#endif
-#elif __IPHONEOS__
-         "iPhone OS"
-#else         
-         "an unknown operating system! (see SDL_platform.h)"
-#endif     
-         );
+   SDL_ATprintVerbose( 1, "%s System detected\n", platform_getPlatform() );
    SDL_ATprintVerbose( 1, "System is %s endian\n",
 #ifdef SDL_LIL_ENDIAN
          "little"
--- a/test/automated/platform/platform.h	Wed Aug 05 18:56:56 2009 +0000
+++ b/test/automated/platform/platform.h	Thu Aug 06 08:39:42 2009 +0000
@@ -11,6 +11,7 @@
 #  define _TEST_PLATFORM
 
 
+const char *platform_getPlatform (void);
 int test_platform (void);
 
 
--- a/test/automated/render/render.c	Wed Aug 05 18:56:56 2009 +0000
+++ b/test/automated/render/render.c	Thu Aug 06 08:39:42 2009 +0000
@@ -970,6 +970,7 @@
 int test_render (void)
 {
 #endif /* TEST_STANDALONE */
+   int failed;
    int i, j, nd, nr;
    int ret;
    const char *driver, *str;
@@ -997,6 +998,7 @@
     * Surface on video mode tests.
     */
    /* Run for all video modes. */
+   failed = 0;
    for (i=0; i<nd; i++) {
       /* Get video mode. */
       driver = SDL_GetVideoDriver(i);
@@ -1058,7 +1060,8 @@
          /*
           * Run tests.
           */
-         if (render_runTests())
+         ret = render_runTests();
+         if (ret)
             continue;
 
          SDL_ATend();
@@ -1070,16 +1073,16 @@
       /*
        * Finish testsuite.
        */
-      SDL_ATfinish();
+      failed += SDL_ATfinish();
    }
 
 
    /* Exit SDL. */
    SDL_Quit();
 
-   return 0;
+   return failed;
 
 err:
-   return -1;
+   return 1;
 }
 
--- a/test/automated/testsdl.c	Wed Aug 05 18:56:56 2009 +0000
+++ b/test/automated/testsdl.c	Thu Aug 06 08:39:42 2009 +0000
@@ -7,6 +7,7 @@
  */
 
 
+#include "SDL.h"
 #include "SDL_at.h"
 
 #include "platform/platform.h"
@@ -128,22 +129,50 @@
  */
 int main( int argc, char *argv[] )
 {
+   int failed;
+   int rev;
+   SDL_version ver;
+
+   /* Get options. */
    parse_options( argc, argv );
 
+   /* Defaults. */
+   failed = 0;
+
+   /* Print some text if verbose. */
+   SDL_GetVersion( &ver );
+   rev = SDL_GetRevision();
+   SDL_ATprintVerbose( 1, "Running tests with SDL %d.%d.%d revision %d\n",
+         ver.major, ver.minor, ver.patch, rev );
+
    /* Automatic tests. */
    if (run_platform)
-      test_platform();
+      failed += test_platform();
    if (run_rwops)
-      test_rwops();
+      failed += test_rwops();
    if (run_surface)
-      test_surface();
+      failed += test_surface();
    if (run_render)
-      test_render();
+      failed += test_render();
 
    /* Manual tests. */
    if (run_manual) {
    }
 
-   return 0;
+   /* Display more information if failed. */
+   if (failed > 0) {
+      SDL_ATprintErr( "Tests run with SDL %d.%d.%d revision %d\n",
+            ver.major, ver.minor, ver.patch, rev );
+      SDL_ATprintErr( "System is running %s and is %s endian\n",
+            platform_getPlatform(),
+#ifdef SDL_LIL_ENDIAN
+            "little"
+#else
+            "big"
+#endif
+            );
+   }
+
+   return failed;
 }