aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/selectadd.ll29
-rw-r--r--tests/sdl_canvas_palette.c2
-rw-r--r--tests/test_core.py2
-rw-r--r--tests/test_other.py43
-rw-r--r--tests/test_sockets.py26
5 files changed, 99 insertions, 3 deletions
diff --git a/tests/cases/selectadd.ll b/tests/cases/selectadd.ll
new file mode 100644
index 00000000..093032b8
--- /dev/null
+++ b/tests/cases/selectadd.ll
@@ -0,0 +1,29 @@
+
+; ModuleID = 'tests/hello_world.bc'
+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-S128"
+target triple = "i386-pc-linux-gnu"
+
+@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ br label %zero
+
+zero:
+ %.3.ph.i757 = phi i8* [ getelementptr ([15 x i8]* @.str, i32 0, i32 add (i32 xor (i32 ptrtoint (i8* getelementptr ([15 x i8]* @.str, i32 0, i32 select (i1 icmp ugt (i32 sub (i32 0, i32 add (i32 ptrtoint ([15 x i8]* @.str to i32), i32 25)), i32 xor (i32 ptrtoint ([15 x i8]* @.str to i32), i32 -1)), i32 sub (i32 0, i32 add (i32 ptrtoint ([15 x i8]* @.str to i32), i32 25)), i32 xor (i32 ptrtoint ([15 x i8]* @.str to i32), i32 -1))) to i32), i32 -1), i32 25)), %entry ], [ getelementptr ([15 x i8]* @.str, i32 0, i32 ptrtoint (i8* getelementptr ([15 x i8]* @.str, i32 0, i32 add (i32 sub (i32 0, i32 ptrtoint ([15 x i8]* @.str to i32)), i32 25)) to i32)), %other ]
+
+ %retval = alloca i32, align 4 ; [#uses=1 type=i32*]
+ store i32 0, i32* %retval
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
+ br label %other
+
+other:
+ br i1 0, label %zero, label %last
+
+last:
+ ret i32 1
+}
+
+declare i32 @printf(i8*, ...)
+
diff --git a/tests/sdl_canvas_palette.c b/tests/sdl_canvas_palette.c
index 316aa44a..361f71a6 100644
--- a/tests/sdl_canvas_palette.c
+++ b/tests/sdl_canvas_palette.c
@@ -42,7 +42,7 @@ int main() {
//changing green color
//to yellow
pal[1].r = 255;
- SDL_SetColors(screen, pal, 1, 1);
+ SDL_SetColors(screen, &pal[1], 1, 1);
{
SDL_Rect rect = { 300, 200, 300, 200 };
diff --git a/tests/test_core.py b/tests/test_core.py
index f3a106a2..53d16f9a 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -3844,7 +3844,6 @@ def process(filename):
self.do_run(open(path_from_root('tests', 'emscripten_get_now.cpp')).read(), 'Timer resolution is good.')
def test_inlinejs(self):
- if Settings.ASM_JS: Settings.ASM_JS = 2 # skip validation, asm does not support random code
if not self.is_le32(): return self.skip('le32 needed for inline js')
src = r'''
#include <stdio.h>
@@ -3872,7 +3871,6 @@ def process(filename):
self.do_run(src, 'Inline JS is very cool\n3.64\n') # TODO 1\n2\n3\n1\n2\n3\n')
def test_inlinejs2(self):
- if Settings.ASM_JS: Settings.ASM_JS = 2 # skip validation, asm does not support random code
if not self.is_le32(): return self.skip('le32 needed for inline js')
src = r'''
#include <stdio.h>
diff --git a/tests/test_other.py b/tests/test_other.py
index 86e0eadf..584f6714 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -2010,6 +2010,49 @@ a(int [32], char [5]*)
try_delete(path_from_root('tests', 'Module-exports', 'test.js'))
try_delete(path_from_root('tests', 'Module-exports', 'test.js.map'))
+ def test_fs_stream_proto(self):
+ open('src.cpp', 'w').write(r'''
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+
+int main()
+{
+ int file_size = 0;
+ int h = open("src.cpp", O_RDONLY, 0666);
+ if (0 != h)
+ {
+ FILE* file = fdopen(h, "rb");
+ if (0 != file)
+ {
+ fseek(file, 0, SEEK_END);
+ file_size = ftell(file);
+ fseek(file, 0, SEEK_SET);
+ }
+ else
+ {
+ printf("fdopen() failed: %s\n", strerror(errno));
+ return 10;
+ }
+ close(h);
+ printf("File size: %d\n", file_size);
+ }
+ else
+ {
+ printf("open() failed: %s\n", strerror(errno));
+ return 10;
+ }
+ return 0;
+}
+ ''')
+ Popen([PYTHON, EMCC, 'src.cpp', '--embed-file', 'src.cpp']).communicate()
+ for engine in JS_ENGINES:
+ out = run_js('a.out.js', engine=engine, stderr=PIPE, full_output=True)
+ self.assertContained('File size: 722', out)
+
def test_simd(self):
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()
diff --git a/tests/test_sockets.py b/tests/test_sockets.py
index d2bc46a2..e1caa150 100644
--- a/tests/test_sockets.py
+++ b/tests/test_sockets.py
@@ -400,3 +400,29 @@ class sockets(BrowserCore):
expected = '1'
self.run_browser(host_outfile, '.', ['/report_result?' + e for e in expected])
+ def test_nodejs_sockets_echo(self):
+ # This test checks that sockets work when the client code is run in Node.js
+ # Run with ./runner.py sockets.test_nodejs_sockets_echo
+ if not NODE_JS in JS_ENGINES:
+ return self.skip('node is not present')
+
+ sockets_include = '-I'+path_from_root('tests', 'sockets')
+
+ # Websockify-proxied servers can't run dgram tests
+ harnesses = [
+ # Websockify doesn't seem to like ws.WebSocket clients TODO check if this is a ws issue or Websockify issue
+ #(WebsockifyServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include], 49160), 0),
+ (CompiledServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include, '-DTEST_DGRAM=0'], 49161), 0),
+ (CompiledServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include, '-DTEST_DGRAM=1'], 49162), 1)
+ ]
+
+ for harness, datagram in harnesses:
+ with harness:
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sockets', 'test_sockets_echo_client.c'), '-o', path_from_root('tests', 'sockets', 'client.js'), '-DSOCKK=%d' % harness.listen_port, '-DREPORT_RESULT=int dummy'], stdout=PIPE, stderr=PIPE).communicate()
+
+ self.assertContained('do_msg_read: read 14 bytes', run_js(path_from_root('tests', 'sockets', 'client.js'), engine=NODE_JS))
+
+ # Tidy up files that might have been created by this test.
+ try_delete(path_from_root('tests', 'sockets', 'client.js'))
+ try_delete(path_from_root('tests', 'sockets', 'client.js.map'))
+