diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cases/uadd_overflow.ll | 25 | ||||
-rw-r--r-- | tests/cases/uadd_overflow.txt | 1 | ||||
-rw-r--r-- | tests/freetype/main_2.c | 135 | ||||
-rw-r--r-- | tests/freetype/ref_2.txt | 33 | ||||
-rw-r--r-- | tests/hello_world_sdl.cpp | 4 | ||||
-rwxr-xr-x | tests/runner.py | 204 | ||||
-rw-r--r-- | tests/sdl_audio.c | 50 | ||||
-rw-r--r-- | tests/sdl_canvas.c | 8 | ||||
-rw-r--r-- | tests/sdl_mouse.c | 2 | ||||
-rw-r--r-- | tests/sounds/LICENSE.txt | 19 | ||||
-rw-r--r-- | tests/sounds/alarmcreatemiltaryfoot_1.wav | bin | 0 -> 443856 bytes | |||
-rw-r--r-- | tests/sounds/alarmvictory_1.ogg | bin | 0 -> 56490 bytes |
12 files changed, 401 insertions, 80 deletions
diff --git a/tests/cases/uadd_overflow.ll b/tests/cases/uadd_overflow.ll new file mode 100644 index 00000000..a808b9de --- /dev/null +++ b/tests/cases/uadd_overflow.ll @@ -0,0 +1,25 @@ +; 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" + +@.str2 = private constant [9 x i8] c"*%d,%d*\0A\00", align 1 ; [#uses=1] + +; [#uses=0] +define i32 @main() { +entry: + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + %mul7 = bitcast i32 -259741926 to i32 + %shl10 = shl i32 4014, 16 + %uadd1 = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %mul7, i32 %shl10) + %a0 = extractvalue { i32, i1 } %uadd1, 0 + %a1 = extractvalue { i32, i1 } %uadd1, 1 + %a2 = zext i1 %a1 to i32 + call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %a0, i32 %a2) ; [#uses=0] + ret i32 1 +} + +; [#uses=1] +declare i32 @printf(i8*, ...) + +declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone + diff --git a/tests/cases/uadd_overflow.txt b/tests/cases/uadd_overflow.txt new file mode 100644 index 00000000..dcda9240 --- /dev/null +++ b/tests/cases/uadd_overflow.txt @@ -0,0 +1 @@ +*3319578,1* diff --git a/tests/freetype/main_2.c b/tests/freetype/main_2.c new file mode 100644 index 00000000..85e5609d --- /dev/null +++ b/tests/freetype/main_2.c @@ -0,0 +1,135 @@ +/* example1.c */ +/* */ +/* This small program shows how to print a rotated string with the */ +/* FreeType 2 library. */ + + +#include <stdio.h> +#include <string.h> +#include <math.h> +#include <stdlib.h> + +#include <ft2build.h> +#include FT_FREETYPE_H + +int WIDTH = 0; +int HEIGHT = 0; + +/* origin is the upper left corner */ +unsigned char *image; + + +/* Replace this function with something useful. */ + +void +draw_bitmap( FT_Bitmap* bitmap, + FT_Int x, + FT_Int y) +{ + FT_Int i, j, p, q; + FT_Int x_max = x + bitmap->width; + FT_Int y_max = y + bitmap->rows; + + for ( i = x, p = 0; i < x_max; i++, p++ ) + { + for ( j = y, q = 0; j < y_max; j++, q++ ) + { + if ( i < 0 || j < 0 || + i >= WIDTH || j >= HEIGHT ) + continue; + + image[j*WIDTH + i] |= bitmap->buffer[q * bitmap->width + p]; + } + } +} + + +void +show_image( void ) +{ + int i, j; + int count = 0; + + for ( i = 0; i < HEIGHT; i++ ) + { + for ( j = 0; j < WIDTH; j++ ) + { + if (image[i*WIDTH + j]) count++; + putchar(image[i*WIDTH + j] == 0? ' ' + : image[i*WIDTH + j] < 128 ? '+' + : '*' ); + } + putchar( '\n' ); + } + printf("Non-0s: %d\n", count); +} + + +int +main( int argc, + char** argv ) +{ + FT_Library library; + FT_Face face; + + FT_GlyphSlot slot; + FT_Error error; + + FT_UInt glyphIndex; + + char* filename; + char* text; + + int target_height; + + if ( argc != 6 ) + { + fprintf ( stderr, "usage: %s font sample-text width height angle\n", argv[0] ); + exit( 1 ); + } + + // Only test the character 'w' + text = "w"; + + filename = argv[1]; /* first argument */ + WIDTH = atoi(argv[3]); + HEIGHT = atoi(argv[4]); + target_height = HEIGHT; + + image = (unsigned char*)malloc(WIDTH*HEIGHT); + for (int x = 0; x < WIDTH; x++) + for (int y = 0; y < HEIGHT; y++) + image[y*WIDTH + x] = 0; + + error = FT_Init_FreeType( &library ); /* initialize library */ + if (error) printf("Init Error! %d\n", error); + + error = FT_New_Face( library, argv[1], 0, &face ); /* create face object */ + if (error) printf("New_Face Error! %d\n", error); + + /* use 50pt at 100dpi */ + error = FT_Set_Char_Size( face, 0, 32 * 64, 0, 0 ); /* set character size */ + if (error) printf("Set_Cshar_Size Error! %d\n", error); + + slot = face->glyph; + + glyphIndex = FT_Get_Char_Index(face, text[0]); + + /* load glyph image into the slot (erase previous one) */ + error = FT_Load_Glyph(face, glyphIndex, FT_LOAD_NO_BITMAP); + if(error) printf("FT_Load_Glyph Error! %d\n", error); + + error = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL); + if(error) printf("FT_Render_Glyph Error! %d\n", error); + + /* now, draw to our target surface (convert position) */ + draw_bitmap(&slot->bitmap, slot->bitmap_left, target_height - slot->bitmap_top); + + show_image(); + + FT_Done_Face(face); + FT_Done_FreeType(library); + return 0; +} + +/* EOF */
\ No newline at end of file diff --git a/tests/freetype/ref_2.txt b/tests/freetype/ref_2.txt new file mode 100644 index 00000000..c15bb415 --- /dev/null +++ b/tests/freetype/ref_2.txt @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + +****+ +***** +**** +****+ +*****+ +**** ++**** ******+ ****+ ++**** ******* ****+ ++****+ +***+*** +**** + ****+ +***+***+ +***+ + +***+ **** ***+ ****+ + +**** ***+ +*** ****+ + +**** +***+ +*** +**** + ****++*** +***++***+ + +***+**** ***++***+ + +***+***+ +*******+ + *******+ +******* + ******* +******+ + +*****+ ******+ + +*****+ +***** + *****+ +***** +Non-0s: 285 diff --git a/tests/hello_world_sdl.cpp b/tests/hello_world_sdl.cpp index 35aec303..b6401995 100644 --- a/tests/hello_world_sdl.cpp +++ b/tests/hello_world_sdl.cpp @@ -14,13 +14,13 @@ int main() { *((char*)screen->pixels + i*256*4 + j*4 + 0) = i; *((char*)screen->pixels + i*256*4 + j*4 + 1) = j; *((char*)screen->pixels + i*256*4 + j*4 + 2) = 255-i; - *((char*)screen->pixels + i*256*4 + j*4 + 3) = 255; + *((char*)screen->pixels + i*256*4 + j*4 + 3) = (i+j)%255; // actually ignored, since this is to the screen } } if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); SDL_Flip(screen); - printf("you should see a colored cube.\n"); + printf("you should see a smoothly-colored square - no sharp lines but the square borders!\n"); printf("and here is some text that should be HTML-friendly: amp: |&| double-quote: |\"| quote: |'| less-than, greater-than, html-like tags: |<cheez></cheez>|\nanother line.\n"); SDL_Quit(); diff --git a/tests/runner.py b/tests/runner.py index 6d060f7e..27142eaf 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -1882,75 +1882,81 @@ m_divisor is 1091269979 ''' self.do_run(src, 'z:1*', force_c=True) - if self.emcc_args is not None: # too slow in other modes - # We should not blow up the stack with numerous allocas + def test_alloca_stack(self): + if self.emcc_args is None: return # too slow in other modes - src = ''' - #include <stdio.h> - #include <stdlib.h> + # We should not blow up the stack with numerous allocas + src = ''' + #include <stdio.h> + #include <stdlib.h> - func(int i) { - char *pc = (char *)alloca(100); - *pc = i; - (*pc)++; - return (*pc) % 10; - } - int main() { - int total = 0; - for (int i = 0; i < 1024*1024; i++) - total += func(i); - printf("ok:%d*\\n", total); - return 0; - } - ''' - self.do_run(src, 'ok:-32768*', force_c=True) + func(int i) { + char *pc = (char *)alloca(100); + *pc = i; + (*pc)++; + return (*pc) % 10; + } + int main() { + int total = 0; + for (int i = 0; i < 1024*1024; i++) + total += func(i); + printf("ok:%d*\\n", total); + return 0; + } + ''' + self.do_run(src, 'ok:-32768*', force_c=True) - # We should also not blow up the stack with byval arguments - src = r''' - #include<stdio.h> - struct vec { - int x, y, z; - vec(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {} - static vec add(vec a, vec b) { - return vec(a.x+b.x, a.y+b.y, a.z+b.z); - } - }; - int main() { - int total = 0; - for (int i = 0; i < 1000; i++) { - for (int j = 0; j < 1000; j++) { - vec c(i+i%10, j*2, i%255); - vec d(j*2, j%255, i%120); - vec f = vec::add(c, d); - total += (f.x + f.y + f.z) % 100; - total %= 10240; - } + def test_stack_byval(self): + if self.emcc_args is None: return # too slow in other modes + + # We should also not blow up the stack with byval arguments + src = r''' + #include<stdio.h> + struct vec { + int x, y, z; + vec(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {} + static vec add(vec a, vec b) { + return vec(a.x+b.x, a.y+b.y, a.z+b.z); + } + }; + int main() { + int total = 0; + for (int i = 0; i < 1000; i++) { + for (int j = 0; j < 1000; j++) { + vec c(i+i%10, j*2, i%255); + vec d(j*2, j%255, i%120); + vec f = vec::add(c, d); + total += (f.x + f.y + f.z) % 100; + total %= 10240; } - printf("sum:%d*\n", total); - return 1; } - ''' - self.do_run(src, 'sum:9780*') + printf("sum:%d*\n", total); + return 1; + } + ''' + self.do_run(src, 'sum:9780*') - # We should not blow up the stack with numerous varargs + def test_stack_varargs(self): + if self.emcc_args is None: return # too slow in other modes - src = r''' - #include <stdio.h> - #include <stdlib.h> + # We should not blow up the stack with numerous varargs + src = r''' + #include <stdio.h> + #include <stdlib.h> - void func(int i) { - printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n", - i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i); - } - int main() { - for (int i = 0; i < 1024; i++) - func(i); - printf("ok!\n"); - return 0; - } - ''' - Settings.TOTAL_STACK = 1024 - self.do_run(src, 'ok!') + void func(int i) { + printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n", + i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i); + } + int main() { + for (int i = 0; i < 1024; i++) + func(i); + printf("ok!\n"); + return 0; + } + ''' + Settings.TOTAL_STACK = 1024 + self.do_run(src, 'ok!') def test_array2(self): src = ''' @@ -4715,6 +4721,15 @@ def process(filename): post_build=post) #build_ll_hook=self.do_autodebug) + # Second testcase, github issue 324 + print '[issue 324]' + self.do_run(open(path_from_root('tests', 'freetype', 'main_2.c'), 'r').read(), + open(path_from_root('tests', 'freetype', 'ref_2.txt'), 'r').read(), + ['font.ttf', 'w', '32', '32', '25'], + libraries=self.get_freetype(), + includes=[path_from_root('tests', 'freetype', 'include')], + post_build=post) + def test_sqlite(self): # gcc -O3 -I/home/alon/Dev/emscripten/tests/sqlite -ldl src.c if self.emcc_args is None: return self.skip('Very slow without ta2, and we would also need to include dlmalloc manually without emcc') @@ -6103,7 +6118,7 @@ Options that are modified or new in %s include: assert ('assert(STACKTOP < STACK_MAX' in generated) == (opt_level == 0), 'assertions should be in opt == 0' 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 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 'HEAP8[HEAP32[' in generated or 'HEAP8[$vla1 + ($storemerge4 / 2 & -1) | 0]' in generated or 'HEAP8[$vla1 + ($storemerge4 / 2 & -1) | 0]' in generated or 'HEAP8[$vla1 + ($i_04 / 2 & -1) | 0]' in generated or 'HEAP8[$vla1 + ($i_04 / 2 & -1)]' in generated or 'HEAP8[$1 + ($i_01 / 2 & -1) | 0]' in generated or 'HEAP8[$1 + ($i_01 / 2 & -1) | 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' @@ -6321,15 +6336,16 @@ f.close() # by individual files Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', 'subdirr/data1.txt', '--preload-file', 'subdirr/moar/data2.txt', '-o', 'page.html']).communicate() self.run_browser('page.html', 'You should see two cool numbers', '/report_result?1') - os.remove('page.html') - # by directory + # by directory, and remove files to make sure Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', 'subdirr', '-o', 'page.html']).communicate() + shutil.rmtree(os.path.join(self.get_dir(), 'subdirr')) self.run_browser('page.html', 'You should see two cool numbers', '/report_result?1') def test_compressed_file(self): open(os.path.join(self.get_dir(), 'datafile.txt'), 'w').write('compress this please' + (2000*'.')) + open(os.path.join(self.get_dir(), 'datafile2.txt'), 'w').write('moar' + (100*'!')) open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r''' #include <stdio.h> #include <string.h> @@ -6342,17 +6358,23 @@ f.close() fclose(f); printf("file says: |%s|\n", buf); int result = !strcmp("compress this please", buf); + FILE *f2 = fopen("datafile2.txt", "r"); + fread(buf, 1, 5, f2); + buf[5] = 0; + fclose(f2); + result = result && !strcmp("moar!", buf); + printf("file 2 says: |%s|\n", buf); REPORT_RESULT(); return 0; } ''')) - Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-o', 'page.html', '--preload-file', 'datafile.txt', + Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-o', 'page.html', '--preload-file', 'datafile.txt', '--preload-file', 'datafile2.txt', '--compression', '%s,%s,%s' % (path_from_root('third_party', 'lzma.js', 'lzma-native'), path_from_root('third_party', 'lzma.js', 'lzma-decoder.js'), 'LZMA.decompress')]).communicate() assert os.path.exists(os.path.join(self.get_dir(), 'datafile.txt')), 'must be data file' - assert os.path.exists(os.path.join(self.get_dir(), 'datafile.txt.compress')), 'must be data file in compressed form' + assert os.path.exists(os.path.join(self.get_dir(), 'page.data.compress')), 'must be data file in compressed form' assert os.stat(os.path.join(self.get_dir(), 'page.js')).st_size != os.stat(os.path.join(self.get_dir(), 'page.js.compress')).st_size, 'compressed file must be different' shutil.move(os.path.join(self.get_dir(), 'datafile.txt'), 'datafile.txt.renamedsoitcannotbefound'); self.run_browser('page.html', '', '/report_result?1') @@ -6366,10 +6388,10 @@ f.close() self.run_browser('page.html', '', '/report_result?600') def test_sdl_image_compressed(self): - for image, worth_compressing, width in [(path_from_root('tests', 'screenshot2.png'), True, 300), - (path_from_root('tests', 'screenshot.jpg'), False, 600)]: + for image, width in [(path_from_root('tests', 'screenshot2.png'), 300), + (path_from_root('tests', 'screenshot.jpg'), 600)]: self.clear() - print image, worth_compressing + print image basename = os.path.basename(image) shutil.copyfile(image, os.path.join(self.get_dir(), basename)) @@ -6379,10 +6401,7 @@ f.close() '--compression', '%s,%s,%s' % (path_from_root('third_party', 'lzma.js', 'lzma-native'), path_from_root('third_party', 'lzma.js', 'lzma-decoder.js'), 'LZMA.decompress')]).communicate() - assert ('.compress' in open('page.js').read()) == worth_compressing, 'do not compress image if not worth it' - assert os.path.exists(basename + '.compress') == worth_compressing, 'remove .compress if not compressing' - if worth_compressing: - shutil.move(os.path.join(self.get_dir(), basename), basename + '.renamedsoitcannotbefound'); + shutil.move(os.path.join(self.get_dir(), basename), basename + '.renamedsoitcannotbefound'); self.run_browser('page.html', '', '/report_result?' + str(width)) def test_sdl_canvas(self): @@ -6451,6 +6470,15 @@ f.close() Popen(['python', EMCC, os.path.join(self.get_dir(), 'sdl_mouse.c'), '-o', 'page.html', '--pre-js', 'pre.js']).communicate() self.run_browser('page.html', '', '/report_result?740') + def test_sdl_audio(self): + shutil.copyfile(path_from_root('tests', 'sounds', 'alarmvictory_1.ogg'), os.path.join(self.get_dir(), 'sound.ogg')) + shutil.copyfile(path_from_root('tests', 'sounds', 'alarmcreatemiltaryfoot_1.wav'), os.path.join(self.get_dir(), 'sound2.wav')) + open(os.path.join(self.get_dir(), 'sdl_audio.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_audio.c')).read())) + + # use closure to check for a possible bug with closure minifying away newer Audio() attributes + Popen(['python', EMCC, '-O2', '--minify', '0', os.path.join(self.get_dir(), 'sdl_audio.c'), '--preload-file', 'sound.ogg', '--preload-file', 'sound2.wav', '-o', 'page.html', '-s', 'EXPORTED_FUNCTIONS=["_main", "_play", "_play2"]']).communicate() + self.run_browser('page.html', '', '/report_result?1') + def test_worker(self): # Test running in a web worker output = Popen(['python', EMCC, path_from_root('tests', 'hello_world_worker.cpp'), '-o', 'worker.js'], stdout=PIPE, stderr=PIPE).communicate() @@ -6665,6 +6693,36 @@ f.close() output = Popen([NODE_JS, JS_OPTIMIZER, input] + passes, stdin=PIPE, stdout=PIPE).communicate()[0] self.assertIdentical(expected, output.replace('\n\n', '\n')) + def test_m_mm(self): + open(os.path.join(self.get_dir(), 'foo.c'), 'w').write('''/* */''') + for opt in ['M', 'MM']: + output = Popen(['python', EMCC, os.path.join(self.get_dir(), 'foo.c'), '-' + opt], stdout=PIPE).communicate()[0] + assert 'foo.o: ' in output, '-%s failed to produce the right output: %s' % (opt, output) + + def test_llvm_nativizer(self): + # avoid impure_ptr problems etc. + shutil.copyfile(path_from_root('tests', 'files.cpp'), os.path.join(self.get_dir(), 'files.cpp')) + open(os.path.join(self.get_dir(), 'somefile.binary'), 'w').write('''waka waka############################''') + open(os.path.join(self.get_dir(), 'test.file'), 'w').write('''ay file..............,,,,,,,,,,,,,,''') + open(os.path.join(self.get_dir(), 'stdin'), 'w').write('''inter-active''') + Popen(['python', EMCC, os.path.join(self.get_dir(), 'files.cpp'), '-c']).communicate() + Popen(['python', path_from_root('tools', 'nativize_llvm.py'), os.path.join(self.get_dir(), 'files.o')]).communicate(input)[0] + output = Popen([os.path.join(self.get_dir(), 'files.o.run')], stdin=open(os.path.join(self.get_dir(), 'stdin')), stdout=PIPE, stderr=PIPE).communicate() + self.assertIdentical('''size: 37 +data: 119,97,107,97,32,119,97,107,97,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35 +loop: 119 97 107 97 32 119 97 107 97 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 +input:inter-active +texto +$ +5 : 10,30,20,11,88 +other=ay file... +seeked= file. +seeked=e... +seeked=,,. +fscanfed: 10 - hello +''', output[0]) + self.assertIdentical('texte\n', output[1]) + elif 'benchmark' in str(sys.argv): # Benchmarks. Run them with argument |benchmark|. To run a specific test, do # |benchmark.test_X|. diff --git a/tests/sdl_audio.c b/tests/sdl_audio.c new file mode 100644 index 00000000..77c82b4e --- /dev/null +++ b/tests/sdl_audio.c @@ -0,0 +1,50 @@ +#include <stdio.h> +#include <SDL/SDL.h> +#include <SDL/SDL_mixer.h> +#include <assert.h> +#include <emscripten.h> + +Mix_Chunk *sound, *sound2; + +void play2(); + +void play() { + int channel = Mix_PlayChannel(-1, sound, 1); + assert(channel >= 0); + + emscripten_run_script("setTimeout(Module['_play2'], 1000)"); +} + +void play2() { + int channel2 = Mix_PlayChannel(-1, sound2, 1); + assert(channel2 >= 0); +} + +int main(int argc, char **argv) { + SDL_Init(SDL_INIT_AUDIO); + + int ret = Mix_OpenAudio(0, 0, 0, 0); // we ignore all these.. + assert(ret == 0); + + sound = Mix_LoadWAV("sound.ogg"); + assert(sound); + sound2 = Mix_LoadWAV("sound2.wav"); + assert(sound); + + play(); + if (argc == 12121) play2(); // keep it alive + + emscripten_run_script("element = document.createElement('input');" + "element.setAttribute('type', 'button');" + "element.setAttribute('value', 'replay!');" + "element.setAttribute('onclick', 'Module[\"_play\"]()');" + "document.body.appendChild(element);"); + + printf("you should hear two sounds. press the button to replay!\n"); + + int result = 1; + REPORT_RESULT(); + + return 0; +} + diff --git a/tests/sdl_canvas.c b/tests/sdl_canvas.c index aaa9d653..ab1340a8 100644 --- a/tests/sdl_canvas.c +++ b/tests/sdl_canvas.c @@ -12,11 +12,11 @@ int main() { TTF_Font *font = TTF_OpenFont("myfont.ttf", 40); printf("Font: %p\n", font); - SDL_Color color = { 0xff, 0x99, 0x00, 0xb0 }; + SDL_Color color = { 0xff, 0x99, 0x00, 0xff }; - SDL_Surface *text = TTF_RenderText_Solid(font, "hello faint orange world", color); + SDL_Surface *text = TTF_RenderText_Solid(font, "hello orange world", color); - SDL_Color color2 = { 0xbb, 0, 0xff, 0 }; + SDL_Color color2 = { 0xbb, 0, 0xff, 0xff }; SDL_Surface *text2 = TTF_RenderText_Solid(font, "a second line, purple", color2); // render @@ -27,7 +27,7 @@ int main() { // fill stuff SDL_Rect rect = { 200, 200, 175, 125 }; - SDL_FillRect(screen, &rect, 0x2222ff00); + SDL_FillRect(screen, &rect, 0x2222ffff); SDL_Flip(screen); diff --git a/tests/sdl_mouse.c b/tests/sdl_mouse.c index a0520839..dae3f636 100644 --- a/tests/sdl_mouse.c +++ b/tests/sdl_mouse.c @@ -44,7 +44,7 @@ int main() { SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE); SDL_Rect rect = { 0, 0, 600, 450 }; - SDL_FillRect(screen, &rect, 0x2244ff00); + SDL_FillRect(screen, &rect, 0x2244ffff); emscripten_run_script("simulateMouseEvent(10, 20, -1)"); // move from 0,0 to 10,20 emscripten_run_script("simulateMouseEvent(10, 20, 0)"); // click diff --git a/tests/sounds/LICENSE.txt b/tests/sounds/LICENSE.txt new file mode 100644 index 00000000..1525d517 --- /dev/null +++ b/tests/sounds/LICENSE.txt @@ -0,0 +1,19 @@ +The files in this directory are Copyright (C) 2009 Wildfire Games. + +These files are licensed under the Creative Commons Attribution-Share Alike 3.0 +(CC-by-sa) license, available at http://creativecommons.org/licenses/by-sa/3.0/ + +Briefly, this means: + +* You may use, modify and distribute these files, for commercial and + non-commercial purposes. + +* If you distribute one of these files, you must include attribution (e.g. + in the credits screen of a game or a video, or in a text file accompanying + the files). The attribution must include: + * A link to http://creativecommons.org/licenses/by-sa/3.0/ + * The name "Wildfire Games" as the original author + * A link to http://www.wildfiregames.com/ + +* If you distribute one of these files, you must release it (and any + modifications you have made to it) under the CC-by-sa license.
\ No newline at end of file diff --git a/tests/sounds/alarmcreatemiltaryfoot_1.wav b/tests/sounds/alarmcreatemiltaryfoot_1.wav Binary files differnew file mode 100644 index 00000000..2de6314a --- /dev/null +++ b/tests/sounds/alarmcreatemiltaryfoot_1.wav diff --git a/tests/sounds/alarmvictory_1.ogg b/tests/sounds/alarmvictory_1.ogg Binary files differnew file mode 100644 index 00000000..cadb1539 --- /dev/null +++ b/tests/sounds/alarmvictory_1.ogg |