summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/analyzer.js2
-rw-r--r--src/library.js4
-rw-r--r--src/library_gl.js2
-rw-r--r--src/utility.js6
-rw-r--r--system/include/sys/sendfile.h16
-rw-r--r--tests/cases/structphiparam.ll36
-rw-r--r--tests/cases/structphiparam.txt1
-rw-r--r--tests/cube_explosion.c16
-rw-r--r--tests/cube_explosion.pngbin0 -> 164108 bytes
-rw-r--r--tests/cubegeom.c18
-rw-r--r--tests/cubegeom.pngbin0 -> 216158 bytes
-rw-r--r--tests/cubegeom_color.pngbin0 -> 83030 bytes
-rw-r--r--tests/cubegeom_color2.c16
-rw-r--r--tests/cubegeom_color2.pngbin0 -> 76128 bytes
-rw-r--r--tests/cubegeom_fog.c16
-rw-r--r--tests/cubegeom_fog.pngbin0 -> 46290 bytes
-rw-r--r--tests/cubegeom_glew.c17
-rw-r--r--tests/cubegeom_mt.c16
-rw-r--r--tests/cubegeom_mt.pngbin0 -> 262750 bytes
-rw-r--r--tests/cubegeom_normal.c16
-rw-r--r--tests/cubegeom_normal.pngbin0 -> 28315 bytes
-rw-r--r--tests/cubegeom_normal_dap.c17
-rw-r--r--tests/cubegeom_normal_dap_far.c16
-rw-r--r--tests/cubegeom_normal_dap_far_glda.c16
-rw-r--r--tests/cubegeom_normal_dap_far_glda.pngbin0 -> 13868 bytes
-rw-r--r--tests/cubegeom_normal_dap_far_glda_quad.c16
-rw-r--r--tests/cubegeom_normal_dap_far_glda_quad.pngbin0 -> 18005 bytes
-rw-r--r--tests/cubegeom_normal_dap_far_range.c16
-rw-r--r--tests/cubegeom_normal_dap_far_range.pngbin0 -> 28315 bytes
-rw-r--r--tests/cubegeom_pre.c17
-rw-r--r--tests/cubegeom_pre.pngbin0 -> 173408 bytes
-rw-r--r--tests/cubegeom_pre2.c16
-rw-r--r--tests/cubegeom_pre2.pngbin0 -> 173408 bytes
-rw-r--r--tests/cubegeom_pre2_vao.c16
-rw-r--r--tests/cubegeom_pre2_vao2.c16
-rw-r--r--tests/cubegeom_pre2_vao2.pngbin0 -> 2956 bytes
-rw-r--r--tests/cubegeom_pre3.c16
-rw-r--r--tests/cubegeom_pre_vao.c16
-rw-r--r--tests/cubegeom_pre_vao.pngbin0 -> 173408 bytes
-rw-r--r--tests/cubegeom_texturematrix.c16
-rw-r--r--tests/cubegeom_texturematrix.pngbin0 -> 47014 bytes
-rw-r--r--tests/dirent/test_readdir.c3
-rw-r--r--tests/fcntl-open/src.c3
-rw-r--r--tests/glbook/CH02_HelloTriangle.pngbin1009 -> 866 bytes
-rw-r--r--tests/glbook/CH08_SimpleVertexShader.pngbin1600 -> 1200 bytes
-rw-r--r--tests/glbook/CH09_SimpleTexture2D.pngbin1943 -> 713 bytes
-rw-r--r--tests/glbook/CH09_TextureCubemap.pngbin3209 -> 2325 bytes
-rw-r--r--tests/glbook/CH09_TextureWrap.pngbin1812 -> 894 bytes
-rw-r--r--tests/glbook/CH10_MultiTexture.pngbin59495 -> 46810 bytes
-rw-r--r--tests/glbook/CH13_ParticleSystem.pngbin4921 -> 4285 bytes
-rw-r--r--tests/htmltest.pngbin743 -> 730 bytes
-rwxr-xr-xtests/runner.py77
-rw-r--r--tests/sdl_gfx_primitives.pngbin2357 -> 2261 bytes
-rw-r--r--tests/sdl_maprgba.pngbin1875 -> 1862 bytes
-rw-r--r--tests/sdl_rotozoom.pngbin431921 -> 431168 bytes
-rw-r--r--tests/stat/test_chmod.c3
-rw-r--r--tests/stat/test_mknod.c3
-rw-r--r--tests/stat/test_stat.c3
-rw-r--r--tests/stdio/test_fgetc_ungetc.c7
-rw-r--r--tests/unistd/unlink.c3
-rw-r--r--tests/utime/test_utime.c3
-rw-r--r--tools/file_packager.py21
-rw-r--r--tools/js-optimizer.js27
-rw-r--r--tools/shared.py2
64 files changed, 162 insertions, 369 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index b1f0b585..1a752305 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -338,7 +338,7 @@ function analyzer(data, sidePass) {
if (subItem != item && (!(subItem.intertype in UNUNFOLDABLE) ||
(subItem.intertype == 'value' && isNumber(subItem.ident) && isIllegalType(subItem.type)))) {
if (item.intertype == 'phi') {
- assert(subItem.intertype == 'value' || subItem.intertype == 'structvalue', 'We can only unfold illegal constants in phis');
+ assert(subItem.intertype == 'value' || subItem.intertype == 'structvalue' || subItem.intertype in PARSABLE_LLVM_FUNCTIONS, 'We can only unfold some expressions in phis');
// we must handle this in the phi itself, if we unfold normally it will not be pushed back with the phi
} else {
var tempIdent = '$$etemp$' + (tempId++);
diff --git a/src/library.js b/src/library.js
index 7978e9cb..85d1d13f 100644
--- a/src/library.js
+++ b/src/library.js
@@ -7844,7 +7844,7 @@ LibraryManager.library = {
inet_pton__deps: ['__setErrNo', '$ERRNO_CODES', 'inet_addr'],
inet_pton: function(af, src, dst) {
// int af, const char *src, void *dst
- if ((af ^ {{{ cDefine("AF_INET") }}}) !== 0) { ___setErrNo(ERRNO_CODES.EAFNOSUPPORT); return -1; }
+ if ((af ^ {{{ cDefine('AF_INET') }}}) !== 0) { ___setErrNo(ERRNO_CODES.EAFNOSUPPORT); return -1; }
var ret = _inet_addr(src);
if (ret == -1 || isNaN(ret)) return 0;
setValue(dst, ret, 'i32');
@@ -7932,7 +7932,7 @@ LibraryManager.library = {
var aliasesBuf = _malloc(4);
setValue(aliasesBuf, 0, 'i8*');
setValue(ret+___hostent_struct_layout.h_aliases, aliasesBuf, 'i8**');
- setValue(ret+___hostent_struct_layout.h_addrtype, {{{ cDefine("AF_INET") }}}, 'i32');
+ setValue(ret+___hostent_struct_layout.h_addrtype, {{{ cDefine('AF_INET') }}}, 'i32');
setValue(ret+___hostent_struct_layout.h_length, 4, 'i32');
var addrListBuf = _malloc(12);
setValue(addrListBuf, addrListBuf+8, 'i32*');
diff --git a/src/library_gl.js b/src/library_gl.js
index 737db8cf..8c724245 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1323,7 +1323,7 @@ var LibraryGL = {
GLEmulation.fogColor = new Float32Array(4);
// Add some emulation workarounds
- Module.printErr('WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work');
+ Module.printErr('WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work. (If you do not want this, build with -s DISABLE_GL_EMULATION=1)');
#if GL_UNSAFE_OPTS == 0
Module.printErr('WARNING: using emscripten GL emulation unsafe opts. If weirdness happens, try -s GL_UNSAFE_OPTS=0');
#endif
diff --git a/src/utility.js b/src/utility.js
index 9cc8d3a3..7d122cef 100644
--- a/src/utility.js
+++ b/src/utility.js
@@ -312,6 +312,12 @@ function setUnion(x, y) {
return ret;
}
+function setSize(x) {
+ var ret = 0;
+ for (var xx in x) ret++;
+ return ret;
+}
+
function invertArray(x) {
var ret = {};
for (var i = 0; i < x.length; i++) {
diff --git a/system/include/sys/sendfile.h b/system/include/sys/sendfile.h
new file mode 100644
index 00000000..1f58f0dd
--- /dev/null
+++ b/system/include/sys/sendfile.h
@@ -0,0 +1,16 @@
+#ifndef _SYS_SENDFILE_H
+#define _SYS_SENDFILE_H
+
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/tests/cases/structphiparam.ll b/tests/cases/structphiparam.ll
new file mode 100644
index 00000000..117bdf77
--- /dev/null
+++ b/tests/cases/structphiparam.ll
@@ -0,0 +1,36 @@
+; ModuleID = '/dev/shm/tmp/src.cpp.o'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
+target triple = "i386-pc-linux-gnu"
+
+@.str = private unnamed_addr constant [15 x i8] c"hello, %d %d!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
+@_dispatchTable = internal global i64 0
+
+define i32 @doit(i32 %x, { i32, i32 } %y) {
+ %y0 = extractvalue { i32, i32 } %y, 0
+ %y1 = extractvalue { i32, i32 } %y, 1
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %y0, i32 %y1) ; [#uses=0 type=i32] [debug line = 5:13]
+ ret i32 0
+}
+
+define i32 @main(i32 %argc) {
+entry:
+ %retval = alloca i32, align 4 ; [#uses=1 type=i32*]
+ %myi64 = alloca i64, align 4
+ %comp = alloca { i32, i32 }, align 4 ; [#uses=1]
+ store i32 0, i32* %retval
+ %should = icmp ne i32 %argc, 1337
+ br i1 %should, label %cond.end, label %cond.null
+
+cond.null:
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi { i32, i32 } [ { i32 zext (i8 111 to i32), i32 6 }, %entry ], [ zeroinitializer, %cond.null ] ; [#uses=1]
+ store { i32, i32 } %cond, { i32, i32 }* %comp
+ %call = call i32 (i32, { i32, i32 })* @doit(i32 1, { i32, i32 } %cond) ;
+ ret i32 0 ; [debug line = 6:13]
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
+
diff --git a/tests/cases/structphiparam.txt b/tests/cases/structphiparam.txt
new file mode 100644
index 00000000..f5af49f1
--- /dev/null
+++ b/tests/cases/structphiparam.txt
@@ -0,0 +1 @@
+hello, 111 6!
diff --git a/tests/cube_explosion.c b/tests/cube_explosion.c
index 3f55b3c6..0c6eb674 100644
--- a/tests/cube_explosion.c
+++ b/tests/cube_explosion.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -230,8 +216,6 @@ int main(int argc, char *argv[])
glDeleteTextures(1, &texture);
assert(!glIsTexture(texture)); // but not anymore
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cube_explosion.png b/tests/cube_explosion.png
new file mode 100644
index 00000000..58a16f2b
--- /dev/null
+++ b/tests/cube_explosion.png
Binary files differ
diff --git a/tests/cubegeom.c b/tests/cubegeom.c
index 787b8373..949a1f9a 100644
--- a/tests/cubegeom.c
+++ b/tests/cubegeom.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
int temp; // testing
@@ -308,9 +294,7 @@ int main(int argc, char *argv[])
// END
SDL_GL_SwapBuffers();
-
- verify();
-
+
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom.png b/tests/cubegeom.png
new file mode 100644
index 00000000..1c6a7fd5
--- /dev/null
+++ b/tests/cubegeom.png
Binary files differ
diff --git a/tests/cubegeom_color.png b/tests/cubegeom_color.png
new file mode 100644
index 00000000..a1d15438
--- /dev/null
+++ b/tests/cubegeom_color.png
Binary files differ
diff --git a/tests/cubegeom_color2.c b/tests/cubegeom_color2.c
index 5294329d..76d71d00 100644
--- a/tests/cubegeom_color2.c
+++ b/tests/cubegeom_color2.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -287,8 +273,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_color2.png b/tests/cubegeom_color2.png
new file mode 100644
index 00000000..ee78eb63
--- /dev/null
+++ b/tests/cubegeom_color2.png
Binary files differ
diff --git a/tests/cubegeom_fog.c b/tests/cubegeom_fog.c
index 9c04a55d..cae6ca2d 100644
--- a/tests/cubegeom_fog.c
+++ b/tests/cubegeom_fog.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -295,8 +281,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_fog.png b/tests/cubegeom_fog.png
new file mode 100644
index 00000000..c88e5a14
--- /dev/null
+++ b/tests/cubegeom_fog.png
Binary files differ
diff --git a/tests/cubegeom_glew.c b/tests/cubegeom_glew.c
index 22ef5d74..a3d86a40 100644
--- a/tests/cubegeom_glew.c
+++ b/tests/cubegeom_glew.c
@@ -19,20 +19,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
int temp; // testing
@@ -297,8 +283,7 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
+
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_mt.c b/tests/cubegeom_mt.c
index 464de7cc..b4ad28a7 100644
--- a/tests/cubegeom_mt.c
+++ b/tests/cubegeom_mt.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -288,8 +274,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_mt.png b/tests/cubegeom_mt.png
new file mode 100644
index 00000000..47649cdc
--- /dev/null
+++ b/tests/cubegeom_mt.png
Binary files differ
diff --git a/tests/cubegeom_normal.c b/tests/cubegeom_normal.c
index d128fef2..02655edf 100644
--- a/tests/cubegeom_normal.c
+++ b/tests/cubegeom_normal.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -283,8 +269,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_normal.png b/tests/cubegeom_normal.png
new file mode 100644
index 00000000..7e3b35d1
--- /dev/null
+++ b/tests/cubegeom_normal.png
Binary files differ
diff --git a/tests/cubegeom_normal_dap.c b/tests/cubegeom_normal_dap.c
index f811c586..752911a8 100644
--- a/tests/cubegeom_normal_dap.c
+++ b/tests/cubegeom_normal_dap.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -279,8 +265,7 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
+
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_normal_dap_far.c b/tests/cubegeom_normal_dap_far.c
index f954b3c7..35a068d9 100644
--- a/tests/cubegeom_normal_dap_far.c
+++ b/tests/cubegeom_normal_dap_far.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -277,8 +263,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_normal_dap_far_glda.c b/tests/cubegeom_normal_dap_far_glda.c
index a4b4975b..849245b8 100644
--- a/tests/cubegeom_normal_dap_far_glda.c
+++ b/tests/cubegeom_normal_dap_far_glda.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -268,8 +254,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_normal_dap_far_glda.png b/tests/cubegeom_normal_dap_far_glda.png
new file mode 100644
index 00000000..815efeb9
--- /dev/null
+++ b/tests/cubegeom_normal_dap_far_glda.png
Binary files differ
diff --git a/tests/cubegeom_normal_dap_far_glda_quad.c b/tests/cubegeom_normal_dap_far_glda_quad.c
index aa6383b8..93c157a4 100644
--- a/tests/cubegeom_normal_dap_far_glda_quad.c
+++ b/tests/cubegeom_normal_dap_far_glda_quad.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -268,8 +254,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_normal_dap_far_glda_quad.png b/tests/cubegeom_normal_dap_far_glda_quad.png
new file mode 100644
index 00000000..8683b0ed
--- /dev/null
+++ b/tests/cubegeom_normal_dap_far_glda_quad.png
Binary files differ
diff --git a/tests/cubegeom_normal_dap_far_range.c b/tests/cubegeom_normal_dap_far_range.c
index eb54c22a..17691ce9 100644
--- a/tests/cubegeom_normal_dap_far_range.c
+++ b/tests/cubegeom_normal_dap_far_range.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -277,8 +263,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_normal_dap_far_range.png b/tests/cubegeom_normal_dap_far_range.png
new file mode 100644
index 00000000..7e3b35d1
--- /dev/null
+++ b/tests/cubegeom_normal_dap_far_range.png
Binary files differ
diff --git a/tests/cubegeom_pre.c b/tests/cubegeom_pre.c
index 8001a2b8..fb1a5e02 100644
--- a/tests/cubegeom_pre.c
+++ b/tests/cubegeom_pre.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -295,8 +281,7 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
+
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_pre.png b/tests/cubegeom_pre.png
new file mode 100644
index 00000000..0a8c95cb
--- /dev/null
+++ b/tests/cubegeom_pre.png
Binary files differ
diff --git a/tests/cubegeom_pre2.c b/tests/cubegeom_pre2.c
index ae8dcf9f..51961bf7 100644
--- a/tests/cubegeom_pre2.c
+++ b/tests/cubegeom_pre2.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -334,8 +320,6 @@ int main(int argc, char *argv[])
// END
SDL_GL_SwapBuffers();
-
- verify();
#if !EMSCRIPTEN
SDL_Delay(1500);
diff --git a/tests/cubegeom_pre2.png b/tests/cubegeom_pre2.png
new file mode 100644
index 00000000..0a8c95cb
--- /dev/null
+++ b/tests/cubegeom_pre2.png
Binary files differ
diff --git a/tests/cubegeom_pre2_vao.c b/tests/cubegeom_pre2_vao.c
index 98bedd54..cba262ff 100644
--- a/tests/cubegeom_pre2_vao.c
+++ b/tests/cubegeom_pre2_vao.c
@@ -33,20 +33,6 @@ PFNGLGENVERTEXARRAYSPROC glGenVertexArrays_ = NULL;
PFNGLBINDVERTEXARRAYPROC glBindVertexArray_ = NULL;
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays_ = NULL;
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -367,8 +353,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_pre2_vao2.c b/tests/cubegeom_pre2_vao2.c
index e3ab4d62..3784006c 100644
--- a/tests/cubegeom_pre2_vao2.c
+++ b/tests/cubegeom_pre2_vao2.c
@@ -33,20 +33,6 @@ PFNGLGENVERTEXARRAYSPROC glGenVertexArrays_ = NULL;
PFNGLBINDVERTEXARRAYPROC glBindVertexArray_ = NULL;
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays_ = NULL;
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -368,8 +354,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_pre2_vao2.png b/tests/cubegeom_pre2_vao2.png
new file mode 100644
index 00000000..1e18bcd9
--- /dev/null
+++ b/tests/cubegeom_pre2_vao2.png
Binary files differ
diff --git a/tests/cubegeom_pre3.c b/tests/cubegeom_pre3.c
index a1f811b6..4ba2a779 100644
--- a/tests/cubegeom_pre3.c
+++ b/tests/cubegeom_pre3.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -335,8 +321,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_pre_vao.c b/tests/cubegeom_pre_vao.c
index f1d35fb5..cae68cfc 100644
--- a/tests/cubegeom_pre_vao.c
+++ b/tests/cubegeom_pre_vao.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -321,8 +307,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_pre_vao.png b/tests/cubegeom_pre_vao.png
new file mode 100644
index 00000000..0a8c95cb
--- /dev/null
+++ b/tests/cubegeom_pre_vao.png
Binary files differ
diff --git a/tests/cubegeom_texturematrix.c b/tests/cubegeom_texturematrix.c
index 229bf2a8..99a4469e 100644
--- a/tests/cubegeom_texturematrix.c
+++ b/tests/cubegeom_texturematrix.c
@@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE.
#include <string.h>
#include <assert.h>
-void verify() {
- int width = 640, height = 480;
- unsigned char *data = (unsigned char*)malloc(width*height*4);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
- int sum = 0;
- for (int x = 0; x < width*height*4; x++) {
- if (x % 4 != 3) sum += x * data[x];
- }
-#if EMSCRIPTEN
- int result = sum;
- REPORT_RESULT();
-#endif
-}
-
int main(int argc, char *argv[])
{
SDL_Surface *screen;
@@ -300,8 +286,6 @@ int main(int argc, char *argv[])
SDL_GL_SwapBuffers();
- verify();
-
#if !EMSCRIPTEN
SDL_Delay(1500);
#endif
diff --git a/tests/cubegeom_texturematrix.png b/tests/cubegeom_texturematrix.png
new file mode 100644
index 00000000..9144b9e4
--- /dev/null
+++ b/tests/cubegeom_texturematrix.png
Binary files differ
diff --git a/tests/dirent/test_readdir.c b/tests/dirent/test_readdir.c
index 9f7b12e8..12f97b73 100644
--- a/tests/dirent/test_readdir.c
+++ b/tests/dirent/test_readdir.c
@@ -2,6 +2,7 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -129,4 +130,4 @@ int main() {
setup();
test();
return EXIT_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/tests/fcntl-open/src.c b/tests/fcntl-open/src.c
index bd52dd3f..fc5d5c76 100644
--- a/tests/fcntl-open/src.c
+++ b/tests/fcntl-open/src.c
@@ -1,6 +1,7 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -91,4 +92,4 @@ int main() {
setup();
test();
return EXIT_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/tests/glbook/CH02_HelloTriangle.png b/tests/glbook/CH02_HelloTriangle.png
index d6351e2a..7b8c176e 100644
--- a/tests/glbook/CH02_HelloTriangle.png
+++ b/tests/glbook/CH02_HelloTriangle.png
Binary files differ
diff --git a/tests/glbook/CH08_SimpleVertexShader.png b/tests/glbook/CH08_SimpleVertexShader.png
index 84b276fd..6711784d 100644
--- a/tests/glbook/CH08_SimpleVertexShader.png
+++ b/tests/glbook/CH08_SimpleVertexShader.png
Binary files differ
diff --git a/tests/glbook/CH09_SimpleTexture2D.png b/tests/glbook/CH09_SimpleTexture2D.png
index e33539e9..7cb01698 100644
--- a/tests/glbook/CH09_SimpleTexture2D.png
+++ b/tests/glbook/CH09_SimpleTexture2D.png
Binary files differ
diff --git a/tests/glbook/CH09_TextureCubemap.png b/tests/glbook/CH09_TextureCubemap.png
index b592b047..2ca61b63 100644
--- a/tests/glbook/CH09_TextureCubemap.png
+++ b/tests/glbook/CH09_TextureCubemap.png
Binary files differ
diff --git a/tests/glbook/CH09_TextureWrap.png b/tests/glbook/CH09_TextureWrap.png
index 3367e254..1fb5a319 100644
--- a/tests/glbook/CH09_TextureWrap.png
+++ b/tests/glbook/CH09_TextureWrap.png
Binary files differ
diff --git a/tests/glbook/CH10_MultiTexture.png b/tests/glbook/CH10_MultiTexture.png
index 8e006eb3..dc7a0ed6 100644
--- a/tests/glbook/CH10_MultiTexture.png
+++ b/tests/glbook/CH10_MultiTexture.png
Binary files differ
diff --git a/tests/glbook/CH13_ParticleSystem.png b/tests/glbook/CH13_ParticleSystem.png
index 4b69414f..e0e4b31b 100644
--- a/tests/glbook/CH13_ParticleSystem.png
+++ b/tests/glbook/CH13_ParticleSystem.png
Binary files differ
diff --git a/tests/htmltest.png b/tests/htmltest.png
index 980245ee..36e87dd8 100644
--- a/tests/htmltest.png
+++ b/tests/htmltest.png
Binary files differ
diff --git a/tests/runner.py b/tests/runner.py
index 9f037164..a0cef588 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -12090,7 +12090,7 @@ int main(int argc, char const *argv[])
open(os.path.join(self.get_dir(), 'test.file'), 'w').write('''ay file..............,,,,,,,,,,,,,,''')
open(os.path.join(self.get_dir(), 'stdin'), 'w').write('''inter-active''')
Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'files.cpp'), '-c']).communicate()
- Popen([PYTHON, path_from_root('tools', 'nativize_llvm.py'), os.path.join(self.get_dir(), 'files.o')]).communicate(input)[0]
+ Popen([PYTHON, path_from_root('tools', 'nativize_llvm.py'), os.path.join(self.get_dir(), 'files.o')], stdout=PIPE, stderr=PIPE).communicate(input)
output = Popen([os.path.join(self.get_dir(), 'files.o.run')], stdin=open(os.path.join(self.get_dir(), 'stdin')), stdout=PIPE, stderr=PIPE).communicate()
self.assertContained('''size: 37
data: 119,97,107,97,32,119,97,107,97,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35
@@ -12395,6 +12395,8 @@ elif 'browser' in str(sys.argv):
''' + code
def reftest(self, expected):
+ # make sure the pngs used here have no color correction, using e.g.
+ # pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB infile outfile
basename = os.path.basename(expected)
shutil.copyfile(expected, os.path.join(self.get_dir(), basename))
open(os.path.join(self.get_dir(), 'reftest.js'), 'w').write('''
@@ -12417,6 +12419,14 @@ elif 'browser' in str(sys.argv):
var actualUrl = Module.canvas.toDataURL();
var actualImage = new Image();
actualImage.onload = function() {
+ /*
+ document.body.appendChild(img); // for comparisons
+ var div = document.createElement('div');
+ div.innerHTML = '^=expected, v=actual';
+ document.body.appendChild(div);
+ document.body.appendChild(actualImage); // to grab it for creating the test reference
+ */
+
var actualCanvas = document.createElement('canvas');
actualCanvas.width = actualImage.width;
actualCanvas.height = actualImage.height;
@@ -12717,7 +12727,7 @@ Press any key to continue.'''
open(absolute_src_path2, 'w').write('''load me right before running the code please''')
def make_main(path):
- print path
+ print 'make main at', path
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r'''
#include <stdio.h>
#include <string.h>
@@ -12755,14 +12765,14 @@ Press any key to continue.'''
for test in test_cases:
(srcpath, dstpath) = test
+ print 'Testing', srcpath, dstpath
make_main(dstpath)
- print srcpath
Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', srcpath, '-o', 'page.html']).communicate()
self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1')
# By absolute path
- make_main(absolute_src_path)
+ make_main('somefile.txt') # absolute becomes relative
Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', absolute_src_path, '-o', 'page.html']).communicate()
self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1')
@@ -12822,7 +12832,7 @@ Press any key to continue.'''
# Should still work with -o subdir/..
- make_main(absolute_src_path)
+ make_main('somefile.txt') # absolute becomes relative
try:
os.mkdir(os.path.join(self.get_dir(), 'dirrey'))
except:
@@ -13237,20 +13247,20 @@ Press any key to continue.'''
def test_sdl_ogl(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('sdl_ogl.c', reference='screenshot-gray-purple.png',
+ self.btest('sdl_ogl.c', reference='screenshot-gray-purple.png', reference_slack=1,
args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png'],
message='You should see an image with gray at the top.')
def test_sdl_ogl_defaultmatrixmode(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('sdl_ogl_defaultMatrixMode.c', reference='screenshot-gray-purple.png',
+ self.btest('sdl_ogl_defaultMatrixMode.c', reference='screenshot-gray-purple.png', reference_slack=1,
args=['--minify', '0', '--preload-file', 'screenshot.png'],
message='You should see an image with gray at the top.')
def test_sdl_ogl_p(self):
# Immediate mode with pointers
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('sdl_ogl_p.c', reference='screenshot-gray.png',
+ self.btest('sdl_ogl_p.c', reference='screenshot-gray.png', reference_slack=1,
args=['--preload-file', 'screenshot.png'],
message='You should see an image with gray at the top.')
@@ -13280,7 +13290,7 @@ Press any key to continue.'''
def test_sdl_fog_linear(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('sdl_fog_linear.c', reference='screenshot-fog-linear.png',
+ self.btest('sdl_fog_linear.c', reference='screenshot-fog-linear.png', reference_slack=1,
args=['--preload-file', 'screenshot.png'],
message='You should see an image with fog.')
@@ -13583,12 +13593,12 @@ Press any key to continue.'''
def test_gl_ps(self):
# pointers and a shader
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png'])
+ self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png'], reference_slack=1)
def test_gl_ps_packed(self):
# packed data that needs to be strided
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('gl_ps_packed.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png'])
+ self.btest('gl_ps_packed.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png'], reference_slack=1)
def test_gl_ps_strides(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
@@ -13604,64 +13614,64 @@ Press any key to continue.'''
self.btest('gl_matrix_identity.c', expected=['-1882984448', '460451840'])
def test_cubegeom_pre(self):
- self.btest('cubegeom_pre.c', expected=['-1472804742', '-1626058463', '-2046234971'])
+ self.btest('cubegeom_pre.c', reference='cubegeom_pre.png')
def test_cubegeom_pre2(self):
- self.btest('cubegeom_pre2.c', expected=['-1472804742', '-1626058463', '-2046234971'], args=['-s', 'GL_DEBUG=1']) # some coverage for GL_DEBUG not breaking the build
+ self.btest('cubegeom_pre2.c', reference='cubegeom_pre2.png', args=['-s', 'GL_DEBUG=1']) # some coverage for GL_DEBUG not breaking the build
def test_cubegeom_pre3(self):
- self.btest('cubegeom_pre3.c', expected=['-1472804742', '-1626058463', '-2046234971'])
+ self.btest('cubegeom_pre3.c', reference='cubegeom_pre2.png')
def test_cubegeom(self):
- self.btest('cubegeom.c', args=['-O2', '-g'], expected=['188641320', '1522377227', '-1054007155', '-1111866053'])
+ self.btest('cubegeom.c', args=['-O2', '-g'], reference='cubegeom.png')
def test_cubegeom_glew(self):
- self.btest('cubegeom_glew.c', args=['-O2', '--closure', '1'], expected=['188641320', '1522377227', '-1054007155', '-1111866053'])
+ self.btest('cubegeom_glew.c', args=['-O2', '--closure', '1'], reference='cubegeom.png')
def test_cubegeom_color(self):
- self.btest('cubegeom_color.c', expected=['588472350', '-687660609', '-818120875'])
+ self.btest('cubegeom_color.c', reference='cubegeom_color.png')
def test_cubegeom_normal(self):
- self.btest('cubegeom_normal.c', expected=['752917084', '-251570256', '-291655550'])
+ self.btest('cubegeom_normal.c', reference='cubegeom_normal.png')
def test_cubegeom_normal_dap(self): # draw is given a direct pointer to clientside memory, no element array buffer
- self.btest('cubegeom_normal_dap.c', expected=['752917084', '-251570256', '-291655550'])
+ self.btest('cubegeom_normal_dap.c', reference='cubegeom_normal.png')
def test_cubegeom_normal_dap_far(self): # indices do nto start from 0
- self.btest('cubegeom_normal_dap_far.c', expected=['752917084', '-251570256', '-291655550'])
+ self.btest('cubegeom_normal_dap_far.c', reference='cubegeom_normal.png')
def test_cubegeom_normal_dap_far_range(self): # glDrawRangeElements
- self.btest('cubegeom_normal_dap_far_range.c', expected=['752917084', '-251570256', '-291655550'])
+ self.btest('cubegeom_normal_dap_far_range.c', reference='cubegeom_normal.png')
def test_cubegeom_normal_dap_far_glda(self): # use glDrawArrays
- self.btest('cubegeom_normal_dap_far_glda.c', expected=['-218745386', '-263951846', '-375182658'])
+ self.btest('cubegeom_normal_dap_far_glda.c', reference='cubegeom_normal_dap_far_glda.png')
def test_cubegeom_normal_dap_far_glda_quad(self): # with quad
- self.btest('cubegeom_normal_dap_far_glda_quad.c', expected=['1757386625', '-677777235', '-690699597'])
+ self.btest('cubegeom_normal_dap_far_glda_quad.c', reference='cubegeom_normal_dap_far_glda_quad.png')
def test_cubegeom_mt(self):
- self.btest('cubegeom_mt.c', expected=['-457159152', '910983047', '870576921']) # multitexture
+ self.btest('cubegeom_mt.c', reference='cubegeom_mt.png') # multitexture
def test_cubegeom_color2(self):
- self.btest('cubegeom_color2.c', expected=['1121999515', '-391668088', '-522128354'])
+ self.btest('cubegeom_color2.c', reference='cubegeom_color2.png')
def test_cubegeom_texturematrix(self):
- self.btest('cubegeom_texturematrix.c', expected=['1297500583', '-791216738', '-783804685'])
+ self.btest('cubegeom_texturematrix.c', reference='cubegeom_texturematrix.png')
def test_cubegeom_fog(self):
- self.btest('cubegeom_fog.c', expected=['1617140399', '-898782526', '-946179526'])
+ self.btest('cubegeom_fog.c', reference='cubegeom_fog.png')
def test_cubegeom_pre_vao(self):
- self.btest('cubegeom_pre_vao.c', expected=['-1472804742', '-1626058463', '-2046234971'])
+ self.btest('cubegeom_pre_vao.c', reference='cubegeom_pre_vao.png')
def test_cubegeom_pre2_vao(self):
- self.btest('cubegeom_pre2_vao.c', expected=['-1472804742', '-1626058463', '-2046234971'])
+ self.btest('cubegeom_pre2_vao.c', reference='cubegeom_pre_vao.png')
def test_cubegeom_pre2_vao2(self):
- self.btest('cubegeom_pre2_vao2.c', expected=['-790445118'])
+ self.btest('cubegeom_pre2_vao2.c', reference='cubegeom_pre2_vao2.png')
def test_cube_explosion(self):
- self.btest('cube_explosion.c', expected=['667220544', '-1543354600', '-1485258415'])
+ self.btest('cube_explosion.c', reference='cube_explosion.png')
def test_sdl_canvas_blank(self):
self.btest('sdl_canvas_blank.c', reference='sdl_canvas_blank.png')
@@ -13677,7 +13687,7 @@ Press any key to continue.'''
def test_sdl_rotozoom(self):
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.btest('sdl_rotozoom.c', reference='sdl_rotozoom.png', args=['--preload-file', 'screenshot.png'], reference_slack=3)
+ self.btest('sdl_rotozoom.c', reference='sdl_rotozoom.png', args=['--preload-file', 'screenshot.png'], reference_slack=5)
def test_sdl_gfx_primitives(self):
self.btest('sdl_gfx_primitives.c', reference='sdl_gfx_primitives.png', reference_slack=1)
@@ -14095,6 +14105,8 @@ elif 'benchmark' in str(sys.argv):
total_native_times = map(lambda x: 0., range(TOTAL_TESTS))
class benchmark(RunnerCore):
+ save_dir = True
+
def print_stats(self, times, native_times, last=False, reps=TEST_REPS):
if reps == 0:
print '(no reps)'
@@ -14950,6 +14962,7 @@ fi
assert not os.path.exists(EMCC_CACHE)
finally:
if old: os.environ['LLVM'] = old
+ else: del os.environ['LLVM']
try_delete(CANONICAL_TEMP_DIR)
diff --git a/tests/sdl_gfx_primitives.png b/tests/sdl_gfx_primitives.png
index 525b4f8f..706af9ae 100644
--- a/tests/sdl_gfx_primitives.png
+++ b/tests/sdl_gfx_primitives.png
Binary files differ
diff --git a/tests/sdl_maprgba.png b/tests/sdl_maprgba.png
index 4f64c7cd..caca4a8b 100644
--- a/tests/sdl_maprgba.png
+++ b/tests/sdl_maprgba.png
Binary files differ
diff --git a/tests/sdl_rotozoom.png b/tests/sdl_rotozoom.png
index 288dd303..5933754f 100644
--- a/tests/sdl_rotozoom.png
+++ b/tests/sdl_rotozoom.png
Binary files differ
diff --git a/tests/stat/test_chmod.c b/tests/stat/test_chmod.c
index 94e6c12b..bf0e2cbe 100644
--- a/tests/stat/test_chmod.c
+++ b/tests/stat/test_chmod.c
@@ -2,6 +2,7 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -150,4 +151,4 @@ int main() {
setup();
test();
return EXIT_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/tests/stat/test_mknod.c b/tests/stat/test_mknod.c
index 4cff57d9..2b8f650d 100644
--- a/tests/stat/test_mknod.c
+++ b/tests/stat/test_mknod.c
@@ -2,6 +2,7 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -93,4 +94,4 @@ int main() {
setup();
test();
return EXIT_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/tests/stat/test_stat.c b/tests/stat/test_stat.c
index 14e88370..2c2bf53d 100644
--- a/tests/stat/test_stat.c
+++ b/tests/stat/test_stat.c
@@ -2,6 +2,7 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -164,4 +165,4 @@ int main() {
setup();
test();
return EXIT_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/tests/stdio/test_fgetc_ungetc.c b/tests/stdio/test_fgetc_ungetc.c
index c69a3d1a..0eea4007 100644
--- a/tests/stdio/test_fgetc_ungetc.c
+++ b/tests/stdio/test_fgetc_ungetc.c
@@ -1,5 +1,6 @@
#include <assert.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -47,7 +48,9 @@ void test() {
ungetc('a', file);
err = fgetc(file);
assert(err == (int)'a');
- fread(buffer, sizeof(char), sizeof(buffer), file);
+ int r = fread(buffer, sizeof(char), sizeof(buffer), file);
+ assert(r == 3);
+ buffer[3] = 0;
assert(!strcmp(buffer, "bcd"));
// rewind and fseek should reset anything that's been
@@ -84,4 +87,4 @@ int main() {
setup();
test();
return EXIT_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/tests/unistd/unlink.c b/tests/unistd/unlink.c
index 87252da2..f0a8f4dd 100644
--- a/tests/unistd/unlink.c
+++ b/tests/unistd/unlink.c
@@ -1,6 +1,7 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -135,4 +136,4 @@ int main() {
setup();
test();
return EXIT_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/tests/utime/test_utime.c b/tests/utime/test_utime.c
index 1793f4a5..59e3e98a 100644
--- a/tests/utime/test_utime.c
+++ b/tests/utime/test_utime.c
@@ -1,5 +1,6 @@
#include <assert.h>
#include <errno.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -50,4 +51,4 @@ int main() {
setup();
test();
return EXIT_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/tools/file_packager.py b/tools/file_packager.py
index 0097c473..136da609 100644
--- a/tools/file_packager.py
+++ b/tools/file_packager.py
@@ -122,8 +122,6 @@ for arg in sys.argv[1:]:
srcpath, dstpath = arg.split('@') # User is specifying destination filename explicitly.
else:
srcpath = dstpath = arg # Use source path as destination path.
- if os.path.isabs(dstpath):
- print >> sys.stderr, 'Warning: Embedding an absolute file/directory name "' + dstpath + '" to the virtual filesystem. The file will be made available in the path "' + dstpath + '", and not in the root of the generated file system. Use the explicit syntax --preload-file srcpath@dstpath to specify the target location the absolute source path should be directed to.'
if os.path.isfile(srcpath) or os.path.isdir(srcpath):
data_files.append({ 'srcpath': srcpath, 'dstpath': dstpath, 'mode': mode })
else:
@@ -201,13 +199,18 @@ data_files = filter(lambda file_: not os.path.isdir(file_['srcpath']), data_file
# Absolutize paths, and check that they make sense
curr_abspath = os.path.abspath(os.getcwd())
for file_ in data_files:
- path = file_['dstpath']
- abspath = os.path.abspath(path)
- if DEBUG: print >> sys.stderr, path, abspath, curr_abspath
- if not abspath.startswith(curr_abspath):
- print >> sys.stderr, 'Error: Embedding "%s" which is below the current directory. This is invalid since the current directory becomes the root that the generated code will see' % path
- sys.exit(1)
- file_['dstpath'] = abspath[len(curr_abspath)+1:]
+ if file_['srcpath'] == file_['dstpath']:
+ # This file was not defined with src@dst, so we inferred the destination from the source. In that case,
+ # we require that the destination not be under the current location
+ path = file_['dstpath']
+ abspath = os.path.abspath(path)
+ if DEBUG: print >> sys.stderr, path, abspath, curr_abspath
+ if not abspath.startswith(curr_abspath):
+ print >> sys.stderr, 'Error: Embedding "%s" which is below the current directory. This is invalid since the current directory becomes the root that the generated code will see' % path
+ sys.exit(1)
+ file_['dstpath'] = abspath[len(curr_abspath)+1:]
+ if os.path.isabs(path):
+ print >> sys.stderr, 'Warning: Embedding an absolute file/directory name "' + path + '" to the virtual filesystem. The file will be made available in the relative path "' + file_['dstpath'] + '". You can use the explicit syntax --preload-file srcpath@dstpath to explicitly specify the target location the absolute source path should be directed to.'
for file_ in data_files:
file_['dstpath'] = file_['dstpath'].replace(os.path.sep, '/') # name in the filesystem, native and emulated
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 29b36cad..82942ce2 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -2817,7 +2817,7 @@ function relocate(ast) {
var other = node[3];
if (base === 0) return other;
if (other[0] == 'num') {
- other[1] += base;
+ other[1] = (other[1] + base)|0;
return other;
} else {
node[2] = ['num', base];
@@ -3106,7 +3106,7 @@ function outline(ast) {
// Reserve an extra two spots per possible outlining: one for control flow var, the other for control flow data
// The control variables are zeroed out when calling an outlined function, and after using
// the value after they return.
- asmData.maxOutlinings = Math.round(3*measureSize(func)/sizeToOutline);
+ asmData.maxOutlinings = Math.round(3*measureSize(func)/extraInfo.sizeToOutline);
asmData.totalStackSize = stackSize + (stack.length + 2*asmData.maxOutlinings)*8;
asmData.controlStackPos = function(i) { return stackSize + (stack.length + i)*8 };
asmData.controlDataStackPos = function(i) { return stackSize + (stack.length + i)*8 + 4 };
@@ -3210,9 +3210,17 @@ function outline(ast) {
var CONTROL_BREAK = 1, CONTROL_BREAK_LABEL = 2, CONTROL_CONTINUE = 3, CONTROL_CONTINUE_LABEL = 4, CONTROL_RETURN_VOID = 5, CONTROL_RETURN_INT = 6, CONTROL_RETURN_DOUBLE = 7;
- var sizeToOutline = extraInfo.sizeToOutline;
- var level = 0;
+ var sizeToOutline = null; // customized per function and as we make progress
+ function calculateThreshold(func) {
+ sizeToOutline = extraInfo.sizeToOutline;
+ var size = measureSize(func);
+ //var desiredChunks = Math.ceil(size/extraInfo.sizeToOutline);
+ ////sizeToOutline = Math.round((extraInfo.sizeToOutline + (2*size/desiredChunks))/3);
+ //sizeToOutline = Math.round(size/desiredChunks);
+ printErr('trying to reduce the size of ' + func[1] + ' which is ' + size + ' (>= ' + extraInfo.sizeToOutline + '), aim for ' + sizeToOutline);
+ }
+ var level = 0;
var outliningParents = {}; // function name => parent it was outlined from
function doOutline(func, asmData, stats, start, end) {
@@ -3225,13 +3233,13 @@ function outline(ast) {
// analyze variables, and find 'owned' variables - that only appear in the outlined code, and do not need any spill support
var codeInfo = analyzeCode(func, asmData, code);
var allCodeInfo = analyzeCode(func, asmData, func);
- //printErr(' do outline ' + [func[1], level, 'range:', start, end, 'of', stats.length, newIdent, measureSize(code), JSON.stringify(codeInfo.labels), JSON.stringify(codeInfo.breaks), JSON.stringify(codeInfo.continues)]);
var owned = { sp: 1 }; // sp is always owned, each has its own
keys(setUnion(codeInfo.reads, codeInfo.writes)).forEach(function(v) {
if (allCodeInfo.reads[v] === codeInfo.reads[v] && allCodeInfo.writes[v] === codeInfo.writes[v] && !(v in asmData.params)) {
owned[v] = 1;
}
});
+ printErr('attempting outline ' + [func[1], newIdent, 'overhead:', setSize(setSub(codeInfo.writes, owned)), setSize(setSub(codeInfo.reads, owned))]);
var reps = [];
// wipe out control variable
reps.push(['stat', makeAssign(makeStackAccess(ASM_INT, asmData.controlStackPos(outlineIndex)), ['num', 0])]);
@@ -3426,6 +3434,7 @@ function outline(ast) {
}
}
outliningParents[newIdent] = func[1];
+ calculateThreshold(func);
return [newFunc];
}
@@ -3452,7 +3461,7 @@ function outline(ast) {
}
while (1) {
i--;
- calcMinIndex();
+ calcMinIndex(); // TODO: optimize
if (i < minIndex) {
// we might be done. but, if we have just outlined, do a further attempt from the beginning.
// (but only if the total costs are not extravagant)
@@ -3536,7 +3545,7 @@ function outline(ast) {
var newFuncs = doOutline(func, asmData, stats, i, end); // outline [i, .. ,end] inclusive
if (newFuncs.length) {
ret.push.apply(ret, newFuncs);
- printErr('performed outline on ' + func[1] + ' of ' + sizeSeen + ', func is now size ' + measureSize(func) + ' ==> ' + newFuncs[0][1]);
+ printErr('performed outline on ' + func[1] + ' of ' + sizeSeen + ', => ' + newFuncs[0][1]);
}
sizeSeen = 0;
end = i-1;
@@ -3566,10 +3575,10 @@ function outline(ast) {
funcs.forEach(function(func) {
var asmData = normalizeAsm(func);
var size = measureSize(func);
- if (size >= sizeToOutline) {
- printErr('trying to reduce the size of ' + func[1] + ' which is ' + size + ' (>= ' + sizeToOutline + ')');
+ if (size >= extraInfo.sizeToOutline) {
aggressiveVariableElimination(func, asmData);
flatten(func, asmData);
+ calculateThreshold(func);
analyzeFunction(func, asmData);
var stats = getStatements(func);
var ret = outlineStatements(func, asmData, stats, 0.9*size);
diff --git a/tools/shared.py b/tools/shared.py
index 250c018d..c0df227d 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -599,7 +599,7 @@ def line_splitter(data):
return out
-def limit_size(string, MAX=80*20):
+def limit_size(string, MAX=120*20):
if len(string) < MAX: return string
return string[0:MAX/2] + '\n[..]\n' + string[-MAX/2:]