aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/aniso.c1
-rw-r--r--tests/cases/callwithstructural64_ta2.ll29
-rw-r--r--tests/cases/callwithstructural64_ta2.txt1
-rw-r--r--tests/cases/callwithstructural_ta2.ll29
-rw-r--r--tests/cases/callwithstructural_ta2.txt1
-rw-r--r--tests/cases/structinparam.ll36
-rw-r--r--tests/cases/structinparam.txt2
-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/file_db.cpp47
-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/pthread/specific.c60
-rw-r--r--tests/pthread/specific.c.txt8
-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_headless.c65
-rw-r--r--tests/sdl_image_prepare_data.c2
-rw-r--r--tests/sdl_pumpevents.c16
-rw-r--r--tests/test_browser.py29
-rw-r--r--tests/test_core.py13
-rw-r--r--tests/test_other.py23
-rw-r--r--tests/test_sanity.py27
-rw-r--r--tests/tex_nonbyte.c1
33 files changed, 382 insertions, 35 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/cases/callwithstructural64_ta2.ll b/tests/cases/callwithstructural64_ta2.ll
new file mode 100644
index 00000000..d16b0e87
--- /dev/null
+++ b/tests/cases/callwithstructural64_ta2.ll
@@ -0,0 +1,29 @@
+; ModuleID = 'foo.bc'
+target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
+target triple = "le32-unknown-nacl"
+
+%ac = type { i8*, i64 }
+
+@0 = constant [9 x i8] c"func %s\0A\00"
+@1 = constant [4 x i8] c"foo\00"
+
+declare void @llvm.trap() noreturn nounwind
+
+define void @direct(%ac) {
+entry:
+ %str = alloca %ac
+ store %ac %0, %ac* %str
+ %1 = getelementptr inbounds %ac* %str, i32 0, i32 0
+ %2 = load i8** %1
+ call void (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @0, i32 0, i32 0), i8* %2)
+ ret void
+}
+
+declare void @printf(i8*, ...)
+
+define i32 @main() {
+entry:
+ call void @direct(%ac { i8* getelementptr inbounds ([4 x i8]* @1, i32 0, i32 0), i64 3 })
+ ret i32 0
+}
+
diff --git a/tests/cases/callwithstructural64_ta2.txt b/tests/cases/callwithstructural64_ta2.txt
new file mode 100644
index 00000000..51a6ac7c
--- /dev/null
+++ b/tests/cases/callwithstructural64_ta2.txt
@@ -0,0 +1 @@
+func foo
diff --git a/tests/cases/callwithstructural_ta2.ll b/tests/cases/callwithstructural_ta2.ll
new file mode 100644
index 00000000..bc6f852a
--- /dev/null
+++ b/tests/cases/callwithstructural_ta2.ll
@@ -0,0 +1,29 @@
+; ModuleID = 'foo.bc'
+target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
+target triple = "le32-unknown-nacl"
+
+%ac = type { i8*, i32 }
+
+@0 = constant [9 x i8] c"func %s\0A\00"
+@1 = constant [4 x i8] c"foo\00"
+
+declare void @llvm.trap() noreturn nounwind
+
+define void @direct(%ac) {
+entry:
+ %str = alloca %ac
+ store %ac %0, %ac* %str
+ %1 = getelementptr inbounds %ac* %str, i32 0, i32 0
+ %2 = load i8** %1
+ call void (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @0, i32 0, i32 0), i8* %2)
+ ret void
+}
+
+declare void @printf(i8*, ...)
+
+define i32 @main() {
+entry:
+ call void @direct(%ac { i8* getelementptr inbounds ([4 x i8]* @1, i32 0, i32 0), i32 3 })
+ ret i32 0
+}
+
diff --git a/tests/cases/callwithstructural_ta2.txt b/tests/cases/callwithstructural_ta2.txt
new file mode 100644
index 00000000..51a6ac7c
--- /dev/null
+++ b/tests/cases/callwithstructural_ta2.txt
@@ -0,0 +1 @@
+func foo
diff --git a/tests/cases/structinparam.ll b/tests/cases/structinparam.ll
new file mode 100644
index 00000000..d81f5e67
--- /dev/null
+++ b/tests/cases/structinparam.ll
@@ -0,0 +1,36 @@
+; ModuleID = 'min.bc'
+target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
+target triple = "le32-unknown-nacl"
+
+%ac = type { i8*, i32 }
+
+@0 = constant [9 x i8] c"func %s\0A\00"
+@1 = constant [4 x i8] c"foo\00"
+@2 = constant [9 x i8] c"main %s\0A\00"
+
+declare void @llvm.trap() noreturn nounwind
+
+define void @direct(%ac) {
+entry:
+ %str = alloca %ac
+ store %ac %0, %ac* %str
+ %1 = getelementptr inbounds %ac* %str, i32 0, i32 0
+ %2 = load i8** %1
+ call void (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @0, i32 0, i32 0), i8* %2)
+ ret void
+}
+
+declare void @printf(i8*, ...)
+
+define i32 @main() {
+entry:
+ %str = alloca %ac
+ store %ac { i8* getelementptr inbounds ([4 x i8]* @1, i32 0, i32 0), i32 3 }, %ac* %str
+ %0 = getelementptr inbounds %ac* %str, i32 0, i32 0
+ %1 = load i8** %0
+ call void (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @2, i32 0, i32 0), i8* %1)
+ %2 = load %ac* %str
+ call void @direct(%ac %2)
+ ret i32 0
+}
+
diff --git a/tests/cases/structinparam.txt b/tests/cases/structinparam.txt
new file mode 100644
index 00000000..785191e7
--- /dev/null
+++ b/tests/cases/structinparam.txt
@@ -0,0 +1,2 @@
+main foo
+func foo
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/file_db.cpp b/tests/file_db.cpp
new file mode 100644
index 00000000..ebb3bb30
--- /dev/null
+++ b/tests/file_db.cpp
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <emscripten.h>
+
+void later(void *) {}
+
+int main() {
+#if FIRST
+ FILE *f = fopen("waka.txt", "w");
+ fputc('a', f);
+ fputc('z', f);
+ fclose(f);
+
+ EM_ASM(
+ FS.saveFilesToDB(['waka.txt', 'moar.txt'], function() {
+ Module.print('save ok');
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', 'http://localhost:8888/report_result?1');
+ xhr.send();
+ setTimeout(function() { window.close() }, 1000);
+ }, function(e) {
+ abort('saving should succeed ' + e);
+ });
+ );
+#else
+ EM_ASM(
+ FS.loadFilesFromDB(['waka.txt', 'moar.txt'], function() {
+ function stringy(arr) {
+ return Array.prototype.map.call(arr, function(x) { return String.fromCharCode(x) }).join('');
+ }
+ assert(stringy(FS.analyzePath('waka.txt').object.contents) == 'az');
+ var secret = stringy(FS.analyzePath('moar.txt').object.contents);
+ Module.print('load: ' + secret);
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', 'http://localhost:8888/report_result?' + secret);
+ xhr.send();
+ setTimeout(function() { window.close() }, 1000);
+ }, function() {
+ abort('loading should succeed');
+ });
+ );
+#endif
+
+ emscripten_async_call(later, NULL, 100); // keep runtime alive
+
+ return 0;
+}
+
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/pthread/specific.c b/tests/pthread/specific.c
new file mode 100644
index 00000000..914884e7
--- /dev/null
+++ b/tests/pthread/specific.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+
+static void destr_function(void *arg)
+{
+ // Not implemented yet in Emscripten
+}
+
+int main(void)
+{
+ pthread_key_t key = 0;
+ int rv;
+ int data = 123;
+ int *data2;
+
+ assert(pthread_key_delete(key) != 0);
+ assert(pthread_getspecific(key) == NULL);
+
+ rv = pthread_key_create(&key, &destr_function);
+ printf("pthread_key_create = %d\n", rv);
+ assert(rv == 0);
+
+ assert(pthread_getspecific(key) == NULL);
+
+ rv = pthread_setspecific(key, (void*) &data);
+ printf("pthread_setspecific = %d\n", rv);
+ assert(rv == 0);
+
+ data2 = pthread_getspecific(key);
+ assert(data2 != NULL);
+ printf("pthread_getspecific = %d\n", *data2);
+ assert(*data2 == 123);
+
+ rv = pthread_key_create(&key, &destr_function);
+ data2 = pthread_getspecific(key);
+ printf("pthread_getspecific after key recreate = %p\n", data2);
+ assert(data2 == NULL);
+
+ rv = pthread_key_delete(key);
+ printf("pthread_key_delete = %d\n", rv);
+ assert(rv == 0);
+
+ rv = pthread_key_delete(key);
+ printf("pthread_key_delete repeated = %d\n", rv);
+ assert(rv == EINVAL);
+
+ rv = pthread_setspecific(key, NULL);
+ printf("pthread_setspecific for value NULL = %d\n", rv);
+ assert(rv == EINVAL);
+
+ rv = pthread_key_create(&key, &destr_function);
+ assert(rv == 0);
+ rv = pthread_key_delete(key);
+ printf("pthread_key_delete just after created = %d\n", rv);
+ assert(rv == 0);
+
+ return 0;
+}
diff --git a/tests/pthread/specific.c.txt b/tests/pthread/specific.c.txt
new file mode 100644
index 00000000..ad122b3d
--- /dev/null
+++ b/tests/pthread/specific.c.txt
@@ -0,0 +1,8 @@
+pthread_key_create = 0
+pthread_setspecific = 0
+pthread_getspecific = 123
+pthread_getspecific after key recreate = (nil)
+pthread_key_delete = 0
+pthread_key_delete repeated = 22
+pthread_setspecific for value NULL = 22
+pthread_key_delete just after created = 0
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_headless.c b/tests/sdl_headless.c
new file mode 100644
index 00000000..349c5e26
--- /dev/null
+++ b/tests/sdl_headless.c
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <SDL/SDL.h>
+#include <SDL/SDL_ttf.h>
+#include <emscripten.h>
+
+
+int main(int argc, char **argv) {
+#if EMSCRIPTEN
+ // include GL stuff, to check that we can compile hybrid 2d/GL apps
+ extern void glBegin(int mode);
+ extern void glBindBuffer(int target, int buffer);
+ if (argc == 9876) {
+ glBegin(0);
+ glBindBuffer(0, 0);
+ }
+#endif
+
+ SDL_Init(SDL_INIT_VIDEO);
+ SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE);
+
+ printf("Init: %d\n", TTF_Init());
+
+ TTF_Font *font = TTF_OpenFont("sans-serif", 40);
+ printf("Font: %p\n", font);
+
+ SDL_Color color = { 0xff, 0x99, 0x00, 0xff };
+
+ SDL_Surface *text = TTF_RenderText_Solid(font, "hello orange world", color);
+
+ SDL_Color color2 = { 0xbb, 0, 0xff, 0xff };
+ SDL_Surface *text2 = TTF_RenderText_Solid(font, "a second line, purple", color2);
+
+ // render
+ SDL_Rect dest = { 0, 50, 0, 0 };
+ SDL_BlitSurface (text, NULL, screen, NULL);
+ dest.y = 100;
+ SDL_BlitSurface (text2, NULL, screen, &dest);
+
+ // fill stuff
+ SDL_Rect rect = { 200, 200, 175, 125 };
+ SDL_FillRect(screen, &rect, SDL_MapRGBA(screen->format, 0x22, 0x22, 0xff, 0xff));
+
+ SDL_Flip(screen);
+
+ SDL_LockSurface(screen);
+
+ int sum = 0;
+ for (int i = 0; i < screen->h; i++) {
+ sum += *((char*)screen->pixels + i*screen->w*4 + i*4 + 0);
+ }
+ printf("Sum: %d\n", sum);
+
+ printf("you should see two lines of text in different colors and a blue rectangle\n");
+
+ SDL_Quit();
+
+ printf("done.\n");
+
+ int result = sum > 3000 && sum < 5000; // varies a little on different browsers, font differences?
+ REPORT_RESULT();
+
+ return 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/sdl_pumpevents.c b/tests/sdl_pumpevents.c
index 64becaad..e765d285 100644
--- a/tests/sdl_pumpevents.c
+++ b/tests/sdl_pumpevents.c
@@ -40,6 +40,20 @@ int loop2()
return r;
}
+int alphakey()
+{
+ unsigned i;
+ int r = 0;
+
+ SDL_PumpEvents();
+
+ const Uint8 *keys = SDL_GetKeyState(NULL);
+ if (keys[SDLK_a])
+ r = 4;
+
+ return r;
+}
+
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
@@ -49,6 +63,8 @@ int main(int argc, char *argv[])
result += loop1();
emscripten_run_script("keydown(39);"); // right
result += loop2();
+ emscripten_run_script("keydown(65);"); // A
+ result += alphakey();
REPORT_RESULT();
return 0;
}
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 7c387071..32b29966 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')
@@ -790,6 +794,17 @@ Press any key to continue.'''
def test_glut_touchevents(self):
self.btest('glut_touchevents.c', '1')
+ def test_file_db(self):
+ secret = str(time.time())
+ open('moar.txt', 'w').write(secret)
+ self.btest('file_db.cpp', '1', args=['--preload-file', 'moar.txt', '-DFIRST'])
+ shutil.copyfile('test.html', 'first.html')
+ self.btest('file_db.cpp', secret)
+ shutil.copyfile('test.html', 'second.html')
+ open('moar.txt', 'w').write('aliantha')
+ self.btest('file_db.cpp', secret, args=['--preload-file', 'moar.txt']) # even with a file there, we load over it
+ shutil.move('test.html', 'third.html')
+
def test_sdl_pumpevents(self):
# key events should be detected using SDL_PumpEvents
open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('''
@@ -801,7 +816,7 @@ Press any key to continue.'''
document.dispatchEvent(event);
}
''')
- self.btest('sdl_pumpevents.c', expected='3', args=['--pre-js', 'pre.js'])
+ self.btest('sdl_pumpevents.c', expected='7', args=['--pre-js', 'pre.js'])
def test_sdl_audio(self):
shutil.copyfile(path_from_root('tests', 'sounds', 'alarmvictory_1.ogg'), os.path.join(self.get_dir(), 'sound.ogg'))
diff --git a/tests/test_core.py b/tests/test_core.py
index 142d6df4..7c5b651f 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -4664,6 +4664,12 @@ The current type of b is: 9
'''
self.do_run(src, 'BA')
+ def test_pthread_specific(self):
+ if self.emcc_args is None: return self.skip('requires emcc')
+ src = open(path_from_root('tests', 'pthread', 'specific.c'), 'r').read()
+ expected = open(path_from_root('tests', 'pthread', 'specific.c.txt'), 'r').read()
+ self.do_run(src, expected, force_c=True)
+
def test_time(self):
# XXX Not sure what the right output is here. Looks like the test started failing with daylight savings changes. Modified it to pass again.
src = open(path_from_root('tests', 'time', 'src.c'), 'r').read()
@@ -5567,7 +5573,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>
@@ -6762,6 +6767,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 = '''
@@ -6788,8 +6794,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.
diff --git a/tests/test_other.py b/tests/test_other.py
index d6e67e59..a6813b07 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -330,27 +330,6 @@ f.close()
os.chdir(path_from_root('tests')) # Move away from the directory we are about to remove.
shutil.rmtree(tempdirname)
- def test_nostdincxx(self):
- try:
- old = os.environ.get('EMCC_LLVM_TARGET') or ''
- for compiler in [EMCC, EMXX]:
- for target in ['i386-pc-linux-gnu', 'le32-unknown-nacl']:
- print compiler, target
- os.environ['EMCC_LLVM_TARGET'] = target
- out, err = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp'), '-v'], stdout=PIPE, stderr=PIPE).communicate()
- out2, err2 = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp'), '-v', '-nostdinc++'], stdout=PIPE, stderr=PIPE).communicate()
- assert out == out2
- def focus(e):
- assert 'search starts here:' in e, e
- assert e.count('End of search list.') == 1, e
- return e[e.index('search starts here:'):e.index('End of search list.')+20]
- err = focus(err)
- err2 = focus(err2)
- assert err == err2, err + '\n\n\n\n' + err2
- finally:
- if old:
- os.environ['EMCC_LLVM_TARGET'] = old
-
def test_failure_error_code(self):
for compiler in [EMCC, EMXX]:
# Test that if one file is missing from the build, then emcc shouldn't succeed, and shouldn't try to produce an output file.
@@ -1902,7 +1881,7 @@ seeked= file.
if SPIDERMONKEY_ENGINE not in JS_ENGINES: return self.skip('cannot run without spidermonkey due to node limitations (Uint8ClampedArray etc.)')
shutil.copyfile(path_from_root('tests', 'screenshot.png'), o