diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cases/legalizer_ta2.ll | 15 | ||||
-rw-r--r-- | tests/cases/legalizer_ta2.txt | 1 | ||||
-rw-r--r-- | tests/cases/unaligneddouble.ll | 24 | ||||
-rw-r--r-- | tests/openjpeg/CMakeLists.txt | 2 | ||||
-rwxr-xr-x | tests/runner.py | 177 |
5 files changed, 197 insertions, 22 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/openjpeg/CMakeLists.txt b/tests/openjpeg/CMakeLists.txt index 52150f5f..d8671fed 100644 --- a/tests/openjpeg/CMakeLists.txt +++ b/tests/openjpeg/CMakeLists.txt @@ -22,6 +22,8 @@ STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME) PROJECT(${OPENJPEG_NAMESPACE} C) +include(CMakeDetermineSystem) + # Do full dependency headers. INCLUDE_REGULAR_EXPRESSION("^.*$") diff --git a/tests/runner.py b/tests/runner.py index ea7a72f4..b8927332 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -260,11 +260,13 @@ process(sys.argv[1]) if self.library_cache is not None: if cache and self.library_cache.get(cache_name): print >> sys.stderr, '<load build from cache> ', - bc_file = os.path.join(output_dir, 'lib' + name + '.bc') - f = open(bc_file, 'wb') - f.write(self.library_cache[cache_name]) - f.close() - return bc_file + generated_libs = [] + for bc_file in self.library_cache[cache_name]: + f = open(bc_file, 'wb') + f.write(self.library_cache[cache_name][bc_file]) + f.close() + generated_libs.append(bc_file) + return generated_libs print >> sys.stderr, '<building and saving into cache> ', @@ -917,6 +919,46 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv): ''' self.do_run(src, '*1 2*') + def test_multiply_defined_symbols(self): + a1 = "int f() { return 1; }" + a1_name = os.path.join(self.get_dir(), 'a1.c') + open(a1_name, 'w').write(a1) + a2 = "void x() {}" + a2_name = os.path.join(self.get_dir(), 'a2.c') + open(a2_name, 'w').write(a2) + b1 = "int f() { return 2; }" + b1_name = os.path.join(self.get_dir(), 'b1.c') + open(b1_name, 'w').write(b1) + b2 = "void y() {}" + b2_name = os.path.join(self.get_dir(), 'b2.c') + open(b2_name, 'w').write(b2) + main = r''' + #include <stdio.h> + int f(); + int main() { + printf("result: %d\n", f()); + return 0; + } + ''' + main_name = os.path.join(self.get_dir(), 'main.c') + open(main_name, 'w').write(main) + + Building.emcc(a1_name) + Building.emcc(a2_name) + Building.emcc(b1_name) + Building.emcc(b2_name) + Building.emcc(main_name) + + liba_name = os.path.join(self.get_dir(), 'liba.a') + Building.emar('cr', liba_name, [a1_name + '.o', a2_name + '.o']) + libb_name = os.path.join(self.get_dir(), 'libb.a') + Building.emar('cr', libb_name, [b1_name + '.o', b2_name + '.o']) + + all_name = os.path.join(self.get_dir(), 'all.bc') + Building.link([main_name + '.o', liba_name, libb_name], all_name) + + self.do_ll_run(all_name, 'result: 1') + def test_if(self): src = ''' #include <stdio.h> @@ -1360,6 +1402,32 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv): Settings.DISABLE_EXCEPTION_CATCHING = 0 self.do_run(src, 'Throw...Construct...Catched...Destruct...Throw...Construct...Copy...Catched...Destruct...Destruct...') + def test_uncaught_exception(self): + Settings.EXCEPTION_DEBUG = 0 # Messes up expected output. + Settings.DISABLE_EXCEPTION_CATCHING = 0 + + src = r''' + #include <stdio.h> + #include <exception> + struct X { + ~X() { + printf("exception? %s\n", std::uncaught_exception() ? "yes" : "no"); + } + }; + int main() { + printf("exception? %s\n", std::uncaught_exception() ? "yes" : "no"); + try { + X x; + throw 1; + } catch(...) { + printf("exception? %s\n", std::uncaught_exception() ? "yes" : "no"); + } + printf("exception? %s\n", std::uncaught_exception() ? "yes" : "no"); + return 0; + } + ''' + self.do_run(src, 'exception? no\nexception? yes\nexception? no\nexception? no\n') + def test_typed_exceptions(self): return self.skip('TODO: fix this for llvm 3.0') @@ -3742,6 +3810,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 @@ -4298,7 +4388,7 @@ def process(filename): self.do_run(open(path_from_root('tests', 'freetype', 'main.c'), 'r').read(), open(path_from_root('tests', 'freetype', 'ref.txt'), 'r').read(), ['font.ttf', 'test!', '150', '120', '25'], - libraries=[self.get_freetype()], + libraries=self.get_freetype(), includes=[path_from_root('tests', 'freetype', 'include')], post_build=post) #build_ll_hook=self.do_autodebug) @@ -4339,7 +4429,7 @@ def process(filename): self.do_run(open(path_from_root('tests', 'zlib', 'example.c'), 'r').read(), open(path_from_root('tests', 'zlib', 'ref.txt'), 'r').read(), - libraries=[self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a'])], + libraries=self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a']), includes=[path_from_root('tests', 'zlib')], force_c=True) @@ -4356,10 +4446,10 @@ def process(filename): self.do_run(open(path_from_root('tests', 'bullet', 'Demos', 'HelloWorld', 'HelloWorld.cpp'), 'r').read(), [open(path_from_root('tests', 'bullet', 'output.txt'), 'r').read(), # different roundings open(path_from_root('tests', 'bullet', 'output2.txt'), 'r').read()], - libraries=[self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletCollision.a'), - os.path.join('src', '.libs', 'libBulletDynamics.a'), + libraries=self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletDynamics.a'), + os.path.join('src', '.libs', 'libBulletCollision.a'), os.path.join('src', '.libs', 'libLinearMath.a')], - configure_args=['--disable-demos','--disable-dependency-tracking'])], + configure_args=['--disable-demos','--disable-dependency-tracking']), includes=[path_from_root('tests', 'bullet', 'src')], js_engines=[SPIDERMONKEY_ENGINE]) # V8 issue 1407 @@ -4400,15 +4490,15 @@ def process(filename): freetype = self.get_freetype() poppler = self.get_library('poppler', - [os.path.join('poppler', '.libs', self.get_shared_library_name('libpoppler.so.13')), - os.path.join('utils', 'pdftoppm.o'), - os.path.join('utils', 'parseargs.o')], - configure_args=['--disable-libjpeg', '--disable-libpng', '--disable-poppler-qt', '--disable-poppler-qt4', '--disable-cms']) + [os.path.join('utils', 'pdftoppm.o'), + os.path.join('utils', 'parseargs.o'), + os.path.join('poppler', '.libs', 'libpoppler.a')], + configure_args=['--disable-libjpeg', '--disable-libpng', '--disable-poppler-qt', '--disable-poppler-qt4', '--disable-cms', '--disable-cairo-output', '--disable-abiword-output', '--enable-shared=no']) # Combine libraries combined = os.path.join(self.get_dir(), 'poppler-combined.bc') - Building.link([freetype, poppler], combined) + Building.link(poppler + freetype, combined) self.do_ll_run(combined, map(ord, open(path_from_root('tests', 'poppler', 'ref.ppm'), 'r').read()).__str__().replace(' ', ''), @@ -4442,11 +4532,11 @@ def process(filename): shutil.copy(path_from_root('tests', 'openjpeg', 'opj_config.h'), self.get_dir()) lib = self.get_library('openjpeg', - [os.path.join('bin', self.get_shared_library_name('libopenjpeg.so.1.4.0')), - os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/index.c.o'.split('/')), + [os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/index.c.o'.split('/')), os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/convert.c.o'.split('/')), os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/__/common/color.c.o'.split('/')), - os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/__/common/getopt.c.o'.split('/'))], + os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/__/common/getopt.c.o'.split('/')), + os.path.join('bin', self.get_shared_library_name('libopenjpeg.so.1.4.0'))], configure=['cmake', '.'], #configure_args=['--enable-tiff=no', '--enable-jp3d=no', '--enable-png=no'], make_args=[]) # no -j 2, since parallel builds can fail @@ -4490,7 +4580,7 @@ def process(filename): self.do_run(open(path_from_root('tests', 'openjpeg', 'codec', 'j2k_to_image.c'), 'r').read(), 'Successfully generated', # The real test for valid output is in image_compare '-i image.j2k -o image.raw'.split(' '), - libraries=[lib], + libraries=lib, includes=[path_from_root('tests', 'openjpeg', 'libopenjpeg'), path_from_root('tests', 'openjpeg', 'codec'), path_from_root('tests', 'openjpeg', 'common'), @@ -5552,9 +5642,9 @@ Options that are modified or new in %s include: # XXX find a way to test this: assert ('& 255' in generated or '&255' in generated) == (opt_level <= 2), 'corrections should be in opt <= 2' assert ('(__label__)' in generated) == (opt_level <= 1), 'relooping should be in opt >= 2' assert ('assert(STACKTOP < STACK_MAX' in generated) == (opt_level == 0), 'assertions should be in opt == 0' - assert 'var $i;' in generated or 'var $storemerge3;' in generated or 'var $storemerge4;' in generated or 'var $i_04;' in generated, 'micro opts should always be on' + assert 'var $i;' in generated or 'var $i_01;' in generated or 'var $storemerge3;' in generated or 'var $storemerge4;' in generated or 'var $i_04;' in generated, 'micro opts should always be on' if opt_level >= 1: - assert 'HEAP8[HEAP32[' in generated or 'HEAP8[$vla1 + $storemerge4 / 2 | 0]' in generated or 'HEAP8[$vla1 + ($storemerge4 / 2 | 0)]' in generated or 'HEAP8[$vla1 + $i_04 / 2 | 0]' in generated or 'HEAP8[$vla1 + ($i_04 / 2 | 0)]' in generated, 'eliminator should create compound expressions, and fewer one-time vars' + assert 'HEAP8[HEAP32[' in generated or 'HEAP8[$vla1 + $storemerge4 / 2 | 0]' in generated or 'HEAP8[$vla1 + ($storemerge4 / 2 | 0)]' in generated or 'HEAP8[$vla1 + $i_04 / 2 | 0]' in generated or 'HEAP8[$vla1 + ($i_04 / 2 | 0)]' in generated or 'HEAP8[$1 + $i_01 / 2 | 0]' in generated or 'HEAP8[$1 + ($i_01 / 2 | 0)]' in generated, 'eliminator should create compound expressions, and fewer one-time vars' assert ('_puts(' in generated) == (opt_level >= 1), 'with opt >= 1, llvm opts are run and they should optimize printf to puts' assert ('function _malloc(bytes) {' in generated) == (not has_malloc), 'If malloc is needed, it should be there, if not not' assert 'function _main() {' in generated, 'Should be unminified, including whitespace' @@ -5785,7 +5875,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 +6008,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> |