aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/inttoptr.ll20
-rw-r--r--tests/hello_world.ll17
-rw-r--r--tests/hello_world_sdl.cpp4
-rw-r--r--tests/poppler/fontconfig/fontconfig.h (renamed from tests/poppler/include/fontconfig/fontconfig.h)0
-rw-r--r--tests/runner.py45
5 files changed, 65 insertions, 21 deletions
diff --git a/tests/cases/inttoptr.ll b/tests/cases/inttoptr.ll
new file mode 100644
index 00000000..c70904c8
--- /dev/null
+++ b/tests/cases/inttoptr.ll
@@ -0,0 +1,20 @@
+; ModuleID = '/tmp/emscripten/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 constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1]
+
+; [#uses=1]
+declare i32 @puts(i8*)
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %retval = alloca i32 ; [#uses=2]
+ %0 = alloca i32 ; [#uses=2]
+ %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
+ %sz.i7 = inttoptr i32 64 to i32* ; [#uses=1 type=i32*]
+ store i32 184, i32* %sz.i7, align 8, !tbaa !1610
+ %0 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ ret i32 0
+}
diff --git a/tests/hello_world.ll b/tests/hello_world.ll
new file mode 100644
index 00000000..adeac7eb
--- /dev/null
+++ b/tests/hello_world.ll
@@ -0,0 +1,17 @@
+; 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 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/hello_world_sdl.cpp b/tests/hello_world_sdl.cpp
index f3fb8ae7..df69b055 100644
--- a/tests/hello_world_sdl.cpp
+++ b/tests/hello_world_sdl.cpp
@@ -8,7 +8,7 @@ int main() {
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *screen = SDL_SetVideoMode(256, 256, 32, SDL_SWSURFACE);
- SDL_LockSurface(screen);
+ if (SDL_MUSTLOCK(screen)) SDL_LockSurface(screen);
for (int i = 0; i < 256; i++) {
for (int j = 0; j < 256; j++) {
*((char*)screen->pixels + i*256*4 + j*4 + 0) = i;
@@ -17,7 +17,7 @@ int main() {
*((char*)screen->pixels + i*256*4 + j*4 + 3) = 255;
}
}
- SDL_UnlockSurface(screen);
+ if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
SDL_Flip(screen);
printf("you should see a colored cube.");
diff --git a/tests/poppler/include/fontconfig/fontconfig.h b/tests/poppler/fontconfig/fontconfig.h
index 4efa4507..4efa4507 100644
--- a/tests/poppler/include/fontconfig/fontconfig.h
+++ b/tests/poppler/fontconfig/fontconfig.h
diff --git a/tests/runner.py b/tests/runner.py
index 9224cb4b..e62e7681 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1964,8 +1964,8 @@ if 'benchmark' not in str(sys.argv):
main_name = os.path.join(self.get_dir(), 'main.cpp')
open(main_name, 'w').write(main)
- Building.emmaken(supp_name)
- Building.emmaken(main_name)
+ Building.emcc(supp_name)
+ Building.emcc(main_name)
all_name = os.path.join(self.get_dir(), 'all.bc')
Building.link([supp_name + '.o', main_name + '.o'], all_name)
@@ -3482,12 +3482,12 @@ at function.:blag
int main()
{
- std::cout << "hello world";
+ std::cout << "hello world" << std::endl << 77 << "." << std::endl;
return 0;
}
'''
- self.do_run(src, 'hello world')
+ self.do_run(src, 'hello world\n77.\n')
def test_stdvec(self):
src = '''
@@ -3564,9 +3564,9 @@ at function.:blag
# emcc should build in dlmalloc automatically, and do all the sign correction etc. for it
try_delete(os.path.join(self.get_dir(), 'src.cpp.o.js'))
- # XXX find out why we fail without TOTAL_MEMORY here. that should not happen!
- output = Popen([EMCC, '-g', '-s', 'TOTAL_MEMORY=104857600', path_from_root('tests', 'dlmalloc_test.c'),
+ output = Popen([EMCC, path_from_root('tests', 'dlmalloc_test.c'),
'-o', os.path.join(self.get_dir(), 'src.cpp.o.js')], stdout=PIPE, stderr=PIPE).communicate()
+ #print output
self.do_run('x', '*1,0*', ['200', '1'], no_build=True)
self.do_run('x', '*400,0*', ['400', '400'], no_build=True)
@@ -3782,7 +3782,7 @@ at function.:blag
freetype = self.get_freetype()
poppler = self.get_library('poppler',
- [os.path.join('poppler', '.libs', 'libpoppler.so.13.0.0.bc'),
+ [os.path.join('poppler', '.libs', 'libpoppler.so.13.0.0'),
os.path.join('goo', '.libs', 'libgoo.a.bc'),
os.path.join('fofi', '.libs', 'libfofi.a.bc'),
os.path.join('splash', '.libs', 'libsplash.a.bc'),
@@ -3825,7 +3825,7 @@ at function.:blag
shutil.copy(path_from_root('tests', 'openjpeg', 'opj_config.h'), self.get_dir())
lib = self.get_library('openjpeg',
- [os.path.join('bin', 'libopenjpeg.so.1.4.0.bc'),
+ [os.path.join('bin', '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/convert.c.o'.split('/')),
os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/__/common/color.c.o'.split('/')),
@@ -4484,8 +4484,8 @@ Child2:9
main_name = os.path.join(self.get_dir(), 'main.cpp')
open(main_name, 'w').write(main)
- Building.emmaken(module_name, ['-g'])
- Building.emmaken(main_name, ['-g'])
+ Building.emcc(module_name, ['-g'])
+ Building.emcc(main_name, ['-g'])
all_name = os.path.join(self.get_dir(), 'all.bc')
Building.link([module_name + '.o', main_name + '.o'], all_name)
@@ -4889,11 +4889,6 @@ TT = %s
del T # T is just a shape for the specific subclasses, we don't test it itself
class other(RunnerCore):
- def test_reminder(self):
- raise Exception('''Fix emmaken.py and emconfiguren.py, they should work but mention they are deprecated
- Test emconfigure
- configure in test_zlib looks broken''')
-
def test_emcc(self):
def clear():
for name in os.listdir(self.get_dir()):
@@ -4939,6 +4934,13 @@ Options that are modified or new in %s include:
assert os.path.exists(target), 'Expected %s to exist since args are %s : %s' % (target, str(args), '\n'.join(output))
self.assertContained('hello, world!', self.run_llvm_interpreter([target]))
+ # emcc src.ll ==> generates .js
+ clear()
+ output = Popen([compiler, path_from_root('tests', 'hello_world.ll')], stdout=PIPE, stderr=PIPE).communicate()
+ assert len(output[0]) == 0, output[0]
+ assert os.path.exists('a.out.js'), '\n'.join(output)
+ self.assertContained('hello, world!', run_js('a.out.js'))
+
# dlmalloc. dlmalloc is special in that it is the only part of libc that is (1) hard to write well, and
# very speed-sensitive. So we do not implement it in JS in library.js, instead we compile it from source
for source, has_malloc in [('hello_world' + suffix, False), ('hello_malloc.cpp', True)]:
@@ -5057,12 +5059,11 @@ Options that are modified or new in %s include:
assert os.path.exists('combined.bc'), '\n'.join(output)
self.assertContained('side got: hello from main, over', self.run_llvm_interpreter(['combined.bc']))
- # TODO: compile .ll inputs to emcc into .bc
# TODO: test normal project linking, static and dynamic: get_library should not need to be told what to link!
# TODO: when ready, switch tools/shared building to use emcc over emmaken
# TODO: when this is done, more test runner to test these (i.e., test all -Ox thoroughly)
# TODO: emscripten tutorial with emcc
- # TODO: deprecate llvm optimizations etc. in emscripten.py.
+ # TODO: deprecate llvm optimizations, dlmalloc, etc. in emscripten.py.
# Finally, do some web browser tests
def run_browser(html_file, message):
@@ -5147,8 +5148,14 @@ else:
Building.COMPILER = CLANG
- # Pick the JS engine to benchmark
- JS_ENGINE = JS_ENGINES[1]
+ # Pick the JS engine to benchmark. If you specify one, it will be picked. For example, python tests/runner.py benchmark SPIDERMONKEY_ENGINE
+ JS_ENGINE = JS_ENGINES[0]
+ for i in range(1, len(sys.argv)):
+ arg = sys.argv[i]
+ if not arg.startswith('test_'):
+ JS_ENGINE = eval(arg)
+ sys.argv[i] = None
+ sys.argv = filter(lambda arg: arg is not None, sys.argv)
print 'Benchmarking JS engine:', JS_ENGINE
Building.COMPILER_TEST_OPTS = []