aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/aniso.c1
-rw-r--r--tests/cubegeom_color.c1
-rw-r--r--tests/cubegeom_pre.c1
-rw-r--r--tests/cubegeom_pre2.c1
-rw-r--r--tests/cubegeom_pre2_vao.c1
-rw-r--r--tests/cubegeom_pre2_vao2.c1
-rw-r--r--tests/cubegeom_pre3.c1
-rw-r--r--tests/cubegeom_pre_vao.c1
-rw-r--r--tests/cubegeom_texturematrix.c1
-rw-r--r--tests/float_tex.cpp2
-rw-r--r--tests/gl_matrix_identity.c1
-rw-r--r--tests/glshaderinfo.cpp2
-rw-r--r--tests/http.h1
-rw-r--r--tests/s3tc.c1
-rw-r--r--tests/s3tc_crunch.c1
-rw-r--r--tests/sdl_canvas.c11
-rw-r--r--tests/sdl_image_prepare_data.c2
-rw-r--r--tests/sockets/test_enet_client.c2
-rw-r--r--tests/sockets/test_sockets_partial_server.c3
-rw-r--r--tests/sockets/test_sockets_select_server_down_client.c (renamed from tests/sockets/test_sockets_select_server_no_accept_client.c)0
-rw-r--r--tests/sockets/test_sockets_select_server_down_server.c (renamed from tests/sockets/test_sockets_select_server_no_accept_server.c)41
-rw-r--r--tests/test_browser.py16
-rw-r--r--tests/test_core.py46
-rw-r--r--tests/test_sockets.py9
-rw-r--r--tests/tex_nonbyte.c1
-rw-r--r--tests/unistd/misc.out7
26 files changed, 95 insertions, 60 deletions
diff --git a/tests/aniso.c b/tests/aniso.c
index f210e5a5..e8d7bd3f 100644
--- a/tests/aniso.c
+++ b/tests/aniso.c
@@ -27,6 +27,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include "SDL/SDL_opengl.h"
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/cubegeom_color.c b/tests/cubegeom_color.c
index 7d384324..ff30e1a9 100644
--- a/tests/cubegeom_color.c
+++ b/tests/cubegeom_color.c
@@ -26,6 +26,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/cubegeom_pre.c b/tests/cubegeom_pre.c
index fb1a5e02..40b03cf7 100644
--- a/tests/cubegeom_pre.c
+++ b/tests/cubegeom_pre.c
@@ -26,6 +26,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/cubegeom_pre2.c b/tests/cubegeom_pre2.c
index 51961bf7..df04ae31 100644
--- a/tests/cubegeom_pre2.c
+++ b/tests/cubegeom_pre2.c
@@ -26,6 +26,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/cubegeom_pre2_vao.c b/tests/cubegeom_pre2_vao.c
index cba262ff..733c8fc6 100644
--- a/tests/cubegeom_pre2_vao.c
+++ b/tests/cubegeom_pre2_vao.c
@@ -26,6 +26,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/cubegeom_pre2_vao2.c b/tests/cubegeom_pre2_vao2.c
index 3784006c..69096833 100644
--- a/tests/cubegeom_pre2_vao2.c
+++ b/tests/cubegeom_pre2_vao2.c
@@ -26,6 +26,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/cubegeom_pre3.c b/tests/cubegeom_pre3.c
index 4ba2a779..ceaa757e 100644
--- a/tests/cubegeom_pre3.c
+++ b/tests/cubegeom_pre3.c
@@ -26,6 +26,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/cubegeom_pre_vao.c b/tests/cubegeom_pre_vao.c
index cae68cfc..8c598143 100644
--- a/tests/cubegeom_pre_vao.c
+++ b/tests/cubegeom_pre_vao.c
@@ -26,6 +26,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/cubegeom_texturematrix.c b/tests/cubegeom_texturematrix.c
index 99a4469e..abb667eb 100644
--- a/tests/cubegeom_texturematrix.c
+++ b/tests/cubegeom_texturematrix.c
@@ -26,6 +26,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/float_tex.cpp b/tests/float_tex.cpp
index 61531124..c40ff786 100644
--- a/tests/float_tex.cpp
+++ b/tests/float_tex.cpp
@@ -113,7 +113,7 @@ static void gl_init(void) {
/* Store the vertices in a vertex buffer object (VBO) */
glGenBuffers(1, &indicesVBO);
glBindBuffer(GL_ARRAY_BUFFER, indicesVBO);
- glBufferData(GL_ARRAY_BUFFER, elements.size() * sizeof(uint), &elements[0], GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, elements.size() * sizeof(float), &elements[0], GL_STATIC_DRAW);
/* Get the locations of the uniforms so we can access them */
nodeSamplerLocation = glGetUniformLocation(program, "nodeInfo");
glBindAttribLocation(program, 0, "indices");
diff --git a/tests/gl_matrix_identity.c b/tests/gl_matrix_identity.c
index 98b1c21f..9f990a77 100644
--- a/tests/gl_matrix_identity.c
+++ b/tests/gl_matrix_identity.c
@@ -26,6 +26,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/glshaderinfo.cpp b/tests/glshaderinfo.cpp
index 8ec393a8..56da2414 100644
--- a/tests/glshaderinfo.cpp
+++ b/tests/glshaderinfo.cpp
@@ -1,8 +1,6 @@
#define GL_GLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES
-#define _GNU_SOURCE
-
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/tests/http.h b/tests/http.h
index 7eff7013..d20f012b 100644
--- a/tests/http.h
+++ b/tests/http.h
@@ -8,6 +8,7 @@
#ifndef __HTTP_H__
#define __HTTP_H__
+#include <stdarg.h>
#include <string>
diff --git a/tests/s3tc.c b/tests/s3tc.c
index 16ee783f..5f7bee83 100644
--- a/tests/s3tc.c
+++ b/tests/s3tc.c
@@ -27,6 +27,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include "SDL/SDL_opengl.h"
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/s3tc_crunch.c b/tests/s3tc_crunch.c
index 90ed02d9..c2606c8f 100644
--- a/tests/s3tc_crunch.c
+++ b/tests/s3tc_crunch.c
@@ -27,6 +27,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include "SDL/SDL_opengl.h"
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/sdl_canvas.c b/tests/sdl_canvas.c
index 10044ff4..6bd659b8 100644
--- a/tests/sdl_canvas.c
+++ b/tests/sdl_canvas.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <emscripten.h>
@@ -43,6 +44,16 @@ int main(int argc, char **argv) {
SDL_Flip(screen);
SDL_LockSurface(screen);
+
+ int width, height, isFullscreen;
+ emscripten_get_canvas_size(&width, &height, &isFullscreen);
+
+ if (width != 600 && height != 450)
+ {
+ printf("error: wrong width/height\n");
+ abort();
+ }
+
int sum = 0;
for (int i = 0; i < screen->h; i++) {
sum += *((char*)screen->pixels + i*screen->w*4 + i*4 + 0);
diff --git a/tests/sdl_image_prepare_data.c b/tests/sdl_image_prepare_data.c
index d45a2e60..043ace47 100644
--- a/tests/sdl_image_prepare_data.c
+++ b/tests/sdl_image_prepare_data.c
@@ -58,7 +58,7 @@ int main() {
printf("prepare..\n");
#define SIZE 203164
- FILE *f = open("screenshot.not", "rb");
+ FILE *f = fopen("screenshot.not", "rb");
char *buffer = malloc(SIZE);
fread(buffer, SIZE, 1, f);
fclose(f);
diff --git a/tests/sockets/test_enet_client.c b/tests/sockets/test_enet_client.c
index bf14375c..afcdcae8 100644
--- a/tests/sockets/test_enet_client.c
+++ b/tests/sockets/test_enet_client.c
@@ -93,6 +93,7 @@ int main (int argc, char ** argv)
}
#if EMSCRIPTEN
+#if USE_IFRAME
emscripten_run_script("console.log('adding iframe');"
"var iframe = document.createElement('iframe');"
"iframe.src = 'server.html';"
@@ -101,6 +102,7 @@ int main (int argc, char ** argv)
"document.body.appendChild(iframe);"
"console.log('added.');");
#endif
+#endif
#if EMSCRIPTEN
emscripten_set_main_loop(main_loop, 3, 1);
diff --git a/tests/sockets/test_sockets_partial_server.c b/tests/sockets/test_sockets_partial_server.c
index 21096552..44ad40a3 100644
--- a/tests/sockets/test_sockets_partial_server.c
+++ b/tests/sockets/test_sockets_partial_server.c
@@ -38,13 +38,12 @@ void do_send(int sockfd) {
int i;
int res;
char *buffer;
- struct sockaddr_in addr;
socklen_t addrlen;
for (i = 0; i < sizeof(buffers) / sizeof(char*); i++) {
buffer = buffers[i];
- res = sendto(sockfd, buffer, strlen(buffer), 0, (struct sockaddr *)&addr, sizeof(addr));
+ res = send(sockfd, buffer, strlen(buffer), 0);
if (res == -1) {
perror("send failed");
exit(EXIT_FAILURE);
diff --git a/tests/sockets/test_sockets_select_server_no_accept_client.c b/tests/sockets/test_sockets_select_server_down_client.c
index e05bd4c8..e05bd4c8 100644
--- a/tests/sockets/test_sockets_select_server_no_accept_client.c
+++ b/tests/sockets/test_sockets_select_server_down_client.c
diff --git a/tests/sockets/test_sockets_select_server_no_accept_server.c b/tests/sockets/test_sockets_select_server_down_server.c
index 4a399ed1..c2e70f33 100644
--- a/tests/sockets/test_sockets_select_server_no_accept_server.c
+++ b/tests/sockets/test_sockets_select_server_down_server.c
@@ -14,38 +14,13 @@
#include <emscripten.h>
#endif
-int serverfd = -1;
-
-void iter(void *arg) {
- int res;
- fd_set fdr;
- fd_set fdw;
-
- // see if there are any connections to accept / write to
- FD_ZERO(&fdr);
- FD_ZERO(&fdw);
- FD_SET(serverfd, &fdr);
- if (clientfd != -1) FD_SET(clientfd, &fdw);
- res = select(64, &fdr, &fdw, NULL, NULL);
- if (res == -1) {
- perror("select failed");
- exit(EXIT_SUCCESS);
- }
-
- if (FD_ISSET(serverfd, &fdr)) {
- printf("accepted someone\n");
- clientfd = accept(serverfd, NULL, NULL);
- assert(clientfd != -1);
- }
-
- if (FD_ISSET(clientfd, &fdw)) {
- do_send(clientfd);
- }
+void main_loop(void *arg) {
}
int main() {
struct sockaddr_in addr;
int res;
+ int serverfd;
// create the socket
serverfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
@@ -55,7 +30,7 @@ int main() {
}
fcntl(serverfd, F_SETFL, O_NONBLOCK);
- // bind and listen to the supplied port
+ // bind to the supplied port
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(SOCKK);
@@ -70,16 +45,12 @@ int main() {
exit(EXIT_FAILURE);
}
- res = listen(serverfd, 50);
- if (res == -1) {
- perror("listen failed");
- exit(EXIT_FAILURE);
- }
+ close(serverfd);
#if EMSCRIPTEN
- emscripten_set_main_loop(iter, 60, 0);
+ emscripten_set_main_loop(main_loop, 60, 0);
#else
- while (1) iter(NULL);
+ while (1) main_loop(NULL); sleep(1);
#endif
return EXIT_SUCCESS;
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 7c387071..4b42eedd 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -38,8 +38,6 @@ class browser(BrowserCore):
message='You should see "hello, world!" and a colored cube.')
def test_html_source_map(self):
- if 'test_html_source_map' not in str(sys.argv): return self.skip('''This test
-requires manual intervention; will not be run unless explicitly requested''')
cpp_file = os.path.join(self.get_dir(), 'src.cpp')
html_file = os.path.join(self.get_dir(), 'src.html')
# browsers will try to 'guess' the corresponding original line if a
@@ -64,14 +62,20 @@ requires manual intervention; will not be run unless explicitly requested''')
''')
# use relative paths when calling emcc, because file:// URIs can only load
# sourceContent when the maps are relative paths
+ try_delete(html_file)
+ try_delete(html_file + '.map')
Popen([PYTHON, EMCC, 'src.cpp', '-o', 'src.html', '-g4'],
cwd=self.get_dir()).communicate()
+ assert os.path.exists(html_file)
+ assert os.path.exists(html_file + '.map')
+ import webbrowser, time
webbrowser.open_new('file://' + html_file)
+ time.sleep(1)
print '''
-Set the debugger to pause on exceptions
-You should see an exception thrown at src.cpp:7.
-Press any key to continue.'''
- raw_input()
+If manually bisecting:
+ Check that you see src.cpp among the page sources.
+ Even better, add a breakpoint, e.g. on the printf, then reload, then step through and see the print (best to run with EM_SAVE_DIR=1 for the reload).
+'''
def build_native_lzma(self):
lzma_native = path_from_root('third_party', 'lzma.js', 'lzma-native')
diff --git a/tests/test_core.py b/tests/test_core.py
index a477c05e..7eff0d2f 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -3752,7 +3752,7 @@ def process(filename):
}
'''
- self.do_run(src, 'Inline JS is very cool\n3.64')
+ self.do_run(src, 'Inline JS is very cool\n3.64\n')
def test_inlinejs2(self):
if Settings.ASM_JS: return self.skip('asm does not support random code, TODO: something that works in asm')
@@ -3779,6 +3779,27 @@ def process(filename):
self.do_run(src, '4\n200\n')
+ def test_inlinejs3(self):
+ if Settings.ASM_JS: return self.skip('asm does not support random code, TODO: something that works in asm')
+ src = r'''
+ #include <stdio.h>
+ #include <emscripten.h>
+
+ int main() {
+ EM_ASM(Module.print('hello dere1'));
+ EM_ASM(
+ Module.print('hello dere2');
+ );
+ EM_ASM(
+ Module.print('hello dere3');
+ Module.print('hello dere' + 4);
+ );
+ return 0;
+ }
+ '''
+
+ self.do_run(src, 'hello dere1\nhello dere2\nhello dere3\nhello dere4\n')
+
def test_memorygrowth(self):
if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays')
if Settings.ASM_JS: return self.skip('asm does not support memory growth yet')
@@ -5546,7 +5567,6 @@ The current type of b is: 9
if Settings.ASM_JS: return self.skip('TODO: dlopen in asm')
Settings.NAMED_GLOBALS = 1
- Settings.LINKABLE = 1
lib_src = '''
#include <cstdio>
@@ -6741,6 +6761,7 @@ date: 18.07.2013w; day 18, month 7, year 2013, extra: 201, 3
def test_files(self):
if self.emcc_args is not None and '-O2' in self.emcc_args:
self.emcc_args += ['--closure', '1'] # Use closure here, to test we don't break FS stuff
+ self.emcc_args = filter(lambda x: x != '-g', self.emcc_args) # ensure we test --closure 1 --memory-init-file 1 (-g would disable closure)
Settings.CORRECT_SIGNS = 1 # Just so our output is what we expect. Can flip them both.
post = '''
@@ -6767,8 +6788,13 @@ def process(filename):
other.close()
src = open(path_from_root('tests', 'files.cpp'), 'r').read()
+
+ mem_file = 'src.cpp.o.js.mem'
+ try_delete(mem_file)
self.do_run(src, ('size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\nok.\ntexte\n', 'size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\ntexte\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\nok.\n'),
post_build=post, extra_emscripten_args=['-H', 'libc/fcntl.h'])
+ if self.emcc_args and '--memory-init-file' in self.emcc_args:
+ assert os.path.exists(mem_file)
def test_files_m(self):
# Test for Module.stdin etc.
@@ -8301,13 +8327,15 @@ def process(filename):
shutil.copyfile(path_from_root('tests', 'freetype', 'LiberationSansBold.ttf'), os.path.join(self.get_dir(), 'font.ttf'))
# Main
- self.do_run(open(path_from_root('tests', 'freetype', 'main.c'), 'r').read(),
- open(path_from_root('tests', 'freetype', 'ref.txt'), 'r').read(),
- ['font.ttf', 'test!', '150', '120', '25'],
- libraries=self.get_freetype(),
- includes=[path_from_root('tests', 'freetype', 'include')],
- post_build=post)
- #build_ll_hook=self.do_autodebug)
+ for outlining in [0, 5000]:
+ Settings.OUTLINING_LIMIT = outlining
+ print >> sys.stderr, 'outlining:', outlining
+ self.do_run(open(path_from_root('tests', 'freetype', 'main.c'), 'r').read(),
+ open(path_from_root('tests', 'freetype', 'ref.txt'), 'r').read(),
+ ['font.ttf', 'test!', '150', '120', '25'],
+ libraries=self.get_freetype(),
+ includes=[path_from_root('tests', 'freetype', 'include')],
+ post_build=post)
# github issue 324
print '[issue 324]'
diff --git a/tests/test_sockets.py b/tests/test_sockets.py
index 4f6ee2a9..82ddc6fe 100644
--- a/tests/test_sockets.py
+++ b/tests/test_sockets.py
@@ -142,11 +142,12 @@ class sockets(BrowserCore):
# def test_sockets_gethostbyname(self):
# self.btest(os.path.join('sockets', 'test_sockets_gethostbyname.c'), expected='0', args=['-O2', '-DSOCKK=8997'])
- def test_sockets_select_server_no_accept(self):
+ def test_sockets_select_server_down(self):
for harness in [
- WebsockifyServerHarness(os.path.join('sockets', 'test_sockets_select_server_no_accept_server.c'), ['-DSOCKK=8995'], 8996, 8995)
+ WebsockifyServerHarness(os.path.join('sockets', 'test_sockets_select_server_down_server.c'), ['-DSOCKK=9002'], 9003, 9002)
]:
- self.btest(os.path.join('sockets', 'test_sockets_select_server_no_accept_client.c'), expected='266', args=['-DSOCKK=8996'])
+ with harness:
+ self.btest(os.path.join('sockets', 'test_sockets_select_server_down_client.c'), expected='266', args=['-DSOCKK=9003'])
def test_sockets_select_server_closes_connection_rw(self):
sockets_include = '-I'+path_from_root('tests', 'sockets')
@@ -178,7 +179,7 @@ class sockets(BrowserCore):
try:
proc = make_relay_server(2234, 2236)
pids.append(proc.pid)
- self.btest(os.path.join('sockets', 'test_enet_client.c'), expected='0', args=['-DSOCKK=2237'] + enet)
+ self.btest(os.path.join('sockets', 'test_enet_client.c'), expected='0', args=['-DSOCKK=2237', '-DUSE_IFRAME'] + enet)
finally:
clean_pids(pids);
diff --git a/tests/tex_nonbyte.c b/tests/tex_nonbyte.c
index 8f2ec162..960d0efb 100644
--- a/tests/tex_nonbyte.c
+++ b/tests/tex_nonbyte.c
@@ -37,6 +37,7 @@ REDISTRIBUTION OF THIS SOFTWARE.
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/tests/unistd/misc.out b/tests/unistd/misc.out
index 43971955..8f03f688 100644
--- a/tests/unistd/misc.out
+++ b/tests/unistd/misc.out
@@ -44,3 +44,10 @@ setgid: -1, errno: 1
setegid: -1, errno: 1
setuid: -1, errno: 1
seteuid: -1, errno: 1
+setpgrp: -1, errno: 1
+setsid: -1, errno: 1
+setpgid: -1, errno: 1
+setregid: -1, errno: 1
+setreuid: -1, errno: 1
+getgroups: 1, result: 0, errno: 0
+setgroups: -1, errno: 1