Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
authorAndreas Schiffler <aschiffler@ferzkopp.net>
Wed, 19 Mar 2014 21:39:55 -0700
changeset 8645d69fdbefeecf
parent 8644 f218b4e65498
child 8646 0a20fff4de3c
Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
VisualC/tests/testautomation/testautomation_VS2008.vcproj
VisualC/tests/testautomation/testautomation_vs2010.vcxproj
VisualC/tests/testautomation/testautomation_vs2012.vcxproj
VisualC/tests/testautomation/testautomation_vs2013.vcxproj
src/stdlib/SDL_getenv.c
test/Makefile.in
test/testautomation_hints.c
test/testautomation_stdlib.c
test/testautomation_suites.h
     1.1 --- a/VisualC/tests/testautomation/testautomation_VS2008.vcproj	Wed Mar 19 22:43:30 2014 -0400
     1.2 +++ b/VisualC/tests/testautomation/testautomation_VS2008.vcproj	Wed Mar 19 21:39:55 2014 -0700
     1.3 @@ -271,6 +271,10 @@
     1.4  			RelativePath="..\..\..\test\testautomation_video.c"
     1.5  			>
     1.6  		</File>
     1.7 +		<File
     1.8 +			RelativePath="..\..\..\test\testautomation_hints.c"
     1.9 +			>
    1.10 +		</File>
    1.11  	</Files>
    1.12  	<Globals>
    1.13  	</Globals>
     2.1 --- a/VisualC/tests/testautomation/testautomation_vs2010.vcxproj	Wed Mar 19 22:43:30 2014 -0400
     2.2 +++ b/VisualC/tests/testautomation/testautomation_vs2010.vcxproj	Wed Mar 19 21:39:55 2014 -0700
     2.3 @@ -194,6 +194,7 @@
     2.4      <ClCompile Include="..\..\..\test\testautomation_syswm.c" />
     2.5      <ClCompile Include="..\..\..\test\testautomation_timer.c" />
     2.6      <ClCompile Include="..\..\..\test\testautomation_video.c" />
     2.7 +    <ClCompile Include="..\..\..\test\testautomation_hints.c" />
     2.8    </ItemGroup>
     2.9    <ItemGroup>
    2.10      <ClInclude Include="..\..\..\test\testautomation_suites.h" />
     3.1 --- a/VisualC/tests/testautomation/testautomation_vs2012.vcxproj	Wed Mar 19 22:43:30 2014 -0400
     3.2 +++ b/VisualC/tests/testautomation/testautomation_vs2012.vcxproj	Wed Mar 19 21:39:55 2014 -0700
     3.3 @@ -198,6 +198,7 @@
     3.4      <ClCompile Include="..\..\..\test\testautomation_syswm.c" />
     3.5      <ClCompile Include="..\..\..\test\testautomation_timer.c" />
     3.6      <ClCompile Include="..\..\..\test\testautomation_video.c" />
     3.7 +    <ClCompile Include="..\..\..\test\testautomation_hints.c" />
     3.8    </ItemGroup>
     3.9    <ItemGroup>
    3.10      <ClInclude Include="..\..\..\test\testautomation_suites.h" />
     4.1 --- a/VisualC/tests/testautomation/testautomation_vs2013.vcxproj	Wed Mar 19 22:43:30 2014 -0400
     4.2 +++ b/VisualC/tests/testautomation/testautomation_vs2013.vcxproj	Wed Mar 19 21:39:55 2014 -0700
     4.3 @@ -198,6 +198,7 @@
     4.4      <ClCompile Include="..\..\..\test\testautomation_syswm.c" />
     4.5      <ClCompile Include="..\..\..\test\testautomation_timer.c" />
     4.6      <ClCompile Include="..\..\..\test\testautomation_video.c" />
     4.7 +    <ClCompile Include="..\..\..\test\testautomation_hints.c" />
     4.8    </ItemGroup>
     4.9    <ItemGroup>
    4.10      <ClInclude Include="..\..\..\test\testautomation_suites.h" />
     5.1 --- a/src/stdlib/SDL_getenv.c	Wed Mar 19 22:43:30 2014 -0400
     5.2 +++ b/src/stdlib/SDL_getenv.c	Wed Mar 19 21:39:55 2014 -0700
     5.3 @@ -33,16 +33,27 @@
     5.4  #endif
     5.5  
     5.6  /* Put a variable into the environment */
     5.7 +/* Note: Name may not contain a '=' character. (Reference: http://www.unix.com/man-page/Linux/3/setenv/) */
     5.8  #if defined(HAVE_SETENV)
     5.9  int
    5.10  SDL_setenv(const char *name, const char *value, int overwrite)
    5.11  {
    5.12 +    /* Input validation */
    5.13 +    if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
    5.14 +        return (-1);
    5.15 +    }
    5.16 +    
    5.17      return setenv(name, value, overwrite);
    5.18  }
    5.19  #elif defined(__WIN32__)
    5.20  int
    5.21  SDL_setenv(const char *name, const char *value, int overwrite)
    5.22  {
    5.23 +    /* Input validation */
    5.24 +    if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
    5.25 +        return (-1);
    5.26 +    }
    5.27 +    
    5.28      if (!overwrite) {
    5.29          char ch = 0;
    5.30          const size_t len = GetEnvironmentVariableA(name, &ch, sizeof (ch));
    5.31 @@ -63,6 +74,11 @@
    5.32      size_t len;
    5.33      char *new_variable;
    5.34  
    5.35 +    /* Input validation */
    5.36 +    if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
    5.37 +        return (-1);
    5.38 +    }
    5.39 +    
    5.40      if (getenv(name) != NULL) {
    5.41          if (overwrite) {
    5.42              unsetenv(name);
    5.43 @@ -91,8 +107,8 @@
    5.44      char **new_env;
    5.45      char *new_variable;
    5.46  
    5.47 -    /* A little error checking */
    5.48 -    if (!name || !value) {
    5.49 +    /* Input validation */
    5.50 +    if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
    5.51          return (-1);
    5.52      }
    5.53  
    5.54 @@ -152,6 +168,11 @@
    5.55  char *
    5.56  SDL_getenv(const char *name)
    5.57  {
    5.58 +    /* Input validation */
    5.59 +    if (!name || SDL_strlen(name)==0) {
    5.60 +        return NULL;
    5.61 +    }
    5.62 +
    5.63      return getenv(name);
    5.64  }
    5.65  #elif defined(__WIN32__)
    5.66 @@ -160,6 +181,11 @@
    5.67  {
    5.68      size_t bufferlen;
    5.69  
    5.70 +    /* Input validation */
    5.71 +    if (!name || SDL_strlen(name)==0) {
    5.72 +        return NULL;
    5.73 +    }
    5.74 +    
    5.75      bufferlen =
    5.76          GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
    5.77      if (bufferlen == 0) {
    5.78 @@ -183,6 +209,11 @@
    5.79      int len, i;
    5.80      char *value;
    5.81  
    5.82 +    /* Input validation */
    5.83 +    if (!name || SDL_strlen(name)==0) {
    5.84 +        return NULL;
    5.85 +    }
    5.86 +    
    5.87      value = (char *) 0;
    5.88      if (SDL_env) {
    5.89          len = SDL_strlen(name);
     6.1 --- a/test/Makefile.in	Wed Mar 19 22:43:30 2014 -0400
     6.2 +++ b/test/Makefile.in	Wed Mar 19 21:39:55 2014 -0700
     6.3 @@ -92,7 +92,8 @@
     6.4  		      $(srcdir)/testautomation_surface.c \
     6.5  		      $(srcdir)/testautomation_syswm.c \
     6.6  		      $(srcdir)/testautomation_timer.c \
     6.7 -		      $(srcdir)/testautomation_video.c
     6.8 +		      $(srcdir)/testautomation_video.c \
     6.9 +		      $(srcdir)/testautomation_hints.c
    6.10  	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) 
    6.11  
    6.12  testmultiaudio$(EXE): $(srcdir)/testmultiaudio.c
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/test/testautomation_hints.c	Wed Mar 19 21:39:55 2014 -0700
     7.3 @@ -0,0 +1,168 @@
     7.4 +/**
     7.5 + * Hints test suite
     7.6 + */
     7.7 +
     7.8 +#include <stdio.h>
     7.9 +
    7.10 +#include "SDL.h"
    7.11 +#include "SDL_test.h"
    7.12 +
    7.13 +
    7.14 +const int _numHintsEnum = 25;
    7.15 +char* _HintsEnum[] =
    7.16 +  {
    7.17 +    SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
    7.18 +    SDL_HINT_FRAMEBUFFER_ACCELERATION,
    7.19 +    SDL_HINT_GAMECONTROLLERCONFIG,
    7.20 +    SDL_HINT_GRAB_KEYBOARD,
    7.21 +    SDL_HINT_IDLE_TIMER_DISABLED,
    7.22 +    SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
    7.23 +    SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK,
    7.24 +    SDL_HINT_MOUSE_RELATIVE_MODE_WARP,
    7.25 +    SDL_HINT_ORIENTATIONS,
    7.26 +    SDL_HINT_RENDER_DIRECT3D_THREADSAFE,
    7.27 +    SDL_HINT_RENDER_DRIVER,
    7.28 +    SDL_HINT_RENDER_OPENGL_SHADERS,
    7.29 +    SDL_HINT_RENDER_SCALE_QUALITY,
    7.30 +    SDL_HINT_RENDER_VSYNC,
    7.31 +    SDL_HINT_TIMER_RESOLUTION,
    7.32 +    SDL_HINT_VIDEO_ALLOW_SCREENSAVER,
    7.33 +    SDL_HINT_VIDEO_HIGHDPI_DISABLED,
    7.34 +    SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES,
    7.35 +    SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
    7.36 +    SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT,
    7.37 +    SDL_HINT_VIDEO_WIN_D3DCOMPILER,
    7.38 +    SDL_HINT_VIDEO_X11_XINERAMA,
    7.39 +    SDL_HINT_VIDEO_X11_XRANDR,
    7.40 +    SDL_HINT_VIDEO_X11_XVIDMODE,
    7.41 +    SDL_HINT_XINPUT_ENABLED,
    7.42 +  };
    7.43 +char* _HintsVerbose[] =
    7.44 +  {
    7.45 +    "SDL_HINT_ACCELEROMETER_AS_JOYSTICK",
    7.46 +    "SDL_HINT_FRAMEBUFFER_ACCELERATION",
    7.47 +    "SDL_HINT_GAMECONTROLLERCONFIG",
    7.48 +    "SDL_HINT_GRAB_KEYBOARD",
    7.49 +    "SDL_HINT_IDLE_TIMER_DISABLED",
    7.50 +    "SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS",
    7.51 +    "SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK",
    7.52 +    "SDL_HINT_MOUSE_RELATIVE_MODE_WARP",
    7.53 +    "SDL_HINT_ORIENTATIONS",
    7.54 +    "SDL_HINT_RENDER_DIRECT3D_THREADSAFE",
    7.55 +    "SDL_HINT_RENDER_DRIVER",
    7.56 +    "SDL_HINT_RENDER_OPENGL_SHADERS",
    7.57 +    "SDL_HINT_RENDER_SCALE_QUALITY",
    7.58 +    "SDL_HINT_RENDER_VSYNC",
    7.59 +    "SDL_HINT_TIMER_RESOLUTION",
    7.60 +    "SDL_HINT_VIDEO_ALLOW_SCREENSAVER",
    7.61 +    "SDL_HINT_VIDEO_HIGHDPI_DISABLED",
    7.62 +    "SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES",
    7.63 +    "SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS",
    7.64 +    "SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT",
    7.65 +    "SDL_HINT_VIDEO_WIN_D3DCOMPILER",
    7.66 +    "SDL_HINT_VIDEO_X11_XINERAMA",
    7.67 +    "SDL_HINT_VIDEO_X11_XRANDR",
    7.68 +    "SDL_HINT_VIDEO_X11_XVIDMODE",
    7.69 +    "SDL_HINT_XINPUT_ENABLED"
    7.70 +  };
    7.71 +
    7.72 +
    7.73 +/* Test case functions */
    7.74 +
    7.75 +/**
    7.76 + * @brief Call to SDL_GetHint
    7.77 + */
    7.78 +int
    7.79 +hints_getHint(void *arg)
    7.80 +{
    7.81 +  char *result1;
    7.82 +  char *result2;
    7.83 +  int i;
    7.84 +    
    7.85 +  for (i=0; i<_numHintsEnum; i++) {
    7.86 +    result1 = (char *)SDL_GetHint((char*)_HintsEnum[i]);
    7.87 +    SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char*)_HintsEnum[i]);
    7.88 +    result2 = (char *)SDL_GetHint((char *)_HintsVerbose[i]);
    7.89 +    SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]);
    7.90 +    SDLTest_AssertCheck(
    7.91 +      (result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0),
    7.92 +      "Verify returned values are equal; got: result1='%s' result2='%s",
    7.93 +      (result1 == NULL) ? "null" : result1,
    7.94 +      (result2 == NULL) ? "null" : result2);
    7.95 +  }
    7.96 +  
    7.97 +  return TEST_COMPLETED;
    7.98 +}
    7.99 +
   7.100 +/**
   7.101 + * @brief Call to SDL_SetHint
   7.102 + */
   7.103 +int
   7.104 +hints_setHint(void *arg)
   7.105 +{
   7.106 +  char *originalValue;
   7.107 +  char *value;
   7.108 +  char *testValue;
   7.109 +  SDL_bool result;
   7.110 +  int i, j;
   7.111 +
   7.112 +  /* Create random values to set */                    
   7.113 +  value = SDLTest_RandomAsciiStringOfSize(10);
   7.114 +    
   7.115 +  for (i=0; i<_numHintsEnum; i++) {
   7.116 +    /* Capture current value */
   7.117 +    originalValue = (char *)SDL_GetHint((char*)_HintsEnum[i]);
   7.118 +    SDLTest_AssertPass("Call to SDL_GetHint(%s)", (char*)_HintsEnum[i]);
   7.119 +    
   7.120 +    /* Set value (twice) */
   7.121 +    for (j=1; j<=2; j++) {
   7.122 +      result = SDL_SetHint((char*)_HintsEnum[i], value);
   7.123 +      SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", (char*)_HintsEnum[i], value, j);
   7.124 +      SDLTest_AssertCheck(
   7.125 +        result == SDL_TRUE || result == SDL_FALSE, 
   7.126 +        "Verify valid result was returned, got: %i",
   7.127 +        (int)result);
   7.128 +      testValue = (char *)SDL_GetHint((char*)_HintsEnum[i]);
   7.129 +      SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]);
   7.130 +      SDLTest_AssertCheck(
   7.131 +        (SDL_strcmp(value, testValue) == 0),
   7.132 +        "Verify returned value equals set value; got: testValue='%s' value='%s",
   7.133 +        (testValue == NULL) ? "null" : testValue,
   7.134 +        value);
   7.135 +    }
   7.136 +      
   7.137 +    /* Reset original value */
   7.138 +    result = SDL_SetHint((char*)_HintsEnum[i], originalValue);
   7.139 +    SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", (char*)_HintsEnum[i]);
   7.140 +    SDLTest_AssertCheck(
   7.141 +      result == SDL_TRUE || result == SDL_FALSE, 
   7.142 +      "Verify valid result was returned, got: %i",
   7.143 +      (int)result);
   7.144 +  }
   7.145 +  
   7.146 +  SDL_free(value);
   7.147 +  
   7.148 +  return TEST_COMPLETED;
   7.149 +}
   7.150 +
   7.151 +/* ================= Test References ================== */
   7.152 +
   7.153 +/* Hints test cases */
   7.154 +static const SDLTest_TestCaseReference hintsTest1 =
   7.155 +        { (SDLTest_TestCaseFp)hints_getHint, "hints_getHint", "Call to SDL_GetHint", TEST_ENABLED };
   7.156 +
   7.157 +static const SDLTest_TestCaseReference hintsTest2 =
   7.158 +        { (SDLTest_TestCaseFp)hints_setHint, "hints_setHint", "Call to SDL_SetHint", TEST_ENABLED };
   7.159 +
   7.160 +/* Sequence of Hints test cases */
   7.161 +static const SDLTest_TestCaseReference *hintsTests[] =  {
   7.162 +    &hintsTest1, &hintsTest2, NULL
   7.163 +};
   7.164 +
   7.165 +/* Hints test suite (global) */
   7.166 +SDLTest_TestSuiteReference hintsTestSuite = {
   7.167 +    "Hints",
   7.168 +    NULL,
   7.169 +    hintsTests,
   7.170 +    NULL
   7.171 +};
     8.1 --- a/test/testautomation_stdlib.c	Wed Mar 19 22:43:30 2014 -0400
     8.2 +++ b/test/testautomation_stdlib.c	Wed Mar 19 21:39:55 2014 -0700
     8.3 @@ -119,6 +119,140 @@
     8.4    return TEST_COMPLETED;
     8.5  }
     8.6  
     8.7 +/**
     8.8 + * @brief Call to SDL_getenv and SDL_setenv
     8.9 + */
    8.10 +int
    8.11 +stdlib_getsetenv(void *arg)
    8.12 +{
    8.13 +  const int nameLen = 16;
    8.14 +  int counter;
    8.15 +  int result;
    8.16 +  char name[nameLen + 1];
    8.17 +  char * value1;
    8.18 +  char * value2;
    8.19 +  char * expected;
    8.20 +  int overwrite;
    8.21 +  char * text;
    8.22 +
    8.23 +  /* Create a random name. This tests SDL_getenv, since we need to */
    8.24 +  /* make sure the variable is not set yet (it shouldn't). */
    8.25 +  do {
    8.26 +    for(counter = 0; counter < nameLen; counter++) {
    8.27 +      name[counter] = (char)SDLTest_RandomIntegerInRange(65, 90);
    8.28 +    }
    8.29 +    name[nameLen] = '\0';
    8.30 +    
    8.31 +    text = SDL_getenv(name);
    8.32 +    SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
    8.33 +    if (text != NULL) {
    8.34 +      SDLTest_Log("Expected: NULL, Got: '%s' (%i)", text, SDL_strlen(text));
    8.35 +    }
    8.36 +  } while (text != NULL);
    8.37 +   
    8.38 +  /* Create random values to set */                    
    8.39 +  value1 = SDLTest_RandomAsciiStringOfSize(10);
    8.40 +  value2 = SDLTest_RandomAsciiStringOfSize(10);
    8.41 +
    8.42 +  /* Set value 1 without overwrite */
    8.43 +  overwrite = 0;
    8.44 +  expected = value1;
    8.45 +  result = SDL_setenv(name, value1, overwrite);
    8.46 +  SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value1, overwrite);
    8.47 +  SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
    8.48 +
    8.49 +  /* Check value */
    8.50 +  text = SDL_getenv(name);
    8.51 +  SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
    8.52 +  SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL");
    8.53 +  if (text != NULL) {
    8.54 +    SDLTest_AssertCheck(
    8.55 +      SDL_strcmp(text, expected) == 0, 
    8.56 +      "Verify returned text, expected: %s, got: %s",
    8.57 +      expected,
    8.58 +      text);
    8.59 +  }
    8.60 +  
    8.61 +  /* Set value 2 with overwrite */
    8.62 +  overwrite = 1;
    8.63 +  expected = value2;    
    8.64 +  result = SDL_setenv(name, value2, overwrite);
    8.65 +  SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value2, overwrite);
    8.66 +  SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
    8.67 +
    8.68 +  /* Check value */
    8.69 +  text = SDL_getenv(name);
    8.70 +  SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
    8.71 +  SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL");
    8.72 +  if (text != NULL) {
    8.73 +    SDLTest_AssertCheck(
    8.74 +      SDL_strcmp(text, expected) == 0, 
    8.75 +      "Verify returned text, expected: %s, got: %s",
    8.76 +      expected,
    8.77 +      text);
    8.78 +  }
    8.79 +
    8.80 +  /* Set value 1 without overwrite */
    8.81 +  overwrite = 0;
    8.82 +  expected = value2;    
    8.83 +  result = SDL_setenv(name, value1, overwrite);
    8.84 +  SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value1, overwrite);
    8.85 +  SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
    8.86 +
    8.87 +  /* Check value */
    8.88 +  text = SDL_getenv(name);
    8.89 +  SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
    8.90 +  SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL");
    8.91 +  if (text != NULL) {
    8.92 +    SDLTest_AssertCheck(
    8.93 +      SDL_strcmp(text, expected) == 0, 
    8.94 +      "Verify returned text, expected: %s, got: %s",
    8.95 +      expected,
    8.96 +      text);
    8.97 +  }
    8.98 +  
    8.99 +  /* Set value 1 without overwrite */
   8.100 +  overwrite = 1;
   8.101 +  expected = value1;
   8.102 +  result = SDL_setenv(name, value1, overwrite);
   8.103 +  SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value1, overwrite);
   8.104 +  SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
   8.105 +
   8.106 +  /* Check value */
   8.107 +  text = SDL_getenv(name);
   8.108 +  SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
   8.109 +  SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL");
   8.110 +  if (text != NULL) {
   8.111 +    SDLTest_AssertCheck(
   8.112 +      SDL_strcmp(text, expected) == 0, 
   8.113 +      "Verify returned text, expected: %s, got: %s",
   8.114 +      expected,
   8.115 +      text);
   8.116 +  }
   8.117 +
   8.118 +  /* Negative cases */
   8.119 +  for (overwrite=0; overwrite <= 1; overwrite++) { 
   8.120 +    result = SDL_setenv(NULL, value1, overwrite);
   8.121 +    SDLTest_AssertPass("Call to SDL_setenv(NULL,'%s', %i)", value1, overwrite);
   8.122 +    SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result);
   8.123 +    result = SDL_setenv("", value1, overwrite);
   8.124 +    SDLTest_AssertPass("Call to SDL_setenv('','%s', %i)", value1, overwrite);
   8.125 +    SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result);
   8.126 +    result = SDL_setenv("=", value1, overwrite);
   8.127 +    SDLTest_AssertPass("Call to SDL_setenv('=','%s', %i)", value1, overwrite);
   8.128 +    SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result);
   8.129 +    result = SDL_setenv(name, NULL, overwrite);
   8.130 +    SDLTest_AssertPass("Call to SDL_setenv('%s', NULL, %i)", name, overwrite);
   8.131 +    SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result);
   8.132 +  }
   8.133 +
   8.134 +  /* Clean up */
   8.135 +  SDL_free(value1);
   8.136 +  SDL_free(value2);
   8.137 +    
   8.138 +  return TEST_COMPLETED;
   8.139 +}
   8.140 +
   8.141  /* ================= Test References ================== */
   8.142  
   8.143  /* Standard C routine test cases */
   8.144 @@ -128,14 +262,17 @@
   8.145  static const SDLTest_TestCaseReference stdlibTest2 =
   8.146          { (SDLTest_TestCaseFp)stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED };
   8.147  
   8.148 +static const SDLTest_TestCaseReference stdlibTest3 =
   8.149 +        { (SDLTest_TestCaseFp)stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED };
   8.150 +
   8.151  /* Sequence of Standard C routine test cases */
   8.152  static const SDLTest_TestCaseReference *stdlibTests[] =  {
   8.153 -    &stdlibTest1, &stdlibTest2, NULL
   8.154 +    &stdlibTest1, &stdlibTest2, &stdlibTest3, NULL
   8.155  };
   8.156  
   8.157  /* Timer test suite (global) */
   8.158  SDLTest_TestSuiteReference stdlibTestSuite = {
   8.159 -    "Standard C routines",
   8.160 +    "Stdlib",
   8.161      NULL,
   8.162      stdlibTests,
   8.163      NULL
     9.1 --- a/test/testautomation_suites.h	Wed Mar 19 22:43:30 2014 -0400
     9.2 +++ b/test/testautomation_suites.h	Wed Mar 19 21:39:55 2014 -0700
     9.3 @@ -26,6 +26,7 @@
     9.4  extern SDLTest_TestSuiteReference syswmTestSuite;
     9.5  extern SDLTest_TestSuiteReference timerTestSuite;
     9.6  extern SDLTest_TestSuiteReference videoTestSuite;
     9.7 +extern SDLTest_TestSuiteReference hintsTestSuite;
     9.8  
     9.9  /* All test suites */
    9.10  SDLTest_TestSuiteReference *testSuites[] =  {
    9.11 @@ -46,6 +47,7 @@
    9.12      &syswmTestSuite,
    9.13      &timerTestSuite,
    9.14      &videoTestSuite,
    9.15 +    &hintsTestSuite,
    9.16      NULL
    9.17  };
    9.18