Both these functions can potentially return NULL if there was an error.
This can be an issue when run in a Docker container using a user ID for a user that doesn't exist in /etc/passwd in the container image. In particular the HOME environment variable may not be set, which can cause SDL_GetPrefPath to fail. Setting HOME to a path that is writable can allow the unit tests to work.
To better detect this situation, we convert the NULL error code to an exception with the message from SDL_GetError.
While investigating some failures for the Arch Linux build, we discovered we didn't properly check the return code for a couple of SDL path functions:
SDL_GetBasePath
SDL_GetPrefPath
Both these functions can potentially return
NULL
if there was an error.This can be an issue when run in a Docker container using a user ID for a user that doesn't exist in
/etc/passwd
in the container image. In particular theHOME
environment variable may not be set, which can causeSDL_GetPrefPath
to fail. SettingHOME
to a path that is writable can allow the unit tests to work.To better detect this situation, we convert the
NULL
error code to an exception with the message fromSDL_GetError
.