wasapi: Patched to compile on C89 systems, and use SDL_ceilf instead of ceilf.
1 /* See COPYING.txt for the full license governing this code. */
5 * Source file for the screenshot API.
8 #include "SDL_visualtest_mischelper.h"
12 SDLVisualTest_VerifyScreenshots(char* args, char* test_dir, char* verify_dir)
14 int i, verify_len, return_code, test_len;
16 char* verify_path; /* path to the bmp file used for verification */
17 char* test_path; /* path to the bmp file to be verified */
19 SDL_Surface* verifybmp;
25 SDLTest_LogError("args argument cannot be NULL");
27 goto verifyscreenshots_cleanup_generic;
31 SDLTest_LogError("test_dir argument cannot be NULL");
33 goto verifyscreenshots_cleanup_generic;
37 SDLTest_LogError("verify_dir argument cannot be NULL");
39 goto verifyscreenshots_cleanup_generic;
42 /* generate the MD5 hash */
43 SDLVisualTest_HashString(args, hash);
45 /* find the verification image */
46 /* path_len + hash_len + some number of extra characters */
47 verify_len = SDL_strlen(verify_dir) + 32 + 10;
48 verify_path = (char*)SDL_malloc(verify_len * sizeof(char));
51 SDLTest_LogError("malloc() failed");
53 goto verifyscreenshots_cleanup_generic;
55 SDL_snprintf(verify_path, verify_len - 1,
56 "%s/%s.bmp", verify_dir, hash);
57 rw = SDL_RWFromFile(verify_path, "rb");
60 SDLTest_Log("Verification image does not exist."
61 " Please manually verify that the SUT is working correctly.");
63 goto verifyscreenshots_cleanup_verifypath;
66 /* load the verification image */
67 verifybmp = SDL_LoadBMP_RW(rw, 1);
70 SDLTest_LogError("SDL_LoadBMP_RW() failed");
72 goto verifyscreenshots_cleanup_verifypath;
75 /* load the test images and compare with the verification image */
76 /* path_len + hash_len + some number of extra characters */
77 test_len = SDL_strlen(test_dir) + 32 + 10;
78 test_path = (char*)SDL_malloc(test_len * sizeof(char));
81 SDLTest_LogError("malloc() failed");
83 goto verifyscreenshots_cleanup_verifybmp;
92 SDL_snprintf(test_path, test_len - 1, "%s/%s.bmp", test_dir, hash);
94 SDL_snprintf(test_path, test_len - 1, "%s/%s_%d.bmp", test_dir, hash, i);
95 testrw = SDL_RWFromFile(test_path, "rb");
97 /* we keep going until we've iterated through the screenshots each
102 /* load the test screenshot */
103 testbmp = SDL_LoadBMP_RW(testrw, 1);
106 SDLTest_LogError("SDL_LoadBMP_RW() failed");
108 goto verifyscreenshots_cleanup_verifybmp;
111 /* compare with the verification image */
112 if(SDLTest_CompareSurfaces(testbmp, verifybmp, 0) != 0)
115 SDL_FreeSurface(testbmp);
116 goto verifyscreenshots_cleanup_verifybmp;
119 SDL_FreeSurface(testbmp);
124 SDLTest_LogError("No verification images found");
128 verifyscreenshots_cleanup_verifybmp:
129 SDL_FreeSurface(verifybmp);
131 verifyscreenshots_cleanup_verifypath:
132 SDL_free(verify_path);
134 verifyscreenshots_cleanup_generic: