SDL: Fixed testautomation --filter pixels_allocFreeFormat (e56dc)

From e56dc9c30e7f4f2e5856fecec083783983565c4c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 7 Aug 2023 22:15:23 -0700
Subject: [PATCH] Fixed testautomation --filter pixels_allocFreeFormat

Error messages are not part of the ABI, so we can't validate those.

Technically SDL_AllocFormat() on a FOURCC format in SDL2 should fail, but SDL3 supports it and we don't expect SDL2 applications to actually do this, so skip that test.

Hand-picked from https://github.com/libsdl-org/sdl2-compat/commit/5cf9438f8870bb1f517935febf9d07b4f910a308
---
 test/testautomation_pixels.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c
index 3b806d60559d..72243eb5ab07 100644
--- a/test/testautomation_pixels.c
+++ b/test/testautomation_pixels.c
@@ -102,8 +102,8 @@ const char *_nonRGBPixelFormatsVerbose[] = {
 /* Definition of some invalid formats for negative tests */
 const int _numInvalidPixelFormats = 2;
 Uint32 _invalidPixelFormats[] = {
-    0xfffffffe,
-    0xffffffff
+    SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1010102 + 1, 32, 4),
+    SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1010102 + 2, 32, 4)
 };
 const char *_invalidPixelFormatsVerbose[] = {
     "SDL_PIXELFORMAT_UNKNOWN",
@@ -121,7 +121,6 @@ const char *_invalidPixelFormatsVerbose[] = {
 int pixels_allocFreeFormat(void *arg)
 {
     const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN";
-    const char *expectedError = "Parameter 'format' is invalid";
     const char *error;
     int i;
     Uint32 format;
@@ -172,6 +171,7 @@ int pixels_allocFreeFormat(void *arg)
         }
     }
 
+#if 0 /* This succeeds for SDL3, but we don't expect SDL2 applications to call SDL_AllocFormat() for FOURCC formats directly */
     /* Non-RGB formats */
     for (i = 0; i < _numNonRGBPixelFormats; i++) {
         format = _nonRGBPixelFormats[i];
@@ -182,6 +182,7 @@ int pixels_allocFreeFormat(void *arg)
         SDLTest_AssertPass("Call to SDL_AllocFormat()");
         SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
     }
+#endif
 
     /* Negative cases */
 
@@ -196,23 +197,6 @@ int pixels_allocFreeFormat(void *arg)
         error = SDL_GetError();
         SDLTest_AssertPass("Call to SDL_GetError()");
         SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
-        if (error != NULL) {
-            SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
-                                "Validate error message, expected: '%s', got: '%s'", expectedError, error);
-        }
-    }
-
-    /* Invalid free pointer */
-    SDL_ClearError();
-    SDLTest_AssertPass("Call to SDL_ClearError()");
-    SDL_FreeFormat(NULL);
-    SDLTest_AssertPass("Call to SDL_FreeFormat(NULL)");
-    error = SDL_GetError();
-    SDLTest_AssertPass("Call to SDL_GetError()");
-    SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
-    if (error != NULL) {
-        SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
-                            "Validate error message, expected: '%s', got: '%s'", expectedError, error);
     }
 
     return TEST_COMPLETED;