aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runner.py2
-rw-r--r--tests/sdl_surface_refcount.c17
2 files changed, 16 insertions, 3 deletions
diff --git a/tests/runner.py b/tests/runner.py
index b2dff6f4..6daa9c36 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -13173,7 +13173,7 @@ Press any key to continue.'''
self.btest('sdl_alloctext.c', expected='1', args=['-O2', '-s', 'TOTAL_MEMORY=' + str(1024*1024*8)])
def test_sdl_surface_refcount(self):
- self.btest('sdl_surface_refcount.c', expected='0')
+ self.btest('sdl_surface_refcount.c', expected='1')
def test_glbegin_points(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
diff --git a/tests/sdl_surface_refcount.c b/tests/sdl_surface_refcount.c
index c4314ebf..5e0f30a9 100644
--- a/tests/sdl_surface_refcount.c
+++ b/tests/sdl_surface_refcount.c
@@ -1,15 +1,28 @@
+#include <emscripten.h>
#include <SDL.h>
#include <stdio.h>
+#include <stdlib.h>
+
+int is_surface_freed(SDL_Surface *surface)
+{
+ const char *template = "!SDL.surfaces[%d]";
+ int length = snprintf(NULL, 0, template, surface) + 1;
+ char *script = malloc(length * sizeof(char));
+ snprintf(script, length, template, surface);
+ int is_freed = emscripten_run_script_int(script);
+ free(script);
+ return is_freed;
+}
int main(int argc, char *argv[])
{
- SDL_Surface* surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 10, 10, 32,
+ SDL_Surface *surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 10, 10, 32,
0, 0, 0, 0);
SDL_Surface *reference = surface;
reference->refcount++;
SDL_FreeSurface(surface);
SDL_FreeSurface(reference);
- int result = surface->refcount;
+ int result = is_surface_freed(surface);
REPORT_RESULT();
return 0;
}