diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cases/sillyfuncast.ll | 23 | ||||
-rw-r--r-- | tests/cases/sillyfuncast2.ll | 21 | ||||
-rwxr-xr-x | tests/runner.py | 48 | ||||
-rw-r--r-- | tests/sdl_rotozoom.c | 3 | ||||
-rw-r--r-- | tests/sdl_rotozoom.png | bin | 437956 -> 431921 bytes |
5 files changed, 92 insertions, 3 deletions
diff --git a/tests/cases/sillyfuncast.ll b/tests/cases/sillyfuncast.ll new file mode 100644 index 00000000..36c26720 --- /dev/null +++ b/tests/cases/sillyfuncast.ll @@ -0,0 +1,23 @@ +; 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]*] + +define void @doit() { + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32] + ret void +} + +define i32 @main() { +entry: + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + store i32 0, i32* %retval + %58 = tail call i32 bitcast (void ()* @doit to i32 ()*)() nounwind + ret i32 1 +} + +declare i32 @printf(i8*, ...) + + + diff --git a/tests/cases/sillyfuncast2.ll b/tests/cases/sillyfuncast2.ll new file mode 100644 index 00000000..f72ebe28 --- /dev/null +++ b/tests/cases/sillyfuncast2.ll @@ -0,0 +1,21 @@ +; 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]*] + +define void @doit(i32 %one, i32 %two) { + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32] + ret void +} + +define i32 @main() { +entry: + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + store i32 0, i32* %retval + call i32 bitcast (void (i32, i32)* @doit to i32 (i32, i64)*)(i32 0, i64 0) nounwind + ret i32 1 +} + +declare i32 @printf(i8*, ...) + diff --git a/tests/runner.py b/tests/runner.py index b40c52ea..339ce68c 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -6021,6 +6021,50 @@ def process(filename): self.do_run(src, '100\n200\n13\n42\n', post_build=add_pre_run_and_checks) + def test_dlfcn_self(self): + if Settings.USE_TYPED_ARRAYS == 1: return self.skip('Does not work with USE_TYPED_ARRAYS=1') + Settings.DLOPEN_SUPPORT = 1 + + src = r''' +#include <stdio.h> +#include <dlfcn.h> + +int global = 123; + +extern "C" __attribute__((noinline)) void foo(int x) { + printf("%d\n", x); +} + +extern "C" __attribute__((noinline)) void repeatable() { + void* self = dlopen(NULL, RTLD_LAZY); + int* global_ptr = (int*)dlsym(self, "global"); + void (*foo_ptr)(int) = (void (*)(int))dlsym(self, "foo"); + foo_ptr(*global_ptr); + dlclose(self); +} + +int main() { + repeatable(); + repeatable(); + return 0; +}''' + def post(filename): + with open(filename) as f: + for line in f: + if 'var SYMBOL_TABLE' in line: + table = line + break + else: + raise Exception('Could not find symbol table!') + import json + table = json.loads(table[table.find('{'):table.rfind('}')+1]) + actual = list(sorted(table.keys())) + # ensure there aren't too many globals; we don't want unnamed_addr + assert actual == ['_foo', '_global', '_main', '_repeatable'], \ + "Symbol table does not match: %s" % actual + + self.do_run(src, '123\n123', post_build=(None, post)) + def test_rand(self): return self.skip('rand() is now random') # FIXME @@ -9790,7 +9834,7 @@ def process(filename): Settings.CORRECT_ROUNDINGS = 0 self.do_run(src.replace('TYPE', 'long long'), '*-3**2**-6**5*') # JS floor operations, always to the negative. This is an undetected error here! self.do_run(src.replace('TYPE', 'int'), '*-2**2**-5**5*') # We get these right, since they are 32-bit and we can shortcut using the |0 trick - self.do_run(src.replace('TYPE', 'unsigned int'), '*-3**2**-6**5*') # We fail, since no fast shortcut for 32-bit unsigneds + self.do_run(src.replace('TYPE', 'unsigned int'), '*-2**2**-6**5*') Settings.CORRECT_ROUNDINGS = 1 Settings.CORRECT_SIGNS = 1 # To be correct here, we need sign corrections as well @@ -9804,7 +9848,7 @@ def process(filename): Settings.CORRECT_ROUNDINGS_LINES = ["src.cpp:13"] # Fix just the last mistake self.do_run(src.replace('TYPE', 'long long'), '*-3**2**-5**5*') self.do_run(src.replace('TYPE', 'int'), '*-2**2**-5**5*') # Here we are lucky and also get the first one right - self.do_run(src.replace('TYPE', 'unsigned int'), '*-3**2**-5**5*') # No such luck here + self.do_run(src.replace('TYPE', 'unsigned int'), '*-2**2**-5**5*') # And reverse the check with = 2 if Settings.USE_TYPED_ARRAYS != 2: # the errors here are very specific to non-i64 mode 1 diff --git a/tests/sdl_rotozoom.c b/tests/sdl_rotozoom.c index e81258d9..cdbdcc6f 100644 --- a/tests/sdl_rotozoom.c +++ b/tests/sdl_rotozoom.c @@ -6,7 +6,7 @@ #include "emscripten.h" #endif -const int numSprites = 8; +const int numSprites = 9; SDL_Surface *screen; SDL_Surface *sprite[numSprites]; @@ -41,6 +41,7 @@ int main(int argc, char **argv) { sprite[5] = rotozoomSurface(sprite[1], 45, 0.5, SMOOTHING_ON); sprite[6] = zoomSurface(sprite[0], -0.5, 0.5, SMOOTHING_ON); sprite[7] = zoomSurface(sprite[0], -0.5, -0.5, SMOOTHING_ON); + sprite[8] = rotozoomSurface(sprite[1], 0, 0.5, SMOOTHING_ON); mainloop(); diff --git a/tests/sdl_rotozoom.png b/tests/sdl_rotozoom.png Binary files differindex 5c5dec2f..288dd303 100644 --- a/tests/sdl_rotozoom.png +++ b/tests/sdl_rotozoom.png |