aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/legalizer_ta2.ll15
-rw-r--r--tests/cases/legalizer_ta2.txt1
-rw-r--r--tests/cases/unaligneddouble.ll24
-rwxr-xr-xtests/runner.py67
4 files changed, 106 insertions, 1 deletions
diff --git a/tests/cases/legalizer_ta2.ll b/tests/cases/legalizer_ta2.ll
index a877c683..67cd9feb 100644
--- a/tests/cases/legalizer_ta2.ll
+++ b/tests/cases/legalizer_ta2.ll
@@ -101,6 +101,21 @@ entry:
store i80 %loaded.short, i80* bitcast ([300 x i8]* @globaliz to i80*), align 4
call i32 (i8*)* @puts(i8* bitcast ([300 x i8]* @globaliz to i8*))
+; phi
+ %if = trunc i104 %ander to i1
+ %first = trunc i104 %xored to i88
+ br i1 %if, label %a17, label %a26
+
+a17:
+ %second = trunc i104 %loaded to i88
+ br label %a26
+
+a26:
+ %a27 = phi i88 [ %first, %entry ], [ %second, %a17 ]
+ store i104 0, i104* %bundled, align 4 ; wipe it out
+ store i88 %a27, i88* bitcast ([300 x i8]* @globaliz to i88*), align 4
+ call i32 (i8*)* @puts(i8* bitcast ([300 x i8]* @globaliz to i8*))
+
ret i32 1
}
diff --git a/tests/cases/legalizer_ta2.txt b/tests/cases/legalizer_ta2.txt
index e05a4816..e25076e6 100644
--- a/tests/cases/legalizer_ta2.txt
+++ b/tests/cases/legalizer_ta2.txt
@@ -15,3 +15,4 @@ hellon worod
hello, war`d
hello, wor-d
hello, wor
+hello, worl
diff --git a/tests/cases/unaligneddouble.ll b/tests/cases/unaligneddouble.ll
new file mode 100644
index 00000000..22b92741
--- /dev/null
+++ b/tests/cases/unaligneddouble.ll
@@ -0,0 +1,24 @@
+; 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*]
+ %doub = alloca double, align 4
+ store i32 0, i32* %retval
+ %0 = bitcast double* %doub to i32
+ %1 = uitofp i32 %0 to double
+ store double %1, double* %doub, align 1
+ store double %1, double* %doub, align 2
+ store double %1, double* %doub, align 4
+ store double %1, double* %doub, align 8
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
+ ret i32 1
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
diff --git a/tests/runner.py b/tests/runner.py
index e348d8d8..ae46634c 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -3742,6 +3742,28 @@ def process(filename):
}
'''
self.do_run(src, "some string constant")
+
+ def test_istream(self):
+ if self.emcc_args is None: return self.skip('requires libcxx')
+
+ src = '''
+ #include <string>
+ #include <sstream>
+ #include <iostream>
+
+ int main()
+ {
+ std::string mystring("1 2 3");
+ std::istringstream is(mystring);
+ int one, two, three;
+
+ is >> one >> two >> three;
+
+ printf( "%i %i %i", one, two, three );
+ }
+ '''
+ self.do_run(src, "1 2 3")
+
def test_fs_base(self):
Settings.INCLUDE_FULL_LIBRARY = 1
@@ -5785,7 +5807,7 @@ elif 'benchmark' in str(sys.argv):
Building.COMPILER_TEST_OPTS = []
TEST_REPS = 10
- TOTAL_TESTS = 8
+ TOTAL_TESTS = 9
tests_done = 0
total_times = map(lambda x: 0., range(TOTAL_TESTS))
@@ -5918,6 +5940,49 @@ elif 'benchmark' in str(sys.argv):
'''
self.do_benchmark(src, [], 'final: 720.')
+ def test_files(self):
+ src = r'''
+ #include<stdio.h>
+ #include<stdlib.h>
+ #include<assert.h>
+ #include <unistd.h>
+
+ int main() {
+ int N = 100;
+ int M = 1000;
+ int K = 1000;
+ unsigned char *k = (unsigned char*)malloc(K+1), *k2 = (unsigned char*)malloc(K+1);
+ for (int i = 0; i < K; i++) {
+ k[i] = (i % 250) + 1;
+ }
+ k[K] = 0;
+ char buf[100];
+ for (int i = 0; i < N; i++) {
+ sprintf(buf, "/dev/shm/file-%d.dat", i);
+ FILE *f = fopen(buf, "w");
+ for (int j = 0; j < M; j++) {
+ fwrite(k, 1, (j % K) + 1, f);
+ }
+ fclose(f);
+ }
+ for (int i = 0; i < N; i++) {
+ sprintf(buf, "/dev/shm/file-%d.dat", i);
+ FILE *f = fopen(buf, "r");
+ for (int j = 0; j < M; j++) {
+ fread(k2, 1, (j % K) + 1, f);
+ }
+ fclose(f);
+ for (int j = 0; j < K; j++) {
+ assert(k[j] == k2[j]);
+ }
+ unlink(buf);
+ }
+ printf("ok");
+ return 1;
+ }
+ '''
+ self.do_benchmark(src, [], 'ok')
+
def test_copy(self):
src = r'''
#include<stdio.h>