diff options
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 165 |
1 files changed, 10 insertions, 155 deletions
diff --git a/tests/runner.py b/tests/runner.py index b819af25..96b00c50 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -6794,84 +6794,9 @@ def process(filename): self.emcc_args += ['--embed-file', 'three_numbers.txt'] self.do_run(src, 'match = 3\nx = -1.0, y = 0.1, z = -0.1\n') - def test_folders(self): - add_pre_run = ''' -def process(filename): - src = open(filename, 'r').read().replace( - '// {{PRE_RUN_ADDITIONS}}', - \'\'\' - FS.createFolder('/', 'test', true, false); - FS.createPath('/', 'test/hello/world/', true, false); - FS.createPath('/test', 'goodbye/world/', true, false); - FS.createPath('/test/goodbye', 'noentry', false, false); - FS.createDataFile('/test', 'freeforall.ext', 'abc', true, true); - FS.createDataFile('/test', 'restricted.ext', 'def', false, false); - \'\'\' - ) - open(filename, 'w').write(src) -''' - src = r''' - #include <stdio.h> - #include <dirent.h> - #include <errno.h> - - int main() { - struct dirent *e; - - // Basic correct behaviour. - DIR* d = opendir("/test"); - printf("--E: %d\n", errno); - while ((e = readdir(d))) puts(e->d_name); - printf("--E: %d\n", errno); - - // Empty folder; tell/seek. - puts("****"); - d = opendir("/test/hello/world/"); - e = readdir(d); - puts(e->d_name); - int pos = telldir(d); - e = readdir(d); - puts(e->d_name); - seekdir(d, pos); - e = readdir(d); - puts(e->d_name); - - // Errors. - puts("****"); - printf("--E: %d\n", errno); - d = opendir("/test/goodbye/noentry"); - printf("--E: %d, D: %d\n", errno, d); - d = opendir("/i/dont/exist"); - printf("--E: %d, D: %d\n", errno, d); - d = opendir("/test/freeforall.ext"); - printf("--E: %d, D: %d\n", errno, d); - while ((e = readdir(d))) puts(e->d_name); - printf("--E: %d\n", errno); - - return 0; - } - ''' - expected = ''' - --E: 0 - . - .. - hello - goodbye - freeforall.ext - restricted.ext - --E: 0 - **** - . - .. - .. - **** - --E: 0 - --E: 13, D: 0 - --E: 2, D: 0 - --E: 20, D: 0 - --E: 9 - ''' - self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected), post_build=add_pre_run) + def test_readdir(self): + src = open(path_from_root('tests', 'dirent', 'test_readdir.c'), 'r').read() + self.do_run(src, 'success', force_c=True) def test_stat(self): add_pre_run = ''' @@ -7087,49 +7012,8 @@ def process(filename): self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected)) def test_utime(self): - add_pre_run_and_checks = ''' -def process(filename): - src = open(filename, 'r').read().replace( - '// {{PRE_RUN_ADDITIONS}}', - \'\'\' - var TEST_F1 = FS.createFolder('/', 'writeable', true, true); - var TEST_F2 = FS.createFolder('/', 'unwriteable', true, false); - \'\'\' - ).replace( - '// {{POST_RUN_ADDITIONS}}', - \'\'\' - Module.print('first changed: ' + (TEST_F1.timestamp == 1200000000000)); - Module.print('second changed: ' + (TEST_F2.timestamp == 1200000000000)); - \'\'\' - ) - open(filename, 'w').write(src) -''' - src = r''' - #include <stdio.h> - #include <errno.h> - #include <utime.h> - - int main() { - struct utimbuf t = {1000000000, 1200000000}; - char* writeable = "/writeable"; - char* unwriteable = "/unwriteable"; - - utime(writeable, &t); - printf("writeable errno: %d\n", errno); - - utime(unwriteable, &t); - printf("unwriteable errno: %d\n", errno); - - return 0; - } - ''' - expected = ''' - writeable errno: 0 - unwriteable errno: 1 - first changed: true - second changed: false - ''' - self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected), post_build=add_pre_run_and_checks) + src = open(path_from_root('tests', 'utime', 'test_utime.c'), 'r').read() + self.do_run(src, 'success', force_c=True) def test_utf(self): self.banned_js_engines = [SPIDERMONKEY_ENGINE] # only node handles utf well @@ -7221,38 +7105,6 @@ def process(filename): Settings.LINKABLE = linkable # regression check for issue #273 self.do_run(src, "1 2 3") - def test_readdir(self): - add_pre_run = ''' -def process(filename): - src = open(filename, 'r').read().replace( - '// {{PRE_RUN_ADDITIONS}}', - "FS.createFolder('', 'test', true, true);\\nFS.createLazyFile( 'test', 'some_file', 'http://localhost/some_file', true, false);\\nFS.createFolder('test', 'some_directory', true, true);" - ) - open(filename, 'w').write(src) -''' - - src = ''' - #include <dirent.h> - #include <stdio.h> - - int main() - { - DIR * dir; - dirent * entity; - - dir = opendir( "test" ); - - while( ( entity = readdir( dir ) ) ) - { - printf( "%s is a %s\\n", entity->d_name, entity->d_type & DT_DIR ? "directory" : "file" ); - } - - return 0; - } - - ''' - self.do_run(src, ". is a directory\n.. is a directory\nsome_file is a file\nsome_directory is a directory", post_build=add_pre_run) - def test_fs_base(self): Settings.INCLUDE_FULL_LIBRARY = 1 try: @@ -13183,8 +13035,11 @@ Press any key to continue.''' 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']) + shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) + self.btest('sdl_rotozoom.c', reference='sdl_rotozoom.png', args=['--preload-file', 'screenshot.png'], reference_slack=3) + + def test_sdl_gfx_primitives(self): + self.btest('sdl_gfx_primitives.c', reference='sdl_gfx_primitives.png', reference_slack=1) def test_sdl_canvas_palette_2(self): open(os.path.join(self.get_dir(), 'pre.js'), 'w').write(''' |