diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 21 | ||||
-rw-r--r-- | tests/sdl_audio_mix.c | 12 | ||||
-rw-r--r-- | tests/sounds/noise.ogg | bin | 0 -> 9205 bytes |
3 files changed, 31 insertions, 2 deletions
diff --git a/tests/runner.py b/tests/runner.py index 7f8c2d87..04baf47b 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -10496,6 +10496,24 @@ f.close() self.assertContained('result: 1', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + def test_export_all(self): + lib = r''' + #include <stdio.h> + void libf1() { printf("libf1\n"); } + void libf2() { printf("libf2\n"); } + ''' + lib_name = os.path.join(self.get_dir(), 'lib.c') + open(lib_name, 'w').write(lib) + + open('main.js', 'w').write(''' + _libf1(); + _libf2(); + ''') + + Building.emcc(lib_name, ['-s', 'EXPORT_ALL=1', '--post-js', 'main.js'], output_filename='a.out.js') + + self.assertContained('libf1\nlibf2\n', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + def test_abspaths(self): # Includes with absolute paths are generally dangerous, things like -I/usr/.. will get to system local headers, not our portable ones. @@ -12290,9 +12308,10 @@ elif 'browser' in str(sys.argv): def test_sdl_audio_mix(self): shutil.copyfile(path_from_root('tests', 'sounds', 'pluck.ogg'), os.path.join(self.get_dir(), 'sound.ogg')) shutil.copyfile(path_from_root('tests', 'sounds', 'the_entertainer.ogg'), os.path.join(self.get_dir(), 'music.ogg')) + shutil.copyfile(path_from_root('tests', 'sounds', 'noise.ogg'), os.path.join(self.get_dir(), 'noise.ogg')) open(os.path.join(self.get_dir(), 'sdl_audio_mix.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_audio_mix.c')).read())) - Popen([PYTHON, EMCC, '-O2', '--minify', '0', os.path.join(self.get_dir(), 'sdl_audio_mix.c'), '--preload-file', 'sound.ogg', '--preload-file', 'music.ogg', '-o', 'page.html']).communicate() + Popen([PYTHON, EMCC, '-O2', '--minify', '0', os.path.join(self.get_dir(), 'sdl_audio_mix.c'), '--preload-file', 'sound.ogg', '--preload-file', 'music.ogg', '--preload-file', 'noise.ogg', '-o', 'page.html']).communicate() self.run_browser('page.html', '', '/report_result?1') def test_sdl_audio_quickload(self): diff --git a/tests/sdl_audio_mix.c b/tests/sdl_audio_mix.c index f72f9c43..a1c0485d 100644 --- a/tests/sdl_audio_mix.c +++ b/tests/sdl_audio_mix.c @@ -5,9 +5,11 @@ #include <emscripten.h> static Mix_Chunk *sound = NULL; +static Mix_Chunk *noiseLoop = NULL; static Mix_Music *music = NULL; static int soundChannel = 0; +static int noiseLoopChannel = 0; void one_iter(); void one_iter() { @@ -19,6 +21,12 @@ void one_iter() { soundChannel = Mix_PlayChannel(-1, sound, 0); printf("channel = %d", soundChannel); assert(soundChannel != -1 && soundChannel != 0); + + noiseLoopChannel = Mix_PlayChannel(-1, noiseLoop, -1); + printf("noiseLoopChannel = %d", noiseLoopChannel); + assert(noiseLoopChannel != -1 && noiseLoopChannel != 0); + // set noiseLoopChannel to half volume + Mix_Volume(noiseLoopChannel,MIX_MAX_VOLUME/10); break; case 2: printf("channel %d is playing = %d", soundChannel, Mix_Playing(soundChannel)); @@ -70,9 +78,11 @@ int main(int argc, char **argv) { sound = Mix_LoadWAV("sound.ogg"); assert(sound); + noiseLoop = Mix_LoadWAV("noise.ogg"); + assert(noiseLoop); + music = Mix_LoadMUS("music.ogg"); assert(music); - emscripten_set_main_loop(one_iter, 30, 0); // force a quit diff --git a/tests/sounds/noise.ogg b/tests/sounds/noise.ogg Binary files differnew file mode 100644 index 00000000..c53d49a7 --- /dev/null +++ b/tests/sounds/noise.ogg |