aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/entry2.ll32
-rw-r--r--tests/cases/entry2.txt2
-rw-r--r--tests/cases/floatreturningfuncptr.ll18
-rwxr-xr-xtests/runner.py119
4 files changed, 164 insertions, 7 deletions
diff --git a/tests/cases/entry2.ll b/tests/cases/entry2.ll
new file mode 100644
index 00000000..75b266c7
--- /dev/null
+++ b/tests/cases/entry2.ll
@@ -0,0 +1,32 @@
+; ModuleID = '/tmp/tmpKnA2D3/a.out.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 [11 x i8] c"getgid=%d\0A\00", align 1
+@.str1 = private unnamed_addr constant [6 x i8] c"f=%d\0A\00", align 1
+
+define internal i32 @_Z1fii(i32, i32) noinline {
+ %3 = tail call i32 @getgid()
+ %4 = icmp eq i32 %3, 0
+ br i1 %4, label %7, label %5
+
+; <label>:5 ; preds = %2
+ %6 = tail call i32 @getgid()
+ br label %7
+
+; <label>:7 ; preds = %5, %2
+ %.0 = phi i32 [ 0, %5 ], [ 1, %2 ]
+ ret i32 %.0
+}
+
+declare i32 @getgid()
+
+define i32 @main() {
+ %1 = tail call i32 @getgid()
+ %2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str, i32 0, i32 0), i32 %1)
+ %3 = tail call i32 @_Z1fii(i32 undef, i32 undef)
+ %4 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str1, i32 0, i32 0), i32 %3)
+ ret i32 0
+}
+
+declare i32 @printf(i8* nocapture, ...) nounwind
diff --git a/tests/cases/entry2.txt b/tests/cases/entry2.txt
new file mode 100644
index 00000000..37642b36
--- /dev/null
+++ b/tests/cases/entry2.txt
@@ -0,0 +1,2 @@
+getgid=0
+f=1
diff --git a/tests/cases/floatreturningfuncptr.ll b/tests/cases/floatreturningfuncptr.ll
new file mode 100644
index 00000000..e07e97b3
--- /dev/null
+++ b/tests/cases/floatreturningfuncptr.ll
@@ -0,0 +1,18 @@
+; 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:
+ %retval = alloca i32, align 4 ; [#uses=1 type=i32*]
+ store i32 0, i32* %retval
+ %call = call float (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
+ %call2 = call float (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), float %call) ; [#uses=0 type=i32]
+ ret i32 1
+}
+
+; [#uses=1]
+declare float @printf(i8*, ...)
diff --git a/tests/runner.py b/tests/runner.py
index 3cf20bc8..a3c74f03 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -2475,17 +2475,14 @@ Exception execution path of first function! 1
def test_exceptions(self):
if Settings.ASM_JS: return self.skip('no exceptions support in asm')
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')
Settings.EXCEPTION_DEBUG = 1
self.banned_js_engines = [NODE_JS] # node issue 1669, exception causes stdout not to be flushed
Settings.DISABLE_EXCEPTION_CATCHING = 0
- if self.emcc_args is None:
- if Building.LLVM_OPTS: return self.skip('optimizing bitcode before emcc can confuse libcxx inclusion')
- self.emcc_args = [] # libc++ auto-inclusion is only done if we use emcc
- else:
- if '-O2' in self.emcc_args:
- self.emcc_args += ['--closure', '1'] # Use closure here for some additional coverage
+ if '-O2' in self.emcc_args:
+ self.emcc_args += ['--closure', '1'] # Use closure here for some additional coverage
src = '''
#include <stdio.h>
@@ -6245,6 +6242,36 @@ def process(filename):
}
'''
self.do_run(src, "some string constant")
+
+ def test_std_cout_new(self):
+ if self.emcc_args is None: return self.skip('requires emcc')
+
+ src = '''
+ #include <iostream>
+
+ struct NodeInfo { //structure that we want to transmit to our shaders
+ float x;
+ float y;
+ float s;
+ float c;
+ };
+ const int nbNodes = 100;
+ NodeInfo * data = new NodeInfo[nbNodes]; //our data that will be transmitted using float texture.
+
+ template<int i>
+ void printText( const char (&text)[ i ] )
+ {
+ std::cout << text << std::endl;
+ }
+
+ int main()
+ {
+ printText( "some string constant" );
+ return 0;
+ }
+ '''
+
+ self.do_run(src, "some string constant")
def test_istream(self):
if self.emcc_args is None: return self.skip('requires libcxx')
@@ -10075,7 +10102,7 @@ f.close()
(1, 0, 3, 2), (1, 1, 3, 4)
]:
print asm, linkable, chunks, js_chunks
- output, err = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_libcxx.cpp'), '-O1', '-s', 'LINKABLE=%d' % linkable, '-s', 'ASM_JS=%d' % asm, '-s', 'UNRESOLVED_AS_DEAD=1'], stdout=PIPE, stderr=PIPE).communicate()
+ output, err = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_libcxx.cpp'), '-O1', '-s', 'LINKABLE=%d' % linkable, '-s', 'ASM_JS=%d' % asm, '-s', 'UNRESOLVED_AS_DEAD=1'] + (['-O2'] if asm else []), stdout=PIPE, stderr=PIPE).communicate()
ok = False
for c in range(chunks, chunks+2):
ok = ok or ('phase 2 working on %d chunks' % c in err)
@@ -11040,6 +11067,84 @@ elif 'browser' in str(sys.argv):
Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_mouse.c'), '-O2', '--minify', '0', '-o', 'page.html', '--pre-js', 'pre.js']).communicate()
self.run_browser('page.html', '', '/report_result?740')
+ def test_sdl_mouse_offsets(self):
+ open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('''
+ function simulateMouseEvent(x, y, button) {
+ var event = document.createEvent("MouseEvents");
+ if (button >= 0) {
+ var event1 = document.createEvent("MouseEvents");
+ event1.initMouseEvent('mousedown', true, true, window,
+ 1, x, y, x, y,
+ 0, 0, 0, 0,
+ button, null);
+ Module['canvas'].dispatchEvent(event1);
+ var event2 = document.createEvent("MouseEvents");
+ event2.initMouseEvent('mouseup', true, true, window,
+ 1, x, y, x, y,
+ 0, 0, 0, 0,
+ button, null);
+ Module['canvas'].dispatchEvent(event2);
+ } else {
+ var event1 = document.createEvent("MouseEvents");
+ event1.initMouseEvent('mousemove', true, true, window,
+ 0, x, y, x, y,
+ 0, 0, 0, 0,
+ 0, null);
+ Module['canvas'].dispatchEvent(event1);
+ }
+ }
+ window['simulateMouseEvent'] = simulateMouseEvent;
+ ''')
+ open(os.path.join(self.get_dir(), 'page.html'), 'w').write('''
+ <html>
+ <head>
+ <style type="text/css">
+ html, body { margin: 0; padding: 0; }
+ #container {
+ position: absolute;
+ left: 5px; right: 0;
+ top: 5px; bottom: 0;
+ }
+ #canvas {
+ position: absolute;
+ left: 0; width: 600px;
+ top: 0; height: 450px;
+ }
+ textarea {
+ margin-top: 500px;
+ margin-left: 5px;
+ width: 600px;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="container">
+ <canvas id="canvas"></canvas>
+ </div>
+ <textarea id="output" rows="8"></textarea>
+ <script type="text/javascript">
+ var Module = {
+ canvas: document.getElementById('canvas'),
+ print: (function() {
+ var element = document.getElementById('output');
+ element.value = ''; // clear browser cache
+ return function(text) {
+ text = Array.prototype.slice.call(arguments).join(' ');
+ element.value += text + "\\n";
+ element.scrollTop = 99999; // focus on bottom
+ };
+ })()
+ };
+ </script>
+ <script type="text/javascript" src="sdl_mouse.js"></script>
+ </body>
+ </html>
+ ''')
+ open(os.path.join(self.get_dir(), 'sdl_mouse.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_mouse.c')).read()))
+
+ Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_mouse.c'), '-O2', '--minify', '0', '-o', 'sdl_mouse.js', '--pre-js', 'pre.js']).communicate()
+ self.run_browser('page.html', '', '/report_result?600')
+
def test_sdl_audio(self):
shutil.copyfile(path_from_root('tests', 'sounds', 'alarmvictory_1.ogg'), os.path.join(self.get_dir(), 'sound.ogg'))
shutil.copyfile(path_from_root('tests', 'sounds', 'alarmcreatemiltaryfoot_1.wav'), os.path.join(self.get_dir(), 'sound2.wav'))