diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cases/fp80.ll | 21 | ||||
-rwxr-xr-x | tests/runner.py | 90 | ||||
-rw-r--r-- | tests/sdl_canvas.c | 2 | ||||
-rw-r--r-- | tests/sdl_ogl_p.c | 6 | ||||
-rw-r--r-- | tests/sdl_rotozoom.c | 48 | ||||
-rw-r--r-- | tests/sdl_rotozoom.png | bin | 0 -> 338527 bytes |
6 files changed, 164 insertions, 3 deletions
diff --git a/tests/cases/fp80.ll b/tests/cases/fp80.ll new file mode 100644 index 00000000..7fc0db4a --- /dev/null +++ b/tests/cases/fp80.ll @@ -0,0 +1,21 @@ +; ModuleID = '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 unnamed_addr constant [15 x i8] c"hello, world!\0A\00" ; [#uses=1] + +; [#uses=0] +define i32 @main() { +entry: + %x = zext i32 0 to x86_fp80 + %1 = bitcast x86_fp80 %x to i80 + %2 = trunc i80 %1 to i32 + %retval = alloca i32, align 4 ; [#uses=1] + store i32 0, i32* %retval + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0] + ret i32 0 +} + +; [#uses=1] +declare i32 @printf(i8*, ...) + diff --git a/tests/runner.py b/tests/runner.py index 17bc7d2c..dfe435a7 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -3012,6 +3012,78 @@ def process(filename): ''' self.do_run(src, '*cheez: 0+24*\n*cheez: 0+24*\n*albeit*\n*albeit*\nQ85*\nmaxxi:21*\nmaxxD:22.10*\n*vfp:22,199*\n*vfp:22,199*\n') + def test_varargs_byval(self): + if Settings.USE_TYPED_ARRAYS != 2: return self.skip('FIXME: Add support for this') + + src = r''' + #include <stdio.h> + #include <stdarg.h> + + typedef struct type_a { + union { + double f; + void *p; + int i; + short sym; + } value; + } type_a; + + enum mrb_vtype { + MRB_TT_FALSE = 0, /* 0 */ + MRB_TT_CLASS = 9 /* 9 */ + }; + + typedef struct type_b { + enum mrb_vtype tt:8; + } type_b; + + void print_type_a(int argc, ...); + void print_type_b(int argc, ...); + + int main(int argc, char *argv[]) + { + type_a a; + type_b b; + a.value.p = (void*) 0x12345678; + b.tt = MRB_TT_CLASS; + + printf("The original address of a is: %p\n", a.value.p); + printf("The original type of b is: %d\n", b.tt); + + print_type_a(1, a); + print_type_b(1, b); + + return 0; + } + + void print_type_a(int argc, ...) { + va_list ap; + type_a a; + + va_start(ap, argc); + a = va_arg(ap, type_a); + va_end(ap); + + printf("The current address of a is: %p\n", a.value.p); + } + + void print_type_b(int argc, ...) { + va_list ap; + type_b b; + + va_start(ap, argc); + b = va_arg(ap, type_b); + va_end(ap); + + printf("The current type of b is: %d\n", b.tt); + } + ''' + self.do_run(src, '''The original address of a is: 0x12345678 +The original type of b is: 9 +The current address of a is: 0x12345678 +The current type of b is: 9 +''') + def test_structbyval(self): # part 1: make sure that normally, passing structs by value works @@ -8306,6 +8378,20 @@ fscanfed: 10 - hello Popen(['python', FILE_PACKAGER, 'test.data', '--pre-run', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate() assert crunch_time < os.stat('ship.crn').st_mtime, 'Crunch was changed' + def test_headless(self): + if SPIDERMONKEY_ENGINE not in JS_ENGINES: return self.skip('cannot run without spidermonkey due to node limitations (Uint8ClampedArray etc.)') + + shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'example.png')) + Popen(['python', EMCC, path_from_root('tests', 'sdl_canvas.c'), '-s', 'HEADLESS=1']).communicate() + output = run_js('a.out.js', engine=SPIDERMONKEY_ENGINE, stderr=PIPE) + assert '''Init: 0 +Font: 0x1 +Sum: 0 +you should see two lines of text in different colors and a blue rectangle +SDL_Quit called (and ignored) +done. +''' in output, output + elif 'browser' in str(sys.argv): # Browser tests. @@ -9316,6 +9402,10 @@ elif 'browser' in str(sys.argv): def test_sdl_maprgba(self): self.btest('sdl_maprgba.c', reference='sdl_maprgba.png', reference_slack=3) + def test_sdl_rotozoom(self): + shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'example.png')) + self.btest('sdl_rotozoom.c', reference='sdl_rotozoom.png', args=['--preload-file', 'example.png']) + def zzztest_sdl_canvas_palette_2(self): # XXX disabled until we have proper automation open(os.path.join(self.get_dir(), 'sdl_canvas_palette_2.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_canvas_palette_2.c')).read())) open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('Module[\'preRun\'] = function() { SDL.defaults.copyOnLock = false }') diff --git a/tests/sdl_canvas.c b/tests/sdl_canvas.c index 5d1c849c..7dcfa043 100644 --- a/tests/sdl_canvas.c +++ b/tests/sdl_canvas.c @@ -53,6 +53,8 @@ int main(int argc, char **argv) { SDL_Quit(); + printf("done.\n"); + int result = sum > 3000 && sum < 5000; // varies a little on different browsers, font differences? REPORT_RESULT(); diff --git a/tests/sdl_ogl_p.c b/tests/sdl_ogl_p.c index 949aaa44..fcc53a40 100644 --- a/tests/sdl_ogl_p.c +++ b/tests/sdl_ogl_p.c @@ -145,9 +145,9 @@ int main(int argc, char *argv[]) // Render the last item using oldschool glBegin etc glBegin( GL_TRIANGLE_STRIP ); glTexCoord2i( 0, 0 ); glVertex3f( 100, 300, 0 ); - glTexCoord2i( 1, 0 ); glVertex3f( 300, 300, 0 ); - glTexCoord2i( 1, 1 ); glVertex3f( 300, 400, 0 ); - glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 0 ); + glTexCoord2i( 1, 0 ); glVertex2f( 300, 300 ); + glTexCoord2i( 1, 1 ); { float vals[3] = { 300, 400, 0 }; glVertex3fv(vals); } + glTexCoord2i( 0, 1 ); { float vals[2] = { 500, 410 }; glVertex2fv(vals); } glEnd(); SDL_GL_SwapBuffers(); diff --git a/tests/sdl_rotozoom.c b/tests/sdl_rotozoom.c new file mode 100644 index 00000000..cb6295cc --- /dev/null +++ b/tests/sdl_rotozoom.c @@ -0,0 +1,48 @@ +#include "SDL/SDL.h" +#include "SDL/SDL_image.h" +#include "SDL/SDL_rotozoom.h" + +#ifdef EMSCRIPTEN +#include "emscripten.h" +#endif + +SDL_Surface *screen; +SDL_Surface *sprite[4]; + +void mainloop() { + int i; + SDL_Rect rect = { 0, 0, 100, 100 }; + for (i = 0; i < 4; i++) { + rect.x = i & 1 ? 200 : 0; + rect.y = i & 2 ? 200 : 0; + SDL_BlitSurface(sprite[i], 0, screen, &rect); + SDL_UpdateRect(screen, 0, 0, 0, 0); + } +} + +int main(int argc, char **argv) { + SDL_Init(SDL_INIT_VIDEO); + + screen = SDL_SetVideoMode(400, 400, 32, SDL_SWSURFACE); + + sprite[0] = IMG_Load("example.png"); + sprite[1] = SDL_CreateRGBSurface(SDL_SWSURFACE, 100, 100, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF); + SDL_FillRect(sprite[1], 0, 0xA0A0A0A0); + sprite[2] = zoomSurface(sprite[0], 0.5, 0.5, SMOOTHING_ON); + sprite[3] = zoomSurface(sprite[1], 0.5, 0.5, SMOOTHING_ON); + + mainloop(); + +#ifndef EMSCRIPTEN + SDL_Event evt; + while (1) { + if (SDL_PollEvent(&evt) != 0 && evt.type == SDL_QUIT) break; + //mainloop(); + SDL_Delay(33); + } +#endif + + SDL_Quit(); + + return 1; +} diff --git a/tests/sdl_rotozoom.png b/tests/sdl_rotozoom.png Binary files differnew file mode 100644 index 00000000..83ec0589 --- /dev/null +++ b/tests/sdl_rotozoom.png |