Skip to content

Commit 2aa1471

Browse files
authored
Use btest_exit for test_gl_textures and test_html5_core. NFC (#18774)
These are the two tests otherwise starting failing with #18770. The reason is that.
1 parent fffa523 commit 2aa1471

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

test/gl_textures.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
#include <assert.h>
1313
#include <stdlib.h>
1414

15-
void report_result(int result)
16-
{
17-
if (result == 0) {
18-
printf("Test successful!\n");
19-
} else {
20-
printf("Test failed!\n");
21-
}
22-
#ifdef REPORT_RESULT
23-
REPORT_RESULT(result);
24-
#endif
25-
}
26-
2715
GLuint program;
2816

2917
#define PIX_C(x, y) ((x)/256.0f + (y)/256.0f)
@@ -53,7 +41,13 @@ void draw()
5341
assert(fabs((int)eRed - red) <= 2);
5442
}
5543
emscripten_cancel_main_loop();
56-
report_result(0);
44+
printf("Test successful!\n");
45+
#if _REENTRANT
46+
// In PROXY_TO_PTHREAD mode its currently not enough to cancel the main
47+
// loop and have the application exit:
48+
// https://github.com/emscripten-core/emscripten/issues/18773
49+
exit(0);
50+
#endif
5751
}
5852

5953
int main()
@@ -81,7 +75,7 @@ int main()
8175
char *buf = new char[maxLength];
8276
glGetShaderInfoLog(vs, maxLength, &maxLength, buf);
8377
printf("%s\n", buf);
84-
return 0;
78+
return 1;
8579
}
8680

8781
GLuint ps = glCreateShader(GL_FRAGMENT_SHADER);
@@ -96,7 +90,7 @@ int main()
9690
char *buf = new char[maxLength];
9791
glGetShaderInfoLog(ps, maxLength, &maxLength, buf);
9892
printf("%s\n", buf);
99-
return 0;
93+
return 1;
10094
}
10195

10296
program = glCreateProgram();
@@ -112,7 +106,7 @@ int main()
112106
char *buf = new char[maxLength];
113107
glGetProgramInfoLog(program, maxLength, &maxLength, buf);
114108
printf("%s\n", buf);
115-
return 0;
109+
return 1;
116110
}
117111

118112
glUseProgram(program);

test/test_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,7 @@ def test_gl_glteximage(self):
20102010
@requires_graphics_hardware
20112011
@requires_threads
20122012
def test_gl_textures(self, args):
2013-
self.btest('gl_textures.cpp', '0', args=['-lGL'] + args)
2013+
self.btest_exit('gl_textures.cpp', args=['-lGL'] + args)
20142014

20152015
@requires_graphics_hardware
20162016
def test_gl_ps(self):
@@ -2674,7 +2674,7 @@ def test_html5_core(self, opts):
26742674
});
26752675
''')
26762676
self.emcc_args.append('--pre-js=pre.js')
2677-
self.btest(test_file('test_html5_core.c'), args=opts, expected='0')
2677+
self.btest_exit(test_file('test_html5_core.c'), args=opts)
26782678

26792679
@requires_threads
26802680
def test_html5_gamepad(self):

test/test_html5_core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,11 @@ EM_BOOL webglcontext_callback(int eventType, const void *reserved, void *userDat
238238
return 0;
239239
}
240240

241-
#ifdef REPORT_RESULT
242-
void report_result(void *arg)
241+
#ifndef KEEP_ALIVE
242+
void test_done(void *arg)
243243
{
244244
emscripten_html5_remove_all_event_listeners();
245-
REPORT_RESULT(0);
245+
exit(0);
246246
}
247247
#endif
248248

@@ -428,11 +428,11 @@ int main()
428428
ret = (width && height) ? EMSCRIPTEN_RESULT_SUCCESS : EMSCRIPTEN_RESULT_FAILED;
429429
TEST_RESULT(emscripten_get_screen_size);
430430

431-
#ifdef REPORT_RESULT
432-
// Keep the page running for a moment.
433-
emscripten_async_call(report_result, 0, 5000);
434-
#else
431+
#ifdef KEEP_ALIVE
435432
emscripten_exit_with_live_runtime();
433+
#else
434+
// Keep the page running for a moment.
435+
emscripten_async_call(test_done, 0, 5000);
436436
#endif
437437
return 0;
438438
}

0 commit comments

Comments
 (0)