summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-15 17:01:19 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-15 17:01:19 -0800
commitc42b937808924f6b922b29d2e0fd1fe1d1b0411c (patch)
tree4027d435b6638a7e72b9519990298fb9314ecc96 /tests
parent8478d6aee54d6c52de16d8c58309534afbf5bf9e (diff)
parente5ccf17e84e7a5102bf9e05ffef01e6672b4c15a (diff)
Merge branch 'incoming'
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/breakinthemiddle2.ll8
-rw-r--r--tests/cases/breakinthemiddle3.ll29
-rw-r--r--tests/cases/gepaddoverflow.ll37
-rw-r--r--tests/cases/gepaddoverflow.txt1
-rw-r--r--tests/cases/invokeundef.ll5
-rw-r--r--tests/cases/switch64_ta2.ll44
-rw-r--r--tests/cases/switch64_ta2.txt2
-rw-r--r--tests/cases/switch64b_ta2.ll54
-rw-r--r--tests/cases/switch64b_ta2.txt3
-rw-r--r--tests/core/test_literal_negative_zero.in27
-rw-r--r--tests/core/test_literal_negative_zero.out6
-rw-r--r--tests/core/test_wprintf.c63
-rw-r--r--tests/core/test_wprintf.out43
-rw-r--r--tests/doublestart.c23
-rw-r--r--tests/glew.c51
-rw-r--r--tests/math/lgamma.in105
-rw-r--r--tests/math/lgamma.out18
-rw-r--r--tests/openal_buffers.c4
-rwxr-xr-xtests/poppler/configure4
-rw-r--r--tests/poppler/configure.ac4
-rw-r--r--tests/printf/output.txt1
-rw-r--r--tests/printf/output_i64_1.txt1
-rw-r--r--tests/printf/test.c1
-rwxr-xr-xtests/runner.py5
-rw-r--r--tests/sdl_canvas.c2
-rw-r--r--tests/test_benchmark.py57
-rw-r--r--tests/test_browser.py65
-rw-r--r--tests/test_core.py63
-rw-r--r--tests/test_other.py51
-rw-r--r--tests/test_webgl_context_attributes_common.c6
-rw-r--r--tests/uuid/test.c69
31 files changed, 727 insertions, 125 deletions
diff --git a/tests/cases/breakinthemiddle2.ll b/tests/cases/breakinthemiddle2.ll
index ba96654f..2f8c1c91 100644
--- a/tests/cases/breakinthemiddle2.ll
+++ b/tests/cases/breakinthemiddle2.ll
@@ -11,10 +11,6 @@ define linkonce_odr i32 @main() align 2 {
label555: ; preds = %0
br label %label569 ; branch should ignore all code after it in the block
; No predecessors!
- %aa472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
- cleanup
- %aa473 = extractvalue { i8*, i32 } %aa472, 0
- %aa474 = extractvalue { i8*, i32 } %aa472, 1
br label %label569
label569: ; preds = %0
@@ -23,10 +19,6 @@ label569: ; preds = %0
label990:
ret i32 0 ; ret should ignore all code after it in the block
; No predecessors!
- %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
- cleanup
- %a473 = extractvalue { i8*, i32 } %a472, 0
- %a474 = extractvalue { i8*, i32 } %a472, 1
br label %label569
label999: ; preds = %555
diff --git a/tests/cases/breakinthemiddle3.ll b/tests/cases/breakinthemiddle3.ll
deleted file mode 100644
index 38da15ef..00000000
--- a/tests/cases/breakinthemiddle3.ll
+++ /dev/null
@@ -1,29 +0,0 @@
-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"
-
-@.str = private constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
-
-define linkonce_odr i32 @main() align 2 {
- %a333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- %z199 = trunc i8 1 to i1 ; [#uses=1]
- switch i32 %a333, label %label999 [
- i32 1000, label %label995
- ] ; switch should ignore all code after it in the block
- ; No predecessors!
- %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
- cleanup
- %a473 = extractvalue { i8*, i32 } %a472, 0
- %a474 = extractvalue { i8*, i32 } %a472, 1
- br label %label999
-
-label995:
- %b333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- br label %label999
-
-label999: ; preds = %555
- ret i32 0
-}
-
-declare i32 @printf(i8*)
-declare i32 @__gxx_personality_v0(...)
-
diff --git a/tests/cases/gepaddoverflow.ll b/tests/cases/gepaddoverflow.ll
new file mode 100644
index 00000000..11246c1d
--- /dev/null
+++ b/tests/cases/gepaddoverflow.ll
@@ -0,0 +1,37 @@
+; ModuleID = 'new.o'
+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"
+
+declare i32 @printf(i8* noalias, ...) nounwind
+
+@x = common global [4194304 x i8] zeroinitializer, align 4
+@.str = private constant [6 x i8] c"*%d*\0A\00", align 1
+
+define i8* @test_gep(i32 %y) nounwind readnone {
+ ; JavaScript uses double precision 64-bit floating point values, with
+ ; a 53 bit mantissa. The maximum precisely representable integer is
+ ; 9007199254740992. A number close to that limit is constructed here
+ ; for the constant part of the getelementptr instruction:
+ ; 4194304 * 2147483647 == 9007199250546688 == 9007199254740992 - 4194304
+ ; If that number appears in JavaScript source instead of being properly
+ ; limited to 32 bits, the %y parameter can be used to exceed the maximum
+ ; precisely representable integer, and make the computation inexact.
+ %test_res = getelementptr [4194304 x i8]* @x, i32 2147483647, i32 %y
+ ret i8* %test_res
+}
+
+define i32 @main() {
+ %res_0 = call i8* (i32)* @test_gep(i32 1000000000)
+ %res_1 = call i8* (i32)* @test_gep(i32 1000000001)
+ %res_0_i = ptrtoint i8* %res_0 to i32
+ %res_1_i = ptrtoint i8* %res_1 to i32
+
+ ; If getelementptr limited the constant part of the offset to 32 bits,
+ ; result will be 1. Otherwise, it cannot be 1 because the large numbers in
+ ; the calculation cannot be accurately represented by floating point math.
+ %res_diff = sub i32 %res_1_i, %res_0_i
+ %printf_res = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i32 %res_diff)
+
+ ret i32 0
+}
+
diff --git a/tests/cases/gepaddoverflow.txt b/tests/cases/gepaddoverflow.txt
new file mode 100644
index 00000000..10fd998b
--- /dev/null
+++ b/tests/cases/gepaddoverflow.txt
@@ -0,0 +1 @@
+*1*
diff --git a/tests/cases/invokeundef.ll b/tests/cases/invokeundef.ll
index be1dd671..2f13e7ab 100644
--- a/tests/cases/invokeundef.ll
+++ b/tests/cases/invokeundef.ll
@@ -31,6 +31,8 @@ invcont33:
ret i32 %retval1
lpad106:
+ %Z = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ cleanup
ret i32 %retval1
return: ; preds = %entry
@@ -40,3 +42,6 @@ return: ; preds = %entry
; [#uses=1]
declare i32 @puts(i8*)
+
+declare i32 @__gxx_personality_v0(...)
+
diff --git a/tests/cases/switch64_ta2.ll b/tests/cases/switch64_ta2.ll
index 4d5c6273..1a6d52f3 100644
--- a/tests/cases/switch64_ta2.ll
+++ b/tests/cases/switch64_ta2.ll
@@ -1,12 +1,14 @@
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"
-@.str = private constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
+@.str = private constant [18 x i8] c"hello, world: %d\0A\00", align 1
+
+declare i32 @printf(i8*, ...)
define linkonce_odr i32 @main() align 2 {
- %a333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- %a444 = zext i32 %a333 to i64
- %a199 = trunc i8 1 to i1 ; [#uses=1]
+ %a333 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 5)
+ %a400 = zext i32 %a333 to i64
+ %a444 = udiv i64 %a400, 3
switch i64 %a444, label %label999 [
i64 1000, label %label9950
i64 1001, label %label9951
@@ -18,41 +20,35 @@ define linkonce_odr i32 @main() align 2 {
i64 1007, label %label9957
i64 1008, label %label9958
i64 1009, label %label9959
- ] ; switch should ignore all code after it in the block
- ; No predecessors!
- %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
- cleanup
- %a473 = extractvalue { i8*, i32 } %a472, 0
- %a474 = extractvalue { i8*, i32 } %a472, 1
- br label %label999
+ ]
label9950:
- %a333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %waka = phi i32 [1000, %0], [0, %label9951], [1, %label9952], [2, %label9953], [3, %label9954], [4, %label9955], [5, %label9956], [6, %label9957], [7, %label9958], [8, %label9959]
+ %a333b = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %waka)
br label %label999
label9951:
- br label %label999
+ br label %label9950
label9952:
- br label %label999
+ br label %label9950
label9953:
- br label %label999
+ br label %label9950
label9954:
- br label %label999
+ br label %label9950
label9955:
- br label %label999
+ br label %label9950
label9956:
- br label %label999
+ br label %label9950
label9957:
- br label %label999
+ br label %label9950
label9958:
- br label %label999
+ br label %label9950
label9959:
- br label %label999
+ br label %label9950
label999: ; preds = %555
+ %last = phi i32 [1, %0], [2, %label9950]
+ %a333c = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %last)
ret i32 0
}
-declare i32 @printf(i8*)
-declare i32 @__gxx_personality_v0(...)
-
diff --git a/tests/cases/switch64_ta2.txt b/tests/cases/switch64_ta2.txt
new file mode 100644
index 00000000..72084b0c
--- /dev/null
+++ b/tests/cases/switch64_ta2.txt
@@ -0,0 +1,2 @@
+hello, world: 5
+hello, world: 1
diff --git a/tests/cases/switch64b_ta2.ll b/tests/cases/switch64b_ta2.ll
new file mode 100644
index 00000000..4364725f
--- /dev/null
+++ b/tests/cases/switch64b_ta2.ll
@@ -0,0 +1,54 @@
+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"
+
+@.str = private constant [18 x i8] c"hello, world: %d\0A\00", align 1
+
+declare i32 @printf(i8*, ...)
+
+define linkonce_odr i32 @main() align 2 {
+ %a333 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 5)
+ %a400 = zext i32 %a333 to i64
+ %a444 = udiv i64 %a400, 3
+ switch i64 %a444, label %label999 [
+ i64 0, label %label9950
+ i64 1, label %label9951
+ i64 2, label %label9952
+ i64 3, label %label9953
+ i64 4, label %label9954
+ i64 5, label %label9955
+ i64 6, label %label9956
+ i64 7, label %label9957
+ i64 8, label %label9958
+ i64 9, label %label9959
+ ]
+
+label9950:
+ %waka = phi i32 [11000, %0], [10, %label9951], [11, %label9952], [12, %label9953], [13, %label9954], [14, %label9955], [15, %label9956], [16, %label9957], [17, %label9958], [18, %label9959]
+ %a333b = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %waka)
+ br label %label999
+
+label9951:
+ br label %label9950
+label9952:
+ br label %label9950
+label9953:
+ br label %label9950
+label9954:
+ br label %label9950
+label9955:
+ br label %label9950
+label9956:
+ br label %label9950
+label9957:
+ br label %label9950
+label9958:
+ br label %label9950
+label9959:
+ br label %label9950
+
+label999: ; preds = %555
+ %last = phi i32 [1, %0], [2, %label9950]
+ %a333c = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %last)
+ ret i32 0
+}
+
diff --git a/tests/cases/switch64b_ta2.txt b/tests/cases/switch64b_ta2.txt
new file mode 100644
index 00000000..917d42e5
--- /dev/null
+++ b/tests/cases/switch64b_ta2.txt
@@ -0,0 +1,3 @@
+hello, world: 5
+hello, world: 14
+hello, world: 2
diff --git a/tests/core/test_literal_negative_zero.in b/tests/core/test_literal_negative_zero.in
new file mode 100644
index 00000000..1554fbf5
--- /dev/null
+++ b/tests/core/test_literal_negative_zero.in
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <math.h>
+
+static float XXXf = -0.0f;
+static double XXXd = -0.0;
+
+struct x {
+ float f;
+ double d;
+};
+
+static struct x xx[] = {
+ -0x0p+0,
+ -0x0p+0,
+};
+
+int main(int argc, char ** argv) {
+ float YYYf = -0.0f;
+ float YYYd = -0.0;
+
+ printf("%.2f\n", XXXf);
+ printf("%.2f\n", XXXd);
+ printf("%.2f\n", YYYf);
+ printf("%.2f\n", YYYd);
+ printf("%.2f\n", xx->f);
+ printf("%.2f\n", xx->d);
+}
diff --git a/tests/core/test_literal_negative_zero.out b/tests/core/test_literal_negative_zero.out
new file mode 100644
index 00000000..d1b863b8
--- /dev/null
+++ b/tests/core/test_literal_negative_zero.out
@@ -0,0 +1,6 @@
+-0.00
+-0.00
+-0.00
+-0.00
+-0.00
+-0.00
diff --git a/tests/core/test_wprintf.c b/tests/core/test_wprintf.c
new file mode 100644
index 00000000..b5f8d6ab
--- /dev/null
+++ b/tests/core/test_wprintf.c
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <wchar.h>
+
+void PrintWide ( const wchar_t * format, ... )
+{
+ wchar_t buffer[256];
+ memset(buffer, 0, 256);
+ va_list args;
+ va_start ( args, format );
+ wprintf(L"format starts with 0x%x\n", *(int*)format);
+ wprintf(L"fmt continues with 0x%x\n", *(((int*)format) + 1));
+ wprintf(L"fmt continues with 0x%x\n", *(((int*)format) + 2));
+ int r = vswprintf ( buffer, 256, format, args );
+ wprintf(L"vswprintf told us %d\n", r);
+ wprintf(L"vswoutput st-rts with 0x%x\n", *(int*)buffer);
+ wprintf(L"vsw continues with 0x%x\n", *(((int*)buffer) + 1));
+ wprintf(L"vsw continues with 0x%x\n", *(((int*)buffer) + 2));
+ wprintf(buffer);
+ va_end ( args );
+}
+
+int main ()
+{
+ FILE *f = fopen("test.dat", "wb");
+ int num = fwprintf(f, L"hello %d", 5);
+ wprintf(L"fwprintf told us %d\n", num);
+ fclose(f);
+ f = fopen("test.dat", "rb");
+ fseek(f, 0, SEEK_END);
+ int size = ftell(f);
+ fclose(f);
+ wprintf(L"file size is %d\n", size);
+
+ wchar_t str[] = L"test string has %d wide characters.\n";
+ wprintf(L"str starts with 0x%x\n", *(int*)str);
+ wprintf(L"str continues with 0x%x\n", *(((int*)str) + 1));
+ wprintf(L"str continues with 0x%x\n", *(((int*)str) + 2));
+ PrintWide ( str, wcslen(str) );
+
+ wprintf (L"Characters: %lc %lc \n", L'a', 65);
+ wprintf (L"Decimals: %d %ld\n", 1977, 650000L);
+ wprintf (L"Preceding with blanks: %10d \n", 1977);
+ wprintf (L"Preceding with zeros: %010d \n", 1977);
+ wprintf (L"Some different radixes: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);
+ wprintf (L"floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416);
+ wprintf (L"Width trick: %*d \n", 5, 10);
+ wprintf (L"%ls \n", L"A wide string");
+
+ wchar_t buffer [100];
+ memset(buffer, 0, sizeof(buffer));
+ int cx;
+ cx = swprintf(buffer, 100, L"The half of %d is %d", 80, 80/2);
+ wprintf(L"swprintf told us %d\n", cx);
+ for (int i = 0; i < 10; i++) wprintf(L"pre %d\n", ((int*)buffer)[i]);
+ swprintf (buffer+cx, 100-cx-1, L", and the half of that is %d.\n", 80/2/2);
+ for (int i = 0; i < 10; i++) wprintf(L"post %d\n", ((int*)buffer)[i]);
+ wprintf(buffer);
+
+ return 0;
+}
+
diff --git a/tests/core/test_wprintf.out b/tests/core/test_wprintf.out
new file mode 100644
index 00000000..e074743d
--- /dev/null
+++ b/tests/core/test_wprintf.out
@@ -0,0 +1,43 @@
+fwprintf told us 7
+file size is 7
+str starts with 0x74
+str continues with 0x65
+str continues with 0x73
+format starts with 0x74
+fmt continues with 0x65
+fmt continues with 0x73
+vswprintf told us 36
+vswoutput st-rts with 0x74
+vsw continues with 0x65
+vsw continues with 0x73
+test string has 36 wide characters.
+Characters: a A
+Decimals: 1977 650000
+Preceding with blanks: 1977
+Preceding with zeros: 0000001977
+Some different radixes: 100 64 144 0x64 0144
+floats: 3.14 +3e+00 3.141600E+00
+Width trick: 10
+A wide string
+swprintf told us 20
+pre 84
+pre 104
+pre 101
+pre 32
+pre 104
+pre 97
+pre 108
+pre 102
+pre 32
+pre 111
+post 84
+post 104
+post 101
+post 32
+post 104
+post 97
+post 108
+post 102
+post 32
+post 111
+The half of 80 is 40, and the half of that is 20.
diff --git a/tests/doublestart.c b/tests/doublestart.c
new file mode 100644
index 00000000..533e6308
--- /dev/null
+++ b/tests/doublestart.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <emscripten.h>
+
+int times = 0;
+
+void later(void* nada) {
+ int result = times;
+ REPORT_RESULT();
+}
+
+void main_loop(void) {
+ static int cnt = 0;
+ if (++cnt >= 10) emscripten_cancel_main_loop();
+}
+
+int main(void) {
+ emscripten_async_call(later, NULL, 2000);
+ times++;
+ printf("This should only appear once.\n");
+ emscripten_set_main_loop(main_loop, 10, 0);
+ return 0;
+}
+
diff --git a/tests/glew.c b/tests/glew.c
new file mode 100644
index 00000000..3bf93fd9
--- /dev/null
+++ b/tests/glew.c
@@ -0,0 +1,51 @@
+#include <GL/glew.h>
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+
+/* for context creation */
+#include <SDL/SDL.h>
+
+int main()
+{
+ assert(SDL_Init(SDL_INIT_VIDEO) == 0);
+ assert(SDL_SetVideoMode(640, 480, 16, SDL_OPENGL) != NULL);
+
+ assert(glewInit() == GLEW_OK);
+ assert(glewGetString(0) == NULL);
+ assert(!strcmp((const char*)glewGetString(1), "1.10.0"));
+ assert(!strcmp((const char*)glewGetString(2), "1"));
+ assert(!strcmp((const char*)glewGetString(3), "10"));
+ assert(!strcmp((const char*)glewGetString(4), "0"));
+
+ for (int i = 0; i < 8; ++i) {
+ assert(glewGetErrorString(i) != NULL);
+ }
+
+ assert(glewGetExtension("EXT_unexistant") == 0);
+ assert(glewIsSupported("EXT_unexistant EXT_foobar") == 0);
+
+ /* we can't be sure about which extension exists, so lets do test on
+ * some of the common ones */
+ if (GLEW_EXT_texture_filter_anisotropic) {
+ assert(glewGetExtension("EXT_texture_filter_anisotropic") == 1);
+ assert(glewGetExtension("GL_EXT_texture_filter_anisotropic") == 1);
+ }
+
+ if (GLEW_EXT_framebuffer_object) {
+ assert(glewGetExtension("EXT_framebuffer_object") == 1);
+ assert(glewGetExtension("GL_EXT_framebuffer_object") == 1);
+ }
+
+ if (GLEW_EXT_texture_filter_anisotropic &&
+ GLEW_EXT_framebuffer_object) {
+ assert(glewIsSupported("EXT_texture_filter_anisotropic EXT_framebuffer_object") == 1);
+ assert(glewIsSupported("GL_EXT_texture_filter_anisotropic GL_EXT_framebuffer_object") == 1);
+ }
+
+#ifdef REPORT_RESULT
+ int result = 1;
+ REPORT_RESULT();
+#endif
+ return 0;
+}
diff --git a/tests/math/lgamma.in b/tests/math/lgamma.in
new file mode 100644
index 00000000..e96f5610
--- /dev/null
+++ b/tests/math/lgamma.in
@@ -0,0 +1,105 @@
+#define _BSD_SOURCE 1
+#define _XOPEN_SOURCE 700
+#include <stdint.h>
+#include <stdio.h>
+#include <fenv.h>
+#include <float.h>
+#include <math.h>
+
+#define RN 0
+#define T(...) {__FILE__, __LINE__, __VA_ARGS__},
+#define POS const char *file; int line;
+struct f_fi {POS int r; float x; float y; float dy; long long i; int e; };
+
+#define DIVBYZERO 0
+#define INEXACT 0
+#define INVALID 0
+#define OVERFLOW 0
+#define UNDERFLOW 0
+
+#define inf INFINITY
+#define nan NAN
+
+static struct f_fi t[] = {
+T(RN, -0x1.02239f3c6a8f1p+3, -0x1.0120f61b63d5ep+3, 0x1.89ccc4p-6, -1, INEXACT)
+T(RN, 0x1.161868e18bc67p+2, 0x1.1ef3b263fd60bp+1, -0x1.6d0264p-3, 1, INEXACT)
+T(RN, -0x1.0c34b3e01e6e7p+3, -0x1.46d73255263d9p+3, 0x1.e0ec76p-3, -1, INEXACT)
+T(RN, -0x1.a206f0a19dcc4p+2, -0x1.9c91f19ac48c5p+2, 0x1.c2a38cp-2, -1, INEXACT)
+T(RN, 0x1.288bbb0d6a1e6p+3, 0x1.65c60768fcc11p+3, 0x1.2f22c2p-2, 1, INEXACT)
+T(RN, 0x1.52efd0cd80497p-1, 0x1.3cc760be720b3p-2, 0x1.0527e2p-2, 1, INEXACT)
+T(RN, -0x1.a05cc754481d1p-2, 0x1.4ef387fea1014p+0, -0x1.c3b036p-2, -1, INEXACT)
+T(RN, 0x1.1f9ef934745cbp-1, 0x1.d6f0efacc5699p-2, 0x1.c0b0a8p-2, 1, INEXACT)
+T(RN, 0x1.8c5db097f7442p-1, 0x1.6c1a14cf91533p-3, 0x1.16f4cap-5, 1, INEXACT)
+T(RN, -0x1.5b86ea8118a0ep-1, 0x1.695b1e0a0a59ep+0, 0x1.ada69ep-2, -1, INEXACT)
+T(RN, 0x0p+0, inf, 0x0p+0, 1, DIVBYZERO)
+/* T(RN, -0x0p+0, inf, 0x0p+0, -1, DIVBYZERO) This one fails in native as well */
+T(RN, 0x1p+0, 0x0p+0, 0x0p+0, 1, 0)
+T(RN, -0x1p+0, inf, 0x0p+0, 1, DIVBYZERO)
+T(RN, 0x1p+1, 0x0p+0, 0x0p+0, 1, 0)
+T(RN, -0x1p+1, inf, 0x0p+0, 1, DIVBYZERO)
+T(RN, inf, inf, 0x0p+0, 1, 0)
+T(RN, -inf, inf, 0x0p+0, -1, 0)
+T(RN, nan, nan, 0x0p+0, 1, 0)
+};
+
+static int eulpf(float x)
+{
+ union { float f; uint32_t i; } u = { x };
+ int e = u.i>>23 & 0xff;
+
+ if (!e)
+ e++;
+ return e - 0x7f - 23;
+}
+
+static int checkulp(float d, int r)
+{
+ // TODO: we only care about >=1.5 ulp errors for now, should be 1.0
+ if (r == RN)
+ return fabsf(d) < 1.5;
+ return 1;
+}
+
+static float ulperrf(float got, float want, float dwant)
+{
+ if (isnan(got) && isnan(want))
+ return 0;
+ if (got == want) {
+ if (signbit(got) == signbit(want))
+ return dwant;
+ return INFINITY;
+ }
+ if (isinf(got)) {
+ got = copysignf(0x1p127, got);
+ want *= 0.5;
+ }
+ return scalbn(got - want, -eulpf(want)) + dwant;
+}
+
+int main(void)
+{
+ int yi;
+ double y;
+ float d;
+ int e, i, err = 0;
+ struct f_fi *p;
+
+ for (i = 0; i < sizeof t/sizeof *t; i++) {
+ p = t + i;
+
+ if (p->r < 0)
+ continue;
+ y = lgammaf(p->x);
+ yi = signgam;
+
+ printf("%g,%d\n", y, yi);
+
+ d = ulperrf(y, p->y, p->dy);
+ if (!checkulp(d, p->r) || (!isnan(p->x) && p->x!=-inf && !(p->e&DIVBYZERO) && yi != p->i)) {
+ /* printf("%s:%d: %d lgammaf(%g) want %g,%lld got %g,%d ulperr %.3f = %g + %g\n",
+ p->file, p->line, p->r, p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy); */
+ err++;
+ }
+ }
+ return !!err;
+}
diff --git a/tests/math/lgamma.out b/tests/math/lgamma.out
new file mode 100644
index 00000000..7412ffb6
--- /dev/null
+++ b/tests/math/lgamma.out
@@ -0,0 +1,18 @@
+-8.03528,-1
+2.24181,1
+-10.2138,-1
+-6.44641,-1
+11.1804,1
+0.309354,1
+1.3084,-1
+0.459903,1
+0.177784,1
+1.41155,-1
+inf,1
+0,1
+inf,1
+0,1
+inf,1
+inf,1
+inf,1
+nan,1
diff --git a/tests/openal_buffers.c b/tests/openal_buffers.c
index 6f51a685..31104a33 100644
--- a/tests/openal_buffers.c
+++ b/tests/openal_buffers.c
@@ -26,7 +26,7 @@ unsigned int bits = 0;
ALenum format = 0;
ALuint source = 0;
-void iter(void *arg) {
+void iter() {
ALuint buffer = 0;
ALint buffersProcessed = 0;
ALint buffersWereQueued = 0;
@@ -180,7 +180,7 @@ int main(int argc, char* argv[]) {
emscripten_set_main_loop(iter, 0, 0);
#else
while (1) {
- iter(NULL);
+ iter();
usleep(16);
}
#endif
diff --git a/tests/poppler/configure b/tests/poppler/configure
index 75813bc9..ab650a30 100755
--- a/tests/poppler/configure
+++ b/tests/poppler/configure
@@ -23051,12 +23051,12 @@ if test "x$GCC" != xyes; then
fi
case "$enable_compile_warnings" in
no) ;;
- yes) CXXFLAGS="-Wall -Wno-write-strings -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions -fno-check-new -fno-common $CXXFLAGS" ;;
+ yes) CXXFLAGS="-Wall -Wno-write-strings -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions -fno-common $CXXFLAGS" ;;
kde) CXXFLAGS="-Wnon-virtual-dtor -Wno-long-long -Wundef \
-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -Wcast-align \
-Wconversion -Wall -W -Wpointer-arith \
-Wwrite-strings -O2 -Wformat-security \
- -Wmissing-format-attribute -fno-exceptions -fno-check-new \
+ -Wmissing-format-attribute -fno-exceptions \
-fno-common $CXXFLAGS" ;;
esac
diff --git a/tests/poppler/configure.ac b/tests/poppler/configure.ac
index f1217c8e..e492fe4b 100644
--- a/tests/poppler/configure.ac
+++ b/tests/poppler/configure.ac
@@ -610,12 +610,12 @@ if test "x$GCC" != xyes; then
fi
case "$enable_compile_warnings" in
no) ;;
- yes) CXXFLAGS="-Wall -Wno-write-strings -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions -fno-check-new -fno-common $CXXFLAGS" ;;
+ yes) CXXFLAGS="-Wall -Wno-write-strings -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions -fno-common $CXXFLAGS" ;;
kde) CXXFLAGS="-Wnon-virtual-dtor -Wno-long-long -Wundef \
-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -Wcast-align \
-Wconversion -Wall -W -Wpointer-arith \
-Wwrite-strings -O2 -Wformat-security \
- -Wmissing-format-attribute -fno-exceptions -fno-check-new \
+ -Wmissing-format-attribute -fno-exceptions \
-fno-common $CXXFLAGS" ;;
esac
diff --git a/tests/printf/output.txt b/tests/printf/output.txt
index 0155f0da..a3baed28 100644
--- a/tests/printf/output.txt
+++ b/tests/printf/output.txt
@@ -8280,4 +8280,5 @@ ffffff8000000000
1
1
+1.234568E+04
no_new_line
diff --git a/tests/printf/output_i64_1.txt b/tests/printf/output_i64_1.txt
index e38fb78f..ea85d302 100644
--- a/tests/printf/output_i64_1.txt
+++ b/tests/printf/output_i64_1.txt
@@ -8280,4 +8280,5 @@ ffffff8000000000
1
1
+1.234568E+04
no_new_line
diff --git a/tests/printf/test.c b/tests/printf/test.c
index 1c8ad9f7..adeb69db 100644
--- a/tests/printf/test.c
+++ b/tests/printf/test.c
@@ -8285,6 +8285,7 @@ int main() {
printf("%hx\n", -0xFFFF);
printf("%x\n", -0xFFFFFFFF);
printf("\n");
+ printf("%*.*E\n", 10, -1, 12345.6789123);
printf("no_new_line");
return 0;
}
diff --git a/tests/runner.py b/tests/runner.py
index 37e307e9..7f0cbaed 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -342,7 +342,7 @@ process(sys.argv[1])
if self.library_cache is not None:
if cache and self.library_cache.get(cache_name):
- print >> sys.stderr, '<load %s from cache> ' % cache_name,
+ print >> sys.stderr, '<load %s from cache> ' % cache_name
generated_libs = []
for basename, contents in self.library_cache[cache_name]:
bc_file = os.path.join(build_dir, cache_name + '_' + basename)
@@ -352,7 +352,7 @@ process(sys.argv[1])
generated_libs.append(bc_file)
return generated_libs
- print >> sys.stderr, '<building and saving %s into cache> ' % cache_name,
+ print >> sys.stderr, '<building and saving %s into cache> ' % cache_name
return Building.build_library(name, build_dir, output_dir, generated_libs, configure, configure_args, make, make_args, self.library_cache, cache_name,
copy_project=True, env_init=env_init, native=native)
@@ -649,6 +649,7 @@ class BrowserCore(RunnerCore):
def btest(self, filename, expected=None, reference=None, force_c=False, reference_slack=0, manual_reference=False, post_build=None,
args=[], outfile='test.html', message='.'): # TODO: use in all other tests
+ if os.environ.get('EMCC_FAST_COMPILER') == '1' and 'LEGACY_GL_EMULATION=1' in args: return self.skip('no legacy gl emulation in fastcomp')
# if we are provided the source and not a path, use that
filename_is_src = '\n' in filename
src = filename if filename_is_src else ''
diff --git a/tests/sdl_canvas.c b/tests/sdl_canvas.c
index 6bd659b8..cab48985 100644
--- a/tests/sdl_canvas.c
+++ b/tests/sdl_canvas.c
@@ -62,6 +62,8 @@ int main(int argc, char **argv) {
printf("you should see two lines of text in different colors and a blue rectangle\n");
+ SDL_UnlockSurface(screen);
+
SDL_Quit();
printf("done.\n");
diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py
index d84f36e4..21a47178 100644
--- a/tests/test_benchmark.py
+++ b/tests/test_benchmark.py
@@ -58,7 +58,7 @@ class NativeBenchmarker(Benchmarker):
def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder):
self.parent = parent
- if lib_builder: native_args += lib_builder(self.name, native=True, env_init={ 'CC': self.cc, 'CXX': self.cxx })
+ if lib_builder: native_args = native_args + lib_builder(self.name, native=True, env_init={ 'CC': self.cc, 'CXX': self.cxx })
if not native_exec:
compiler = self.cxx if filename.endswith('cpp') else self.cc
process = Popen([compiler, '-O2', '-fno-math-errno', filename, '-o', filename+'.native'] + shared_args + native_args, stdout=PIPE, stderr=parent.stderr_redirect)
@@ -67,7 +67,6 @@ class NativeBenchmarker(Benchmarker):
print >> sys.stderr, "Building native executable with command '%s' failed with a return code %d!" % (' '.join([compiler, '-O2', filename, '-o', filename+'.native']), process.returncode)
print "Output: " + output[0]
else:
- print '(using clang)'
shutil.copyfile(native_exec, filename + '.native')
shutil.copymode(native_exec, filename + '.native')
@@ -90,7 +89,8 @@ class JSBenchmarker(Benchmarker):
def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder):
self.filename = filename
- if lib_builder: emcc_args += lib_builder('js', native=False, env_init={})
+ llvm_root = self.env.get('LLVM') or LLVM_ROOT
+ if lib_builder: emcc_args = emcc_args + lib_builder('js_' + llvm_root, native=False, env_init=self.env)
open('hardcode.py', 'w').write('''
def process(filename):
@@ -119,16 +119,27 @@ process(sys.argv[1])
return run_js(self.filename, engine=self.engine, args=args, stderr=PIPE, full_output=True)
# Benchmarkers
-benchmarkers = [
- NativeBenchmarker('clang', CLANG_CC, CLANG),
- #NativeBenchmarker('gcc', 'gcc', 'g++'),
- #JSBenchmarker('sm-f32', SPIDERMONKEY_ENGINE, ['-s', 'PRECISE_F32=2']),
- JSBenchmarker('sm', SPIDERMONKEY_ENGINE),
- #JSBenchmarker('sm-fc', SPIDERMONKEY_ENGINE, env={ 'EMCC_FAST_COMPILER': '1' }),
- #JSBenchmarker('sm-noasm', SPIDERMONKEY_ENGINE + ['--no-asmjs']),
- #JSBenchmarker('sm-noasm-f32', SPIDERMONKEY_ENGINE + ['--no-asmjs'], ['-s', 'PRECISE_F32=2']),
- #JSBenchmarker('v8', V8_ENGINE)
-]
+try:
+ benchmarkers_error = ''
+ benchmarkers = [
+ #NativeBenchmarker('clang', CLANG_CC, CLANG),
+ NativeBenchmarker('clang-3.2', os.path.join(LLVM_3_2, 'clang'), os.path.join(LLVM_3_2, 'clang++')),
+ #NativeBenchmarker('clang-3.3', os.path.join(LLVM_3_3, 'clang'), os.path.join(LLVM_3_3, 'clang++')),
+ #NativeBenchmarker('clang-3.4', os.path.join(LLVM_3_4, 'clang'), os.path.join(LLVM_3_4, 'clang++')),
+ #NativeBenchmarker('gcc', 'gcc', 'g++'),
+ JSBenchmarker('sm-f32', SPIDERMONKEY_ENGINE, ['-s', 'PRECISE_F32=2']),
+ #JSBenchmarker('sm-f32-aggro', SPIDERMONKEY_ENGINE, ['-s', 'PRECISE_F32=2', '-s', 'AGGRESSIVE_VARIABLE_ELIMINATION=1']),
+ #JSBenchmarker('sm-f32-3.2', SPIDERMONKEY_ENGINE, ['-s', 'PRECISE_F32=2'], env={ 'LLVM': LLVM_3_2 }),
+ #JSBenchmarker('sm-f32-3.3', SPIDERMONKEY_ENGINE, ['-s', 'PRECISE_F32=2'], env={ 'LLVM': LLVM_3_3 }),
+ #JSBenchmarker('sm-f32-3.4', SPIDERMONKEY_ENGINE, ['-s', 'PRECISE_F32=2'], env={ 'LLVM': LLVM_3_4 }),
+ #JSBenchmarker('sm-fc', SPIDERMONKEY_ENGINE, env={ 'EMCC_FAST_COMPILER': '1' }),
+ #JSBenchmarker('sm-noasm', SPIDERMONKEY_ENGINE + ['--no-asmjs']),
+ #JSBenchmarker('sm-noasm-f32', SPIDERMONKEY_ENGINE + ['--no-asmjs'], ['-s', 'PRECISE_F32=2']),
+ #JSBenchmarker('v8', V8_ENGINE)
+ ]
+except Exception, e:
+ benchmarkers_error = str(e)
+ benchmarkers = []
class benchmark(RunnerCore):
save_dir = True
@@ -166,6 +177,8 @@ class benchmark(RunnerCore):
Building.COMPILER_TEST_OPTS = []
def do_benchmark(self, name, src, expected_output='FAIL', args=[], emcc_args=[], native_args=[], shared_args=[], force_c=False, reps=TEST_REPS, native_exec=None, output_parser=None, args_processor=None, lib_builder=None):
+ if len(benchmarkers) == 0: raise Exception('error, no benchmarkers: ' + benchmarkers_error)
+
args = args or [DEFAULT_ARG]
if args_processor: args = args_processor(args)
@@ -458,17 +471,15 @@ class benchmark(RunnerCore):
def lua(self, benchmark, expected, output_parser=None, args_processor=None):
shutil.copyfile(path_from_root('tests', 'lua', benchmark + '.lua'), benchmark + '.lua')
- #shutil.copyfile(path_from_root('tests', 'lua', 'binarytrees.lua'), 'binarytrees.lua')
- #shutil.copyfile(path_from_root('tests', 'lua', 'scimark.lua'), 'scimark.lua')
- emcc_args = self.get_library('lua', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None) + \
- ['--embed-file', benchmark + '.lua']
- #['--embed-file', 'binarytrees.lua', '--embed-file', 'scimark.lua'] + ['--minify', '0']
- shutil.copyfile(emcc_args[0], emcc_args[0] + '.bc')
- emcc_args[0] += '.bc'
- native_args = self.get_library('lua_native', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None, native=True)
-
+ def lib_builder(name, native, env_init):
+ ret = self.get_library('lua', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None, native=native, cache_name_extra=name, env_init=env_init)
+ if native: return ret
+ shutil.copyfile(ret[0], ret[0] + '.bc')
+ ret[0] += '.bc'
+ return ret
self.do_benchmark('lua_' + benchmark, '', expected,
- force_c=True, args=[benchmark + '.lua', DEFAULT_ARG], emcc_args=emcc_args, native_args=native_args, native_exec=os.path.join('building', 'lua_native', 'src', 'lua'),
+ force_c=True, args=[benchmark + '.lua', DEFAULT_ARG], emcc_args=['--embed-file', benchmark + '.lua'],
+ lib_builder=lib_builder, native_exec=os.path.join('building', 'lua_native', 'src', 'lua'),
output_parser=output_parser, args_processor=args_processor)
def test_zzz_lua_scimark(self):
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 920c6f8c..eed18a3d 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -120,6 +120,8 @@ If manually bisecting:
'''
def test_emscripten_log(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('fastcomp uses asm, where call stacks are sometimes less clear')
+
src = os.path.join(self.get_dir(), 'src.cpp')
open(src, 'w').write(self.with_report_result(open(path_from_root('tests', 'emscripten_log', 'emscripten_log.cpp')).read()))
@@ -680,10 +682,7 @@ If manually bisecting:
self.btest('sdl_stb_image_data.c', reference='screenshot.jpg', args=['-s', 'STB_IMAGE=1', '--preload-file', 'screenshot.not'])
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', '-s', 'LEGACY_GL_EMULATION=1']).communicate()
- self.run_browser('page.html', '', '/report_result?1')
+ self.btest('sdl_canvas.c', expected='1', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_sdl_canvas_proxy(self):
def post():
@@ -1111,6 +1110,8 @@ keydown(100);keyup(100); // trigger the end
self.run_browser('page.html', '', '/report_result?1')
def test_sdl_audio_beeps(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo c++ exceptions in fastcomp')
+
open(os.path.join(self.get_dir(), 'sdl_audio_beep.cpp'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_audio_beep.cpp')).read()))
# use closure to check for a possible bug with closure minifying away newer Audio() attributes
@@ -1194,10 +1195,7 @@ keydown(100);keyup(100); // trigger the end
self.btest('openal_buffers.c', '0', args=['--preload-file', 'the_entertainer.wav'],)
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', '-s', 'LEGACY_GL_EMULATION=1']).communicate()
- self.run_browser('page.html', '', '/report_result?1')
+ self.btest('glfw.c', '1', args=['-s', 'LEGACY_GL_EMULATION=1'])
def test_egl(self):
open(os.path.join(self.get_dir(), 'test_egl.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'test_egl.c')).read()))
@@ -1436,6 +1434,8 @@ keydown(100);keyup(100); // trigger the end
self.btest('sdl_resize.c', '1')
def test_gc(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('flaky in fastcomp and also non-fastcomp -O1, timing issues')
+
self.btest('browser_gc.cpp', '1')
def test_glshaderinfo(self):
@@ -1622,11 +1622,12 @@ keydown(100);keyup(100); // trigger the end
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:
+ if SPIDERMONKEY_ENGINE in JS_ENGINES and os.environ.get('EMCC_FAST_COMPILER') != '1':
# 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')
+ print 'passed asm test'
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', '-s', 'LEGACY_GL_EMULATION=1'])
@@ -1681,6 +1682,8 @@ keydown(100);keyup(100); // trigger the end
self.btest('http.cpp', expected='0', args=['-I' + path_from_root('tests')])
def test_module(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
Popen([PYTHON, EMCC, path_from_root('tests', 'browser_module.cpp'), '-o', 'module.js', '-O2', '-s', 'SIDE_MODULE=1', '-s', 'DLOPEN_SUPPORT=1', '-s', 'EXPORTED_FUNCTIONS=["_one", "_two"]']).communicate()
self.btest('browser_main.cpp', args=['-O2', '-s', 'MAIN_MODULE=1', '-s', 'DLOPEN_SUPPORT=1'], expected='8')
@@ -1717,3 +1720,47 @@ keydown(100);keyup(100); // trigger the end
assert 'argv[3]: 3' in stdout
assert 'hello, world!' in stdout
assert 'hello, error stream!' in stderr
+
+ def test_uuid(self):
+ # Run with ./runner.py browser.test_uuid
+ # We run this test in Node/SPIDERMONKEY and browser environments because we try to make use of
+ # high quality crypto random number generators such as crypto.getRandomValues or randomBytes (if available).
+
+ # First run tests in Node and/or SPIDERMONKEY using run_js. Use closure compiler so we can check that
+ # require('crypto').randomBytes and window.crypto.getRandomValues doesn't get minified out.
+ Popen([PYTHON, EMCC, '-O2', '--closure', '1', path_from_root('tests', 'uuid', 'test.c'), '-o', path_from_root('tests', 'uuid', 'test.js')], stdout=PIPE, stderr=PIPE).communicate()
+
+ test_js_closure = open(path_from_root('tests', 'uuid', 'test.js')).read()
+
+ # Check that test.js compiled with --closure 1 contains ").randomBytes" and "window.crypto.getRandomValues"
+ assert ").randomBytes" in test_js_closure
+ assert "window.crypto.getRandomValues" in test_js_closure
+
+ out = run_js(path_from_root('tests', 'uuid', 'test.js'), full_output=True)
+ print out
+
+ # Tidy up files that might have been created by this test.
+ try_delete(path_from_root('tests', 'uuid', 'test.js'))
+ try_delete(path_from_root('tests', 'uuid', 'test.js.map'))
+
+ # Now run test in browser
+ self.btest(path_from_root('tests', 'uuid', 'test.c'), '1')
+
+ def test_glew(self):
+ self.btest(path_from_root('tests', 'glew.c'), expected='1')
+ self.btest(path_from_root('tests', 'glew.c'), args=['-s', 'LEGACY_GL_EMULATION=1'], expected='1')
+ self.btest(path_from_root('tests', 'glew.c'), args=['-DGLEW_MX'], expected='1')
+ self.btest(path_from_root('tests', 'glew.c'), args=['-s', 'LEGACY_GL_EMULATION=1', '-DGLEW_MX'], expected='1')
+
+ def test_doublestart_bug(self):
+ open('pre.js', 'w').write(r'''
+if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
+if (!Module['preRun']) Module['preRun'] = [];
+Module["preRun"].push(function () {
+ Module['addRunDependency']('test_run_dependency');
+ Module['removeRunDependency']('test_run_dependency');
+});
+''')
+
+ self.btest('doublestart.c', args=['--pre-js', 'pre.js', '-o', 'test.html'], expected='1')
+
diff --git a/tests/test_core.py b/tests/test_core.py
index c149281b..6c483069 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -477,6 +477,14 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
self.do_run_from_file(src, output)
+ def test_literal_negative_zero(self):
+ if self.emcc_args == None: return self.skip('needs emcc')
+
+ test_path = path_from_root('tests', 'core', 'test_literal_negative_zero')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
+
def test_llvm_intrinsics(self):
if self.emcc_args == None: return self.skip('needs ta2')
@@ -502,6 +510,7 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_cube2md5(self):
if self.emcc_args == None: return self.skip('needs emcc')
+ if not self.is_le32(): return self.skip('le32 needed for accurate math')
self.emcc_args += ['--embed-file', 'cube2md5.txt']
shutil.copyfile(path_from_root('tests', 'cube2md5.txt'), os.path.join(self.get_dir(), 'cube2md5.txt'))
self.do_run(open(path_from_root('tests', 'cube2md5.cpp')).read(), open(path_from_root('tests', 'cube2md5.ok')).read())
@@ -829,6 +838,15 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
expected = open(path_from_root('tests', 'hyperbolic', 'output.txt'), 'r').read()
self.do_run(src, expected)
+ def test_math_lgamma(self):
+ if self.emcc_args is None: return self.skip('requires emcc')
+ if not self.is_le32(): return self.skip('le32 needed for accurate math')
+
+ test_path = path_from_root('tests', 'math', 'lgamma')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
+
def test_frexp(self):
test_path = path_from_root('tests', 'core', 'test_frexp')
src, output = (test_path + s for s in ('.in', '.out'))
@@ -937,6 +955,8 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
for named in (0, 1):
print named
+ if os.environ.get('EMCC_FAST_COMPILER') == '1' and named: continue # no named globals in fastcomp
+
Settings.NAMED_GLOBALS = named
self.do_run_from_file(src, output, ['wowie', 'too', '74'])
@@ -1184,7 +1204,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_exceptions(self):
if Settings.QUANTUM_SIZE == 1: return self.skip("we don't support libcxx in q1")
if self.emcc_args is None: return self.skip('need emcc to add in libcxx properly')
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.EXCEPTION_DEBUG = 1
@@ -1273,7 +1292,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_exception_2(self):
if self.emcc_args is None: return self.skip('need emcc to add in libcxx properly')
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.DISABLE_EXCEPTION_CATCHING = 0
test_path = path_from_root('tests', 'core', 'test_exception_2')
@@ -1281,6 +1299,7 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
self.do_run_from_file(src, output)
+
def test_white_list_exception(self):
if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
@@ -1298,7 +1317,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_uncaught_exception(self):
if self.emcc_args is None: return self.skip('no libcxx inclusion without emcc')
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.DISABLE_EXCEPTION_CATCHING = 0
@@ -1337,8 +1355,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
self.do_run(src, 'success')
def test_typed_exceptions(self):
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
-
Settings.DISABLE_EXCEPTION_CATCHING = 0
Settings.SAFE_HEAP = 0 # Throwing null will cause an ignorable null pointer access.
src = open(path_from_root('tests', 'exceptions', 'typed.cpp'), 'r').read()
@@ -1357,7 +1373,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_std_exception(self):
if self.emcc_args is None: return self.skip('requires emcc')
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.DISABLE_EXCEPTION_CATCHING = 0
self.emcc_args += ['-s', 'SAFE_HEAP=0']
@@ -1367,8 +1382,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
self.do_run_from_file(src, output)
def test_async_exit(self):
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
-
open('main.c', 'w').write(r'''
#include <stdio.h>
#include <stdlib.h>
@@ -3542,6 +3555,7 @@ ok
def test_strtod(self):
if self.emcc_args is None: return self.skip('needs emcc for libc')
+ if not self.is_le32(): return self.skip('le32 needed for accurate math')
src = r'''
#include <stdio.h>
@@ -3571,6 +3585,8 @@ ok
printf("%g\n", strtod("123e-50", &endptr));
printf("%g\n", strtod("123e-250", &endptr));
printf("%g\n", strtod("123e-450", &endptr));
+ printf("%g\n", strtod("0x6", &endptr));
+ printf("%g\n", strtod("-0x0p+0", &endptr));
char str[] = " 12.34e56end";
printf("%g\n", strtod(str, &endptr));
@@ -3603,6 +3619,8 @@ ok
1.23e-48
1.23e-248
0
+ 6
+ -0
1.234e+57
10
inf
@@ -3687,6 +3705,7 @@ ok
def test_sscanf(self):
if self.emcc_args is None: return self.skip('needs emcc for libc')
+ if not self.is_le32(): return self.skip('le32 needed for accurate math')
test_path = path_from_root('tests', 'core', 'test_sscanf')
src, output = (test_path + s for s in ('.in', '.out'))
@@ -4071,6 +4090,12 @@ def process(filename):
self.do_run(open(path_from_root('tests', 'utf32.cpp')).read(), 'OK.')
self.do_run(open(path_from_root('tests', 'utf32.cpp')).read(), 'OK.', args=['-fshort-wchar'])
+ def test_wprintf(self):
+ if self.emcc_args is None: return self.skip('requires libcxx')
+ test_path = path_from_root('tests', 'core', 'test_wprintf')
+ src, output = (test_path + s for s in ('.c', '.out'))
+ self.do_run_from_file(src, output)
+
def test_direct_string_constant_usage(self):
if self.emcc_args is None: return self.skip('requires libcxx')
@@ -4602,7 +4627,6 @@ return malloc(size);
def test_simd(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2')
if Settings.ASM_JS: Settings.ASM_JS = 2 # does not validate
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
test_path = path_from_root('tests', 'core', 'test_simd')
src, output = (test_path + s for s in ('.in', '.out'))
@@ -4611,7 +4635,6 @@ return malloc(size);
def test_simd2(self):
if Settings.ASM_JS: Settings.ASM_JS = 2 # does not validate
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
test_path = path_from_root('tests', 'core', 'test_simd2')
src, output = (test_path + s for s in ('.in', '.out'))
@@ -4619,9 +4642,10 @@ return malloc(size);
self.do_run_from_file(src, output)
def test_simd3(self):
+ return self.skip('FIXME: this appears to be broken')
+
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2')
if Settings.ASM_JS: Settings.ASM_JS = 2 # does not validate
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
test_path = path_from_root('tests', 'core', 'test_simd3')
src, output = (test_path + s for s in ('.in', '.out'))
@@ -4650,12 +4674,15 @@ return malloc(size);
if Settings.QUANTUM_SIZE == 1: return self.skip('TODO: make this work')
if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- self.do_run('',
- 'hello lua world!\n17\n1\n2\n3\n4\n7',
- args=['-e', '''print("hello lua world!");print(17);for x = 1,4 do print(x) end;print(10-3)'''],
- libraries=self.get_library('lua', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None),
- includes=[path_from_root('tests', 'lua')],
- output_nicerizer=lambda string, err: (string + err).replace('\n\n', '\n').replace('\n\n', '\n'))
+ for aggro in ([0, 1] if Settings.ASM_JS and '-O2' in self.emcc_args else [0]):
+ print aggro
+ Settings.AGGRESSIVE_VARIABLE_ELIMINATION = aggro
+ self.do_run('',
+ 'hello lua world!\n17\n1\n2\n3\n4\n7',
+ args=['-e', '''print("hello lua world!");print(17);for x = 1,4 do print(x) end;print(10-3)'''],
+ libraries=self.get_library('lua', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None),
+ includes=[path_from_root('tests', 'lua')],
+ output_nicerizer=lambda string, err: (string + err).replace('\n\n', '\n').replace('\n\n', '\n'))
def get_freetype(self):
Settings.DEAD_FUNCTIONS += ['_inflateEnd', '_inflate', '_inflateReset', '_inflateInit2_']
@@ -5033,7 +5060,7 @@ def process(filename):
'2xi40', # pnacl limitations in ExpandGetElementPtr
'legalizer_ta2', '514_ta2', # pnacl limitation in not legalizing i104, i96, etc.
'longjmp_tiny', 'longjmp_tiny_invoke', 'longjmp_tiny_phi', 'longjmp_tiny_phi2', 'longjmp_tiny_invoke_phi', 'indirectbrphi', 'ptrtoint_blockaddr', 'quoted', # current fastcomp limitations FIXME
- 'sillyfuncast', 'sillyfuncast2', 'sillybitcast', 'atomicrmw_unaligned' # TODO XXX
+ 'sillyfuncast2', 'sillybitcast', 'atomicrmw_unaligned' # TODO XXX
]: continue
if '_ta2' in shortname and not Settings.USE_TYPED_ARRAYS == 2:
print self.skip('case "%s" only relevant for ta2' % shortname)
diff --git a/tests/test_other.py b/tests/test_other.py
index 4bdd889b..00c42418 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -197,7 +197,7 @@ Options that are modified or new in %s include:
#(['-O2', '-g4'], lambda generated: 'var b=0' not in generated and 'var b = 0' not in generated and 'function _main' in generated, 'same as -g3 for now'),
(['-s', 'INLINING_LIMIT=0'], lambda generated: 'function _dump' in generated, 'no inlining without opts'),
(['-O3', '-s', 'INLINING_LIMIT=0', '--closure', '0'], lambda generated: 'function _dump' not in generated, 'lto/inlining'),
- (['-Os', '--llvm-lto', '1', '-s', 'ASM_JS=0'], lambda generated: 'function _dump' in generated, '-Os disables inlining'),
+ (['-Os', '--llvm-lto', '1', '-s', 'ASM_JS=0', '-g2'], lambda generated: 'function _dump' in generated, '-Os disables inlining'),
(['-s', 'USE_TYPED_ARRAYS=0'], lambda generated: 'new Int32Array' not in generated, 'disable typed arrays'),
(['-s', 'USE_TYPED_ARRAYS=1'], lambda generated: 'IHEAPU = ' in generated, 'typed arrays 1 selected'),
([], lambda generated: 'Module["_dump"]' not in generated, 'dump is not exported by default'),
@@ -209,6 +209,7 @@ Options that are modified or new in %s include:
]:
print params, text
self.clear()
+ if os.environ.get('EMCC_FAST_COMPILER') == '1' and ['disable typed arrays', 'typed arrays 1 selected']: continue
output = Popen([PYTHON, compiler, path_from_root('tests', 'hello_world_loop.cpp'), '-o', 'a.out.js'] + params, stdout=PIPE, stderr=PIPE).communicate()
assert len(output[0]) == 0, output[0]
assert os.path.exists('a.out.js'), '\n'.join(output)
@@ -1735,6 +1736,8 @@ f.close()
['asm', 'outline']),
(path_from_root('tools', 'test-js-optimizer-asm-minlast.js'), open(path_from_root('tools', 'test-js-optimizer-asm-minlast-output.js')).read(),
['asm', 'minifyWhitespace', 'last']),
+ (path_from_root('tools', 'test-js-optimizer-shiftsAggressive.js'), open(path_from_root('tools', 'test-js-optimizer-shiftsAggressive-output.js')).read(),
+ ['asm', 'aggressiveVariableElimination']),
]:
print input
output = Popen(listify(NODE_JS) + [path_from_root('tools', 'js-optimizer.js'), input] + passes, stdin=PIPE, stdout=PIPE).communicate()[0]
@@ -2149,10 +2152,19 @@ int main()
self.assertContained('File size: 722', out)
def test_simd(self):
- if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+ if get_clang_version() == '3.2':
+ simd_args = ['-O3', '-vectorize', '-vectorize-loops']
+ elif get_clang_version() == '3.3':
+ simd_args = ['-O3', '-vectorize-loops', '-vectorize-slp-aggressive', '-bb-vectorize-aligned-only'] # XXX this generates <2 x float> , '-vectorize-slp']
+ elif get_clang_version() == '3.4':
+ simd_args = ['-O3'] # vectorization on by default, SIMD=1 makes us not disable it
+ else:
+ raise Exception('unknown llvm version')
+
+ simd_args += ['-bb-vectorize-vector-bits=128', '-force-vector-width=4']
self.clear()
- Popen([PYTHON, EMCC, path_from_root('tests', 'linpack.c'), '-O2', '-DSP', '--llvm-opts', '''['-O3', '-vectorize', '-vectorize-loops', '-bb-vectorize-vector-bits=128', '-force-vector-width=4']''']).communicate()
+ Popen([PYTHON, EMCC, path_from_root('tests', 'linpack.c'), '-O2', '-s', 'SIMD=1', '-DSP', '--llvm-opts', str(simd_args)]).communicate()
self.assertContained('Unrolled Single Precision', run_js('a.out.js'))
def test_dependency_file(self):
@@ -2208,3 +2220,36 @@ mergeInto(LibraryManager.library, {
process = Popen([PYTHON, EMCC, '-c', path_from_root('tests', 'hello_world.c'), '-o', outdir, '--default-obj-ext', 'obj'], stdout=PIPE, stderr=PIPE)
process.communicate()
assert(os.path.isfile(outdir + 'hello_world.obj'))
+
+
+ def test_doublestart_bug(self):
+ open('code.cpp', 'w').write(r'''
+#include <stdio.h>
+#include <emscripten.h>
+
+void main_loop(void) {
+ static int cnt = 0;
+ if (++cnt >= 10) emscripten_cancel_main_loop();
+}
+
+int main(void) {
+ printf("This should only appear once.\n");
+ emscripten_set_main_loop(main_loop, 10, 0);
+ return 0;
+}
+''')
+
+ open('pre.js', 'w').write(r'''
+if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
+if (!Module['preRun']) Module['preRun'] = [];
+Module["preRun"].push(function () {
+ Module['addRunDependency']('test_run_dependency');
+ Module['removeRunDependency']('test_run_dependency');
+});
+''')
+
+ Popen([PYTHON, EMCC, 'code.cpp', '--pre-js', 'pre.js']).communicate()
+ output = run_js(os.path.join(self.get_dir(), 'a.out.js'), engine=NODE_JS)
+
+ assert output.count('This should only appear once.') == 1, '\n'+output
+
diff --git a/tests/test_webgl_context_attributes_common.c b/tests/test_webgl_context_attributes_common.c
index 7131203b..80506b50 100644
--- a/tests/test_webgl_context_attributes_common.c
+++ b/tests/test_webgl_context_attributes_common.c
@@ -238,9 +238,9 @@ static void draw() {
}
-extern int webglAntialiasSupported();
-extern int webglDepthSupported();
-extern int webglStencilSupported();
+extern int webglAntialiasSupported(void);
+extern int webglDepthSupported(void);
+extern int webglStencilSupported(void);
// Check attributes support in the WebGL implementation (see test_webgl_context_attributes function in test_browser.py)
// Tests will succeed if they are not.
diff --git a/tests/uuid/test.c b/tests/uuid/test.c
new file mode 100644
index 00000000..dc2c6589
--- /dev/null
+++ b/tests/uuid/test.c
@@ -0,0 +1,69 @@
+#include <uuid/uuid.h>
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <emscripten.h>
+
+int isUUID(char* p, int upper) {
+ char* p1 = p;
+ do {
+ if (!(isxdigit(*p1) || (*p1 == '-')) || (upper && islower(*p1)) || (!upper && isupper(*p1))) {
+ return 0;
+ } else {
+ }
+ } while (*++p1 != 0);
+
+ if ((p[8] == '-') && (p[13] == '-') && (p[18] == '-') && (p[23] == '-')) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+int main() {
+ uuid_t uuid;
+ uuid_t uuid1;
+ uuid_t uuid2;
+ uuid_t empty_uuid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ uuid_generate(uuid);
+
+ assert(uuid_is_null(uuid) == 0);
+ assert(uuid_type(uuid) == UUID_TYPE_DCE_RANDOM);
+ assert(uuid_variant(uuid) == UUID_VARIANT_DCE);
+
+ char *generated = (char *)malloc(37*sizeof(char));
+ uuid_unparse(uuid, generated);
+ assert(isUUID(generated, 0) == 1); // Check it's a valid lower case UUID string.
+ printf("\nuuid = %s\n", generated);
+
+ assert(uuid_parse(generated, uuid1) == 0); // Check the generated UUID parses correctly into a compact UUID.
+ assert(uuid_compare(uuid1, uuid) == 0); // Compare the parsed UUID with the original.
+
+ uuid_unparse_lower(uuid, generated);
+ assert(isUUID(generated, 0) == 1); // Check it's a valid lower case UUID string.
+ printf("uuid = %s\n", generated);
+
+ uuid_unparse_upper(uuid, generated);
+ assert(isUUID(generated, 1) == 1); // Check it's a valid upper case UUID string.
+ printf("uuid = %s\n", generated);
+
+
+ uuid_copy(uuid2, uuid);
+ assert(uuid_compare(uuid2, uuid) == 0);
+
+ uuid_clear(uuid);
+ assert(uuid_compare(empty_uuid, uuid) == 0);
+
+ assert(uuid_is_null(uuid) == 1);
+
+ // The following lets the browser test exit cleanly.
+ int result = 1;
+ #if EMSCRIPTEN
+ #ifdef REPORT_RESULT
+ REPORT_RESULT();
+ #endif
+ #endif
+ exit(0);
+}
+