aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/aniso.c10
-rwxr-xr-xtests/runner.py24
-rw-r--r--tests/sdl_ogl_proc_alias.c180
-rw-r--r--tests/sockets/test_sockets_echo_server.c8
-rw-r--r--tests/sockets/test_sockets_partial_server.c24
-rw-r--r--tests/sockets/webrtc_host.c89
-rw-r--r--tests/sockets/webrtc_peer.c81
-rw-r--r--tests/test_browser.py117
-rw-r--r--tests/test_core.py8
-rw-r--r--tests/test_sockets.py68
10 files changed, 533 insertions, 76 deletions
diff --git a/tests/aniso.c b/tests/aniso.c
index 1126265e..f210e5a5 100644
--- a/tests/aniso.c
+++ b/tests/aniso.c
@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
for (int x = 0; x < n; x++) {
int start = x*w*2;
glBegin( GL_TRIANGLES );
- glTexCoord2i( 1, 0 ); glVertex3f( start , 0, 0 );
+ glTexCoord2i( 1, 0 ); glVertex2i( start , 0 );
glTexCoord2i( 0, 0 ); glVertex3f( start+w, 300, 0 );
glTexCoord2i( 1, 1 ); glVertex3f( start-w, 300, 0 );
glEnd();
@@ -209,5 +209,11 @@ int main(int argc, char *argv[])
SDL_Quit();
- return 0;
+ // check for asm compilation bug with aliased functions with different sigs
+ void (*f)(int, int) = glVertex2i;
+ if ((int)f % 16 == 4) f(5, 7);
+ void (*g)(int, int) = glVertex3f;
+ if ((int)g % 16 == 4) g(5, 7);
+ return (int)f + (int)g;
}
+
diff --git a/tests/runner.py b/tests/runner.py
index 2f508dfc..318946e6 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -275,6 +275,18 @@ process(sys.argv[1])
print "Output: " + output[0]
return output[0]
+ # Tests that the given two paths are identical, modulo path delimiters. E.g. "C:/foo" is equal to "C:\foo".
+ def assertPathsIdentical(self, path1, path2):
+ path1 = path1.replace('\\', '/')
+ path2 = path2.replace('\\', '/')
+ return self.assertIdentical(path1, path2)
+
+ # Tests that the given two multiline text content are identical, modulo line ending differences (\r\n on Windows, \n on Unix).
+ def assertTextDataIdentical(self, text1, text2):
+ text1 = text1.replace('\r\n', '\n')
+ text2 = text2.replace('\r\n', '\n')
+ return self.assertIdentical(text1, text2)
+
def assertIdentical(self, values, y):
if type(values) not in [list, tuple]: values = [values]
for x in values:
@@ -480,7 +492,7 @@ def server_func(dir, q):
if 'report_' in s.path:
q.put(s.path)
else:
- filename = s.path[1:]
+ filename = s.path.split('?')[0][1:]
if os.path.exists(filename):
s.send_response(200)
s.send_header("Content-type", "text/html")
@@ -649,6 +661,7 @@ class BrowserCore(RunnerCore):
self.reftest(path_from_root('tests', reference))
args = args + ['--pre-js', 'reftest.js', '-s', 'GL_TESTING=1']
Popen([PYTHON, EMCC, temp_filepath, '-o', outfile] + args).communicate()
+ assert os.path.exists(outfile)
if type(expected) is str: expected = [expected]
self.run_browser(outfile, message, ['/report_result?' + e for e in expected])
@@ -765,10 +778,17 @@ an individual test with
except:
pass
+ numFailures = 0 # Keep count of the total number of failing tests.
+
# Run the discovered tests
if not len(suites):
print >> sys.stderr, 'No tests found for %s' % str(sys.argv[1:])
+ numFailures = 1
else:
testRunner = unittest.TextTestRunner(verbosity=2)
for suite in suites:
- testRunner.run(suite)
+ results = testRunner.run(suite)
+ numFailures += len(results.errors) + len(results.failures)
+
+ # Return the number of failures as the process exit code for automating success/failure reporting.
+ exit(numFailures)
diff --git a/tests/sdl_ogl_proc_alias.c b/tests/sdl_ogl_proc_alias.c
new file mode 100644
index 00000000..c96da81b
--- /dev/null
+++ b/tests/sdl_ogl_proc_alias.c
@@ -0,0 +1,180 @@
+/*******************************************************************
+ * *
+ * Using SDL With OpenGL *
+ * *
+ * Tutorial by Kyle Foley (sdw) *
+ * *
+ * http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL *
+ * *
+ *******************************************************************/
+
+/*
+THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION
+AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN.
+
+THE ORIGINAL AUTHOR IS KYLE FOLEY.
+
+THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY
+OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF
+MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE,
+ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE
+RESULTING FROM THE USE, MODIFICATION, OR
+REDISTRIBUTION OF THIS SOFTWARE.
+*/
+
+#include "SDL/SDL.h"
+#include "SDL/SDL_image.h"
+#include "SDL/SDL_opengl.h"
+
+#include <stdio.h>
+#include <string.h>
+
+void (*true_glGenTextures)(GLsizei, GLuint*) = NULL;
+
+void glGenTextures(GLsizei n, GLuint *textures) {
+ printf("num? %d\n", n);
+ true_glGenTextures(n + 1, textures); // correct the error, ensures we are gone through
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen;
+
+ // Slightly different SDL initialization
+ if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) {
+ printf("Unable to initialize SDL: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // *new*
+
+ screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL ); // *changed*
+ if ( !screen ) {
+ printf("Unable to set video mode: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ // Set the OpenGL state after creating the context with SDL_SetVideoMode
+
+ glClearColor( 0, 0, 0, 0 );
+
+ glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline.
+
+ glViewport( 0, 0, 640, 480 );
+
+ glMatrixMode( GL_PROJECTION );
+ glPushMatrix(); // just for testing
+ glLoadIdentity();
+
+ glOrtho( 0, 640, 480, 0, -1, 1 );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ // Load the OpenGL texture
+
+ GLuint texture; // Texture object handle
+ SDL_Surface *surface; // Gives us the information to make the texture
+
+ if ( (surface = IMG_Load("screenshot.png")) ) {
+
+ // Check that the image's width is a power of 2
+ if ( (surface->w & (surface->w - 1)) != 0 ) {
+ printf("warning: image.bmp's width is not a power of 2\n");
+ }
+
+ // Also check if the height is a power of 2
+ if ( (surface->h & (surface->h - 1)) != 0 ) {
+ printf("warning: image.bmp's height is not a power of 2\n");
+ }
+
+ true_glGenTextures = SDL_GL_GetProcAddress("glGenTextures");
+
+ // Have OpenGL generate a texture object handle for us
+ glGenTextures( 0, &texture );
+
+ // Bind the texture object
+ glBindTexture( GL_TEXTURE_2D, texture );
+
+ // Set the texture's stretching properties
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+
+ //SDL_LockSurface(surface);
+
+ // Add some greyness
+ memset(surface->pixels, 0x66, surface->w*surface->h);
+
+ // Edit the texture object's image data using the information SDL_Surface gives us
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels );
+
+ //SDL_UnlockSurface(surface);
+ }
+ else {
+ printf("SDL could not load image.bmp: %s\n", SDL_GetError());
+ SDL_Quit();
+ return 1;
+ }
+
+ // Free the SDL_Surface only if it was successfully created
+ if ( surface ) {
+ SDL_FreeSurface( surface );
+ }
+
+ // Clear the screen before drawing
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ // Bind the texture to which subsequent calls refer to
+ glBindTexture( GL_TEXTURE_2D, texture );
+
+ glBegin( GL_QUADS );
+ glTexCoord2i( 0, 0 ); glVertex3f( 10, 10, 0 );
+ glTexCoord2i( 1, 0 ); glVertex3f( 300, 10, 0 );
+ glTexCoord2i( 1, 1 ); glVertex3f( 300, 128, 0 );
+ glTexCoord2i( 0, 1 ); glVertex3f( 10, 128, 0 );
+
+ glTexCoord2f( 0, 0.5 ); glVertex3f( 410, 10, 0 );
+ glTexCoord2f( 1, 0.5 ); glVertex3f( 600, 10, 0 );
+ glTexCoord2f( 1, 1 ); glVertex3f( 630, 200, 0 );
+ glTexCoord2f( 0.5, 1 ); glVertex3f( 310, 250, 0 );
+ glEnd();
+
+ glBegin( GL_TRIANGLE_STRIP );
+ glTexCoord2i( 0, 0 ); glVertex3f( 100, 300, 0 );
+ glTexCoord2i( 1, 0 ); glVertex3f( 300, 300, 0 );
+ glTexCoord2i( 1, 1 ); glVertex3f( 300, 400, 0 );
+ glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 0 );
+ glEnd();
+
+ glDisable(GL_TEXTURE_2D);
+
+ glColor3ub(90, 255, 255);
+ glBegin( GL_QUADS );
+ glVertex3f( 10, 410, 0 );
+ glVertex3f( 300, 410, 0 );
+ glVertex3f( 300, 480, 0 );
+ glVertex3f( 10, 470, 0 );
+ glEnd();
+
+ glBegin( GL_QUADS );
+ glColor3f(1.0, 0, 1.0); glVertex3f( 410, 410, 0 );
+ glColor3f(0, 1.0, 0); glVertex3f( 600, 410, 0 );
+ glColor3f(0, 0, 1.0); glVertex3f( 600, 480, 0 );
+ glColor3f(1.0, 1.0, 1.0); glVertex3f( 410, 470, 0 );
+ glEnd();
+
+ SDL_GL_SwapBuffers();
+
+#if !EMSCRIPTEN
+ // Wait for 3 seconds to give us a chance to see the image
+ SDL_Delay(3000);
+#endif
+
+ // Now we can delete the OpenGL texture and close down SDL
+ glDeleteTextures( 1, &texture );
+
+ SDL_Quit();
+
+ return 0;
+}
diff --git a/tests/sockets/test_sockets_echo_server.c b/tests/sockets/test_sockets_echo_server.c
index 8a48b878..38e27cac 100644
--- a/tests/sockets/test_sockets_echo_server.c
+++ b/tests/sockets/test_sockets_echo_server.c
@@ -37,6 +37,11 @@ typedef struct {
server_t server;
client_t client;
+void cleanup() {
+ if (server.fd) close(server.fd);
+ if (client.fd) close(client.fd);
+}
+
void main_loop(void *arg) {
int res;
fd_set fdr;
@@ -105,6 +110,9 @@ int main() {
struct sockaddr_in addr;
int res;
+ atexit(cleanup);
+ signal(SIGTERM, cleanup);
+
memset(&server, 0, sizeof(server_t));
memset(&client, 0, sizeof(client_t));
diff --git a/tests/sockets/test_sockets_partial_server.c b/tests/sockets/test_sockets_partial_server.c
index 57fae84b..dfe0e249 100644
--- a/tests/sockets/test_sockets_partial_server.c
+++ b/tests/sockets/test_sockets_partial_server.c
@@ -14,18 +14,13 @@
#include <emscripten.h>
#endif
-int serverfd = -1;
-int clientfd = -1;
-
-// csock.send("\x09\x01\x02\x03\x04\x05\x06\x07\x08\x09")
-// csock.send("\x08\x01\x02\x03\x04\x05\x06\x07\x08")
-// csock.send("\x07\x01\x02\x03\x04\x05\x06\x07")
-// csock.send("\x06\x01\x02\x03\x04\x05\x06")
-// csock.send("\x05\x01\x02\x03\x04\x05")
-// csock.send("\x04\x01\x02\x03\x04")
-// csock.send("\x03\x01\x02\x03")
-// csock.send("\x02\x01\x02")
-// csock.send("\x01\x01")
+int serverfd = 0;
+int clientfd = 0;
+
+void cleanup() {
+ if (serverfd) close(serverfd);
+ if (clientfd) close(clientfd);
+}
void do_send(int sockfd) {
static char* buffers[] = {
@@ -69,7 +64,7 @@ void iter(void *arg) {
FD_ZERO(&fdr);
FD_ZERO(&fdw);
FD_SET(serverfd, &fdr);
- if (clientfd != -1) FD_SET(clientfd, &fdw);
+ if (clientfd) FD_SET(clientfd, &fdw);
res = select(64, &fdr, &fdw, NULL, NULL);
if (res == -1) {
perror("select failed");
@@ -91,6 +86,9 @@ int main() {
struct sockaddr_in addr;
int res;
+ atexit(cleanup);
+ signal(SIGTERM, cleanup);
+
// create the socket
serverfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (serverfd == -1) {
diff --git a/tests/sockets/webrtc_host.c b/tests/sockets/webrtc_host.c
new file mode 100644
index 00000000..770e59e0
--- /dev/null
+++ b/tests/sockets/webrtc_host.c
@@ -0,0 +1,89 @@
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <assert.h>
+#if EMSCRIPTEN
+#include <emscripten.h>
+#endif
+
+#define EXPECTED_BYTES 5
+#define BUFLEN 16
+
+int result = 0;
+int sock;
+char buf[BUFLEN];
+char expected[] = "emscripten";
+struct sockaddr_in si_host,
+ si_peer;
+struct iovec iov[1];
+struct msghdr hdr;
+int done = 0;
+
+void iter(void* arg) {
+ int n;
+ n = recvmsg(sock, &hdr, 0);
+
+ if(0 < n) {
+ done = 1;
+ fprintf(stderr, "received %d bytes: %s", n, (char*)hdr.msg_iov[0].iov_base);
+
+ shutdown(sock, SHUT_RDWR);
+ close(sock);
+
+#if EMSCRIPTEN
+ int result = 1;
+ REPORT_RESULT();
+ exit(EXIT_SUCCESS);
+ emscripten_cancel_main_loop();
+#endif
+ } else if(EWOULDBLOCK != errno) {
+ perror("recvmsg failed");
+ exit(EXIT_FAILURE);
+ emscripten_cancel_main_loop();
+ }
+}
+
+int main(void)
+{
+ memset(&si_host, 0, sizeof(struct sockaddr_in));
+ memset(&si_peer, 0, sizeof(struct sockaddr_in));
+
+ si_host.sin_family = AF_INET;
+ si_host.sin_port = htons(8991);
+ si_host.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ if(-1 == (sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP))) {
+ perror("cannot create host socket");
+ exit(EXIT_FAILURE);
+ }
+
+ if(-1 == bind(sock, (struct sockaddr*)&si_host, sizeof(struct sockaddr))) {
+ perror("cannot bind host socket");
+ exit(EXIT_FAILURE);
+ }
+
+ iov[0].iov_base = buf;
+ iov[0].iov_len = sizeof(buf);
+
+ memset (&hdr, 0, sizeof (struct msghdr));
+
+ hdr.msg_name = &si_peer;
+ hdr.msg_namelen = sizeof(struct sockaddr_in);
+ hdr.msg_iov = iov;
+ hdr.msg_iovlen = 1;
+
+#if EMSCRIPTEN
+ emscripten_set_main_loop(iter, 0, 0);
+#else
+ while (!done) iter(NULL);
+#endif
+
+ return EXIT_SUCCESS;
+} \ No newline at end of file
diff --git a/tests/sockets/webrtc_peer.c b/tests/sockets/webrtc_peer.c
new file mode 100644
index 00000000..d24979e7
--- /dev/null
+++ b/tests/sockets/webrtc_peer.c
@@ -0,0 +1,81 @@
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <assert.h>
+#if EMSCRIPTEN
+#include <emscripten.h>
+#endif
+
+#define EXPECTED_BYTES 5
+#define BUFLEN 16
+#define HOST_ADDR "10.0.0.1"
+
+int result = 0;
+int sock;
+char buf[16] = "emscripten";
+struct sockaddr_in si_host;
+struct iovec iov[1];
+struct msghdr hdr;
+int done = 0;
+
+void iter(void* arg) {
+ int n;
+ n = sendmsg(sock, &hdr, 0);
+
+ if(0 < n) {
+ done = 1;
+ fprintf(stderr, "sent %d bytes: %s", n, (char*)hdr.msg_iov[0].iov_base);
+
+ shutdown(sock, SHUT_RDWR);
+ close(sock);
+
+ exit(EXIT_SUCCESS);
+ emscripten_cancel_main_loop();
+ } else if(EWOULDBLOCK != errno) {
+ perror("sendmsg failed");
+ exit(EXIT_FAILURE);
+ emscripten_cancel_main_loop();
+ }
+}
+
+int main(void)
+{
+ memset(&si_host, 0, sizeof(struct sockaddr_in));
+
+ si_host.sin_family = AF_INET;
+ si_host.sin_port = htons(8991);
+ if(0 == inet_pton(AF_INET, HOST_ADDR, &si_host.sin_addr)) {
+ perror("inet_aton failed");
+ exit(EXIT_FAILURE);
+ }
+
+ if(-1 == (sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP))) {
+ perror("cannot create socket");
+ exit(EXIT_FAILURE);
+ }
+
+ iov[0].iov_base = buf;
+ iov[0].iov_len = sizeof(buf);
+
+ memset (&hdr, 0, sizeof (struct msghdr));
+
+ hdr.msg_name = &si_host;
+ hdr.msg_namelen = sizeof(struct sockaddr_in);
+ hdr.msg_iov = iov;
+ hdr.msg_iovlen = 1;
+
+#if EMSCRIPTEN
+ emscripten_set_main_loop(iter, 0, 0);
+#else
+ while (!done) iter(NULL);
+#endif
+
+ return EXIT_SUCCESS;
+} \ No newline at end of file
diff --git a/tests/test_browser.py b/tests/test_browser.py
index be2c388b..69fb6f7e 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -620,7 +620,7 @@ Press any key to continue.'''
def test_sdl_canvas(self):
open(os.path.join(self.get_dir(), 'sdl_canvas.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_canvas.c')).read()))
- Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_canvas.c'), '-o', 'page.html']).communicate()
+ Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_canvas.c'), '-o', 'page.html', '-s', 'LEGACY_GL_EMULATION=1']).communicate()
self.run_browser('page.html', '', '/report_result?1')
def test_sdl_key(self):
@@ -843,50 +843,55 @@ Press any key to continue.'''
def test_sdl_ogl(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.btest('sdl_ogl.c', reference='screenshot-gray-purple.png', reference_slack=1,
- args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png'],
+ args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
message='You should see an image with gray at the top.')
def test_sdl_ogl_defaultmatrixmode(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.btest('sdl_ogl_defaultMatrixMode.c', reference='screenshot-gray-purple.png', reference_slack=1,
- args=['--minify', '0', '--preload-file', 'screenshot.png'],
+ args=['--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
message='You should see an image with gray at the top.')
def test_sdl_ogl_p(self):
# Immediate mode with pointers
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.btest('sdl_ogl_p.c', reference='screenshot-gray.png', reference_slack=1,
- args=['--preload-file', 'screenshot.png'],
+ args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
message='You should see an image with gray at the top.')
+ def test_sdl_ogl_proc_alias(self):
+ shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
+ self.btest('sdl_ogl_proc_alias.c', reference='screenshot-gray-purple.png', reference_slack=1,
+ args=['-O2', '-g2', '-s', 'INLINING_LIMIT=1', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '-s', 'VERBOSE=1'])
+
def test_sdl_fog_simple(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.btest('sdl_fog_simple.c', reference='screenshot-fog-simple.png',
- args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png'],
+ args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
message='You should see an image with fog.')
def test_sdl_fog_negative(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.btest('sdl_fog_negative.c', reference='screenshot-fog-negative.png',
- args=['--preload-file', 'screenshot.png'],
+ args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
message='You should see an image with fog.')
def test_sdl_fog_density(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.btest('sdl_fog_density.c', reference='screenshot-fog-density.png',
- args=['--preload-file', 'screenshot.png'],
+ args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
message='You should see an image with fog.')
def test_sdl_fog_exp2(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.btest('sdl_fog_exp2.c', reference='screenshot-fog-exp2.png',
- args=['--preload-file', 'screenshot.png'],
+ args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
message='You should see an image with fog.')
def test_sdl_fog_linear(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.btest('sdl_fog_linear.c', reference='screenshot-fog-linear.png', reference_slack=1,
- args=['--preload-file', 'screenshot.png'],
+ args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
message='You should see an image with fog.')
def test_openal_playback(self):
@@ -903,7 +908,7 @@ Press any key to continue.'''
def test_glfw(self):
open(os.path.join(self.get_dir(), 'glfw.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'glfw.c')).read()))
- Popen([PYTHON, EMCC, '-O2', os.path.join(self.get_dir(), 'glfw.c'), '-o', 'page.html']).communicate()
+ Popen([PYTHON, EMCC, '-O2', os.path.join(self.get_dir(), 'glfw.c'), '-o', 'page.html', '-s', 'LEGACY_GL_EMULATION=1']).communicate()
self.run_browser('page.html', '', '/report_result?1')
def test_egl_width_height(self):
@@ -1063,17 +1068,13 @@ Press any key to continue.'''
def test_glgears_animation(self):
es2_suffix = ['', '_full', '_full_944']
for full_es2 in [0, 1, 2]:
- for emulation in [0, 1]:
- if full_es2 and emulation: continue
- print full_es2, emulation
- Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles%s.c' % es2_suffix[full_es2]), '-o', 'something.html',
- '-DHAVE_BUILTIN_SINCOS', '-s', 'GL_TESTING=1',
- '--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')] +
- (['-s', 'FORCE_GL_EMULATION=1'] if emulation else []) +
- (['-s', 'FULL_ES2=1'] if full_es2 else []),
- ).communicate()
- self.run_browser('something.html', 'You should see animating gears.', '/report_gl_result?true')
- assert ('var GLEmulation' in open(self.in_dir('something.html')).read()) == emulation, "emulation code should be added when asked for"
+ print full_es2
+ Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles%s.c' % es2_suffix[full_es2]), '-o', 'something.html',
+ '-DHAVE_BUILTIN_SINCOS', '-s', 'GL_TESTING=1',
+ '--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')] +
+ (['-s', 'FULL_ES2=1'] if full_es2 else []),
+ ).communicate()
+ self.run_browser('something.html', 'You should see animating gears.', '/report_gl_result?true')
def test_fulles2_sdlproc(self):
self.btest('full_es2_sdlproc.c', '1', args=['-s', 'GL_TESTING=1', '-DHAVE_BUILTIN_SINCOS', '-s', 'FULL_ES2=1'])
@@ -1163,90 +1164,90 @@ Press any key to continue.'''
self.btest('glgetattachedshaders.c', '1')
def test_sdlglshader(self):
- self.btest('sdlglshader.c', reference='sdlglshader.png', args=['-O2', '--closure', '1'])
+ self.btest('sdlglshader.c', reference='sdlglshader.png', args=['-O2', '--closure', '1', '-s', 'LEGACY_GL_EMULATION=1'])
def test_gl_ps(self):
# pointers and a shader
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png'], reference_slack=1)
+ self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'], reference_slack=1)
def test_gl_ps_packed(self):
# packed data that needs to be strided
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('gl_ps_packed.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png'], reference_slack=1)
+ self.btest('gl_ps_packed.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'], reference_slack=1)
def test_gl_ps_strides(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('gl_ps_strides.c', reference='gl_ps_strides.png', args=['--preload-file', 'screenshot.png'])
+ self.btest('gl_ps_strides.c', reference='gl_ps_strides.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'])
def test_gl_renderers(self):
- self.btest('gl_renderers.c', reference='gl_renderers.png', args=['-s', 'GL_UNSAFE_OPTS=0'])
+ self.btest('gl_renderers.c', reference='gl_renderers.png', args=['-s', 'GL_UNSAFE_OPTS=0', '-s', 'LEGACY_GL_EMULATION=1'])
def test_gl_stride(self):
- self.btest('gl_stride.c', reference='gl_stride.png', args=['-s', 'GL_UNSAFE_OPTS=0'])
+ self.btest('gl_stride.c', reference='gl_stride.png', args=['-s', 'GL_UNSAFE_OPTS=0', '-s', 'LEGACY_GL_EMULATION=1'])
def test_matrix_identity(self):
- self.btest('gl_matrix_identity.c', expected=['-1882984448', '460451840'])
+ self.btest('gl_matrix_identity.c', expected=['-1882984448', '460451840'], args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_pre(self):
- self.btest('cubegeom_pre.c', reference='cubegeom_pre.png')
+ self.btest('cubegeom_pre.c', reference='cubegeom_pre.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_pre2(self):
- self.btest('cubegeom_pre2.c', reference='cubegeom_pre2.png', args=['-s', 'GL_DEBUG=1']) # some coverage for GL_DEBUG not breaking the build
+ self.btest('cubegeom_pre2.c', reference='cubegeom_pre2.png', args=['-s', 'GL_DEBUG=1', '-s', 'LEGACY_GL_EMULATION=1']) # some coverage for GL_DEBUG not breaking the build
def test_cubegeom_pre3(self):
- self.btest('cubegeom_pre3.c', reference='cubegeom_pre2.png')
+ self.btest('cubegeom_pre3.c', reference='cubegeom_pre2.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom(self):
- self.btest('cubegeom.c', args=['-O2', '-g'], reference='cubegeom.png')
+ self.btest('cubegeom.c', reference='cubegeom.png', args=['-O2', '-g', '-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_glew(self):
- self.btest('cubegeom_glew.c', args=['-O2', '--closure', '1'], reference='cubegeom.png')
+ self.btest('cubegeom_glew.c', reference='cubegeom.png', args=['-O2', '--closure', '1', '-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_color(self):
- self.btest('cubegeom_color.c', reference='cubegeom_color.png')
+ self.btest('cubegeom_color.c', reference='cubegeom_color.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_normal(self):
- self.btest('cubegeom_normal.c', reference='cubegeom_normal.png')
+ self.btest('cubegeom_normal.c', reference='cubegeom_normal.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_normal_dap(self): # draw is given a direct pointer to clientside memory, no element array buffer
- self.btest('cubegeom_normal_dap.c', reference='cubegeom_normal.png')
+ self.btest('cubegeom_normal_dap.c', reference='cubegeom_normal.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_normal_dap_far(self): # indices do nto start from 0
- self.btest('cubegeom_normal_dap_far.c', reference='cubegeom_normal.png')
+ self.btest('cubegeom_normal_dap_far.c', reference='cubegeom_normal.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_normal_dap_far_range(self): # glDrawRangeElements
- self.btest('cubegeom_normal_dap_far_range.c', reference='cubegeom_normal.png')
+ self.btest('cubegeom_normal_dap_far_range.c', reference='cubegeom_normal.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_normal_dap_far_glda(self): # use glDrawArrays
- self.btest('cubegeom_normal_dap_far_glda.c', reference='cubegeom_normal_dap_far_glda.png')
+ self.btest('cubegeom_normal_dap_far_glda.c', reference='cubegeom_normal_dap_far_glda.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_normal_dap_far_glda_quad(self): # with quad
- self.btest('cubegeom_normal_dap_far_glda_quad.c', reference='cubegeom_normal_dap_far_glda_quad.png')
+ self.btest('cubegeom_normal_dap_far_glda_quad.c', reference='cubegeom_normal_dap_far_glda_quad.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_mt(self):
- self.btest('cubegeom_mt.c', reference='cubegeom_mt.png') # multitexture
+ self.btest('cubegeom_mt.c', reference='cubegeom_mt.png', args=['-s', 'LEGACY_GL_EMULATION=1']) # multitexture
def test_cubegeom_color2(self):
- self.btest('cubegeom_color2.c', reference='cubegeom_color2.png')
+ self.btest('cubegeom_color2.c', reference='cubegeom_color2.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_texturematrix(self):
- self.btest('cubegeom_texturematrix.c', reference='cubegeom_texturematrix.png')
+ self.btest('cubegeom_texturematrix.c', reference='cubegeom_texturematrix.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_fog(self):
- self.btest('cubegeom_fog.c', reference='cubegeom_fog.png')
+ self.btest('cubegeom_fog.c', reference='cubegeom_fog.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_pre_vao(self):
- self.btest('cubegeom_pre_vao.c', reference='cubegeom_pre_vao.png')
+ self.btest('cubegeom_pre_vao.c', reference='cubegeom_pre_vao.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_pre2_vao(self):
- self.btest('cubegeom_pre2_vao.c', reference='cubegeom_pre_vao.png')
+ self.btest('cubegeom_pre2_vao.c', reference='cubegeom_pre_vao.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cubegeom_pre2_vao2(self):
- self.btest('cubegeom_pre2_vao2.c', reference='cubegeom_pre2_vao2.png')
+ self.btest('cubegeom_pre2_vao2.c', reference='cubegeom_pre2_vao2.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_cube_explosion(self):
- self.btest('cube_explosion.c', reference='cube_explosion.png')
+ self.btest('cube_explosion.c', reference='cube_explosion.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_sdl_canvas_blank(self):
self.btest('sdl_canvas_blank.c', reference='sdl_canvas_blank.png')
@@ -1298,11 +1299,11 @@ Press any key to continue.'''
def test_glbegin_points(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('glbegin_points.c', reference='glbegin_points.png', args=['--preload-file', 'screenshot.png'])
+ self.btest('glbegin_points.c', reference='glbegin_points.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'])
def test_s3tc(self):
shutil.copyfile(path_from_root('tests', 'screenshot.dds'), os.path.join(self.get_dir(), 'screenshot.dds'))
- self.btest('s3tc.c', reference='s3tc.png', args=['--preload-file', 'screenshot.dds'])
+ self.btest('s3tc.c', reference='s3tc.png', args=['--preload-file', 'screenshot.dds', '-s', 'LEGACY_GL_EMULATION=1'])
def test_s3tc_crunch(self):
shutil.copyfile(path_from_root('tests', 'ship.dds'), 'ship.dds')
@@ -1313,7 +1314,7 @@ Press any key to continue.'''
shutil.move('ship.dds', 'ship.donotfindme.dds') # make sure we load from the compressed
shutil.move('bloom.dds', 'bloom.donotfindme.dds') # make sure we load from the compressed
shutil.move('water.dds', 'water.donotfindme.dds') # make sure we load from the compressed
- self.btest('s3tc_crunch.c', reference='s3tc_crunch.png', reference_slack=11, args=['--pre-js', 'pre.js'])
+ self.btest('s3tc_crunch.c', reference='s3tc_crunch.png', reference_slack=11, args=['--pre-js', 'pre.js', '-s', 'LEGACY_GL_EMULATION=1'])
def test_s3tc_crunch_split(self): # load several datafiles/outputs of file packager
shutil.copyfile(path_from_root('tests', 'ship.dds'), 'ship.dds')
@@ -1324,14 +1325,20 @@ Press any key to continue.'''
shutil.move('ship.dds', 'ship.donotfindme.dds') # make sure we load from the compressed
shutil.move('bloom.dds', 'bloom.donotfindme.dds') # make sure we load from the compressed
shutil.move('water.dds', 'water.donotfindme.dds') # make sure we load from the compressed
- self.btest('s3tc_crunch.c', reference='s3tc_crunch.png', reference_slack=11, args=['--pre-js', 'asset_a.js', '--pre-js', 'asset_b.js'])
+ self.btest('s3tc_crunch.c', reference='s3tc_crunch.png', reference_slack=11, args=['--pre-js', 'asset_a.js', '--pre-js', 'asset_b.js', '-s', 'LEGACY_GL_EMULATION=1'])
def test_aniso(self):
+ if SPIDERMONKEY_ENGINE in JS_ENGINES:
+ # asm.js-ification check
+ Popen([PYTHON, EMCC, path_from_root('tests', 'aniso.c'), '-O2', '-g2', '-s', 'LEGACY_GL_EMULATION=1']).communicate()
+ Settings.ASM_JS = 1
+ self.run_generated_code(SPIDERMONKEY_ENGINE, 'a.out.js')
+
shutil.copyfile(path_from_root('tests', 'water.dds'), 'water.dds')
- self.btest('aniso.c', reference='aniso.png', reference_slack=2, args=['--preload-file', 'water.dds'])
+ self.btest('aniso.c', reference='aniso.png', reference_slack=2, args=['--preload-file', 'water.dds', '-s', 'LEGACY_GL_EMULATION=1'])
def test_tex_nonbyte(self):
- self.btest('tex_nonbyte.c', reference='tex_nonbyte.png')
+ self.btest('tex_nonbyte.c', reference='tex_nonbyte.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_float_tex(self):
self.btest('float_tex.cpp', reference='float_tex.png')
@@ -1340,7 +1347,7 @@ Press any key to continue.'''
self.btest('gl_subdata.cpp', reference='float_tex.png')
def test_perspective(self):
- self.btest('perspective.c', reference='perspective.png')
+ self.btest('perspective.c', reference='perspective.png', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_runtimelink(self):
return self.skip('shared libs are deprecated')
diff --git a/tests/test_core.py b/tests/test_core.py
index 31db6ca5..88f6674a 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -9582,15 +9582,15 @@ def process(filename):
self.assertIdentical(clean(no_maps_file), clean(out_file))
map_filename = out_filename + '.map'
data = json.load(open(map_filename, 'r'))
- self.assertIdentical(out_filename, data['file'])
- self.assertIdentical(src_filename, data['sources'][0])
- self.assertIdentical(src, data['sourcesContent'][0])
+ self.assertPathsIdentical(out_filename, data['file'])
+ self.assertPathsIdentical(src_filename, data['sources'][0])
+ self.assertTextDataIdentical(src, data['sourcesContent'][0])
mappings = json.loads(jsrun.run_js(
path_from_root('tools', 'source-maps', 'sourcemap2json.js'),
tools.shared.NODE_JS, [map_filename]))
seen_lines = set()
for m in mappings:
- self.assertIdentical(src_filename, m['source'])
+ self.assertPathsIdentical(src_filename, m['source'])
seen_lines.add(m['originalLine'])
# ensure that all the 'meaningful' lines in the original code get mapped
assert seen_lines.issuperset([6, 7, 11, 12])
diff --git a/tests/test_sockets.py b/tests/test_sockets.py
index 03593674..4f6ee2a9 100644
--- a/tests/test_sockets.py
+++ b/tests/test_sockets.py
@@ -198,3 +198,71 @@ class sockets(BrowserCore):
# ]:
# with harness:
# self.btest(os.path.join('sockets', 'test_enet_client.c'), expected='0', args=['-DSOCKK=9011'] + enet)
+
+ def test_webrtc(self):
+ host_src = 'webrtc_host.c'
+ peer_src = 'webrtc_peer.c'
+
+ host_outfile = 'host.html'
+ peer_outfile = 'peer.html'
+
+ host_filepath = path_from_root('tests', 'sockets', host_src)
+ temp_host_filepath = os.path.join(self.get_dir(), os.path.basename(host_src))
+ with open(host_filepath) as f: host_src = f.read()
+ with open(temp_host_filepath, 'w') as f: f.write(self.with_report_result(host_src))
+
+ peer_filepath = path_from_root('tests', 'sockets', peer_src)
+ temp_peer_filepath = os.path.join(self.get_dir(), os.path.basename(peer_src))
+ with open(peer_filepath) as f: peer_src = f.read()
+ with open(temp_peer_filepath, 'w') as f: f.write(self.with_report_result(peer_src))