More debugging information when test fails. gsoc2009_unit_tests
authorEdgar Simo <bobbens@gmail.com>
Thu, 06 Aug 2009 08:39:42 +0000
branchgsoc2009_unit_tests
changeset 37535b48a529fd8a
parent 3752 f47658c8f87a
child 3754 09d4fa3a787a
More debugging information when test fails.
test/automated/platform/platform.c
test/automated/platform/platform.h
test/automated/render/render.c
test/automated/testsdl.c
     1.1 --- a/test/automated/platform/platform.c	Wed Aug 05 18:56:56 2009 +0000
     1.2 +++ b/test/automated/platform/platform.c	Thu Aug 06 08:39:42 2009 +0000
     1.3 @@ -132,6 +132,64 @@
     1.4  
     1.5  
     1.6  /**
     1.7 + * @brief Gets the name of the platform.
     1.8 + */
     1.9 +const char *platform_getPlatform (void)
    1.10 +{
    1.11 +   return
    1.12 +#if __AIX__   
    1.13 +      "AIX"
    1.14 +#elif __BEOS__
    1.15 +      "BeOS"
    1.16 +#elif __BSDI__
    1.17 +      "BSDI"
    1.18 +#elif __DREAMCAST__
    1.19 +      "Dreamcast"
    1.20 +#elif __FREEBSD__
    1.21 +
    1.22 +      "FreeBSD"
    1.23 +#elif __HPUX__ 
    1.24 +      "HP-UX"
    1.25 +#elif __IRIX__ 
    1.26 +      "Irix"
    1.27 +#elif __LINUX__
    1.28 +      "Linux"
    1.29 +#elif __MINT__
    1.30 +      "Atari MiNT"
    1.31 +#elif __MACOS__
    1.32 +      "MacOS Classic"
    1.33 +#elif __MACOSX__
    1.34 +      "Mac OS X"
    1.35 +#elif __NETBSD__
    1.36 +      "NetBSD"
    1.37 +#elif __OPENBSD__
    1.38 +      "OpenBSD"
    1.39 +#elif __OS2__ 
    1.40 +      "OS/2"
    1.41 +#elif __OSF__ 
    1.42 +      "OSF/1"
    1.43 +#elif __QNXNTO__
    1.44 +      "QNX Neutrino"
    1.45 +#elif __RISCOS__
    1.46 +      "RISC OS"
    1.47 +#elif __SOLARIS__
    1.48 +      "Solaris"
    1.49 +#elif __WIN32__
    1.50 +#ifdef _WIN32_WCE
    1.51 +      "Windows CE"
    1.52 +#else         
    1.53 +      "Windows"
    1.54 +#endif
    1.55 +#elif __IPHONEOS__
    1.56 +      "iPhone OS"
    1.57 +#else         
    1.58 +      "an unknown operating system! (see SDL_platform.h)"
    1.59 +#endif     
    1.60 +      ;
    1.61 +}
    1.62 +
    1.63 +
    1.64 +/**
    1.65   * @brief Platform test entrypoint.
    1.66   */
    1.67  #ifdef TEST_STANDALONE
    1.68 @@ -147,56 +205,7 @@
    1.69     SDL_ATinit( "Platform" );
    1.70  
    1.71     /* Debug information. */
    1.72 -   SDL_ATprintVerbose( 1, "%s System detected\n",
    1.73 -#if __AIX__   
    1.74 -         "AIX"
    1.75 -#elif __BEOS__
    1.76 -         "BeOS"
    1.77 -#elif __BSDI__
    1.78 -         "BSDI"
    1.79 -#elif __DREAMCAST__
    1.80 -         "Dreamcast"
    1.81 -#elif __FREEBSD__
    1.82 -
    1.83 -         "FreeBSD"
    1.84 -#elif __HPUX__ 
    1.85 -         "HP-UX"
    1.86 -#elif __IRIX__ 
    1.87 -         "Irix"
    1.88 -#elif __LINUX__
    1.89 -         "Linux"
    1.90 -#elif __MINT__
    1.91 -         "Atari MiNT"
    1.92 -#elif __MACOS__
    1.93 -         "MacOS Classic"
    1.94 -#elif __MACOSX__
    1.95 -         "Mac OS X"
    1.96 -#elif __NETBSD__
    1.97 -         "NetBSD"
    1.98 -#elif __OPENBSD__
    1.99 -         "OpenBSD"
   1.100 -#elif __OS2__ 
   1.101 -         "OS/2"
   1.102 -#elif __OSF__ 
   1.103 -         "OSF/1"
   1.104 -#elif __QNXNTO__
   1.105 -         "QNX Neutrino"
   1.106 -#elif __RISCOS__
   1.107 -         "RISC OS"
   1.108 -#elif __SOLARIS__
   1.109 -         "Solaris"
   1.110 -#elif __WIN32__
   1.111 -#ifdef _WIN32_WCE
   1.112 -         "Windows CE"
   1.113 -#else         
   1.114 -         "Windows"
   1.115 -#endif
   1.116 -#elif __IPHONEOS__
   1.117 -         "iPhone OS"
   1.118 -#else         
   1.119 -         "an unknown operating system! (see SDL_platform.h)"
   1.120 -#endif     
   1.121 -         );
   1.122 +   SDL_ATprintVerbose( 1, "%s System detected\n", platform_getPlatform() );
   1.123     SDL_ATprintVerbose( 1, "System is %s endian\n",
   1.124  #ifdef SDL_LIL_ENDIAN
   1.125           "little"
     2.1 --- a/test/automated/platform/platform.h	Wed Aug 05 18:56:56 2009 +0000
     2.2 +++ b/test/automated/platform/platform.h	Thu Aug 06 08:39:42 2009 +0000
     2.3 @@ -11,6 +11,7 @@
     2.4  #  define _TEST_PLATFORM
     2.5  
     2.6  
     2.7 +const char *platform_getPlatform (void);
     2.8  int test_platform (void);
     2.9  
    2.10  
     3.1 --- a/test/automated/render/render.c	Wed Aug 05 18:56:56 2009 +0000
     3.2 +++ b/test/automated/render/render.c	Thu Aug 06 08:39:42 2009 +0000
     3.3 @@ -970,6 +970,7 @@
     3.4  int test_render (void)
     3.5  {
     3.6  #endif /* TEST_STANDALONE */
     3.7 +   int failed;
     3.8     int i, j, nd, nr;
     3.9     int ret;
    3.10     const char *driver, *str;
    3.11 @@ -997,6 +998,7 @@
    3.12      * Surface on video mode tests.
    3.13      */
    3.14     /* Run for all video modes. */
    3.15 +   failed = 0;
    3.16     for (i=0; i<nd; i++) {
    3.17        /* Get video mode. */
    3.18        driver = SDL_GetVideoDriver(i);
    3.19 @@ -1058,7 +1060,8 @@
    3.20           /*
    3.21            * Run tests.
    3.22            */
    3.23 -         if (render_runTests())
    3.24 +         ret = render_runTests();
    3.25 +         if (ret)
    3.26              continue;
    3.27  
    3.28           SDL_ATend();
    3.29 @@ -1070,16 +1073,16 @@
    3.30        /*
    3.31         * Finish testsuite.
    3.32         */
    3.33 -      SDL_ATfinish();
    3.34 +      failed += SDL_ATfinish();
    3.35     }
    3.36  
    3.37  
    3.38     /* Exit SDL. */
    3.39     SDL_Quit();
    3.40  
    3.41 -   return 0;
    3.42 +   return failed;
    3.43  
    3.44  err:
    3.45 -   return -1;
    3.46 +   return 1;
    3.47  }
    3.48  
     4.1 --- a/test/automated/testsdl.c	Wed Aug 05 18:56:56 2009 +0000
     4.2 +++ b/test/automated/testsdl.c	Thu Aug 06 08:39:42 2009 +0000
     4.3 @@ -7,6 +7,7 @@
     4.4   */
     4.5  
     4.6  
     4.7 +#include "SDL.h"
     4.8  #include "SDL_at.h"
     4.9  
    4.10  #include "platform/platform.h"
    4.11 @@ -128,22 +129,50 @@
    4.12   */
    4.13  int main( int argc, char *argv[] )
    4.14  {
    4.15 +   int failed;
    4.16 +   int rev;
    4.17 +   SDL_version ver;
    4.18 +
    4.19 +   /* Get options. */
    4.20     parse_options( argc, argv );
    4.21  
    4.22 +   /* Defaults. */
    4.23 +   failed = 0;
    4.24 +
    4.25 +   /* Print some text if verbose. */
    4.26 +   SDL_GetVersion( &ver );
    4.27 +   rev = SDL_GetRevision();
    4.28 +   SDL_ATprintVerbose( 1, "Running tests with SDL %d.%d.%d revision %d\n",
    4.29 +         ver.major, ver.minor, ver.patch, rev );
    4.30 +
    4.31     /* Automatic tests. */
    4.32     if (run_platform)
    4.33 -      test_platform();
    4.34 +      failed += test_platform();
    4.35     if (run_rwops)
    4.36 -      test_rwops();
    4.37 +      failed += test_rwops();
    4.38     if (run_surface)
    4.39 -      test_surface();
    4.40 +      failed += test_surface();
    4.41     if (run_render)
    4.42 -      test_render();
    4.43 +      failed += test_render();
    4.44  
    4.45     /* Manual tests. */
    4.46     if (run_manual) {
    4.47     }
    4.48  
    4.49 -   return 0;
    4.50 +   /* Display more information if failed. */
    4.51 +   if (failed > 0) {
    4.52 +      SDL_ATprintErr( "Tests run with SDL %d.%d.%d revision %d\n",
    4.53 +            ver.major, ver.minor, ver.patch, rev );
    4.54 +      SDL_ATprintErr( "System is running %s and is %s endian\n",
    4.55 +            platform_getPlatform(),
    4.56 +#ifdef SDL_LIL_ENDIAN
    4.57 +            "little"
    4.58 +#else
    4.59 +            "big"
    4.60 +#endif
    4.61 +            );
    4.62 +   }
    4.63 +
    4.64 +   return failed;
    4.65  }
    4.66