diff options
-rw-r--r-- | src/library.js | 10 | ||||
-rw-r--r-- | src/library_gl.js | 4 | ||||
-rw-r--r-- | src/library_sdl.js | 6 | ||||
-rw-r--r-- | src/postamble.js | 8 | ||||
-rw-r--r-- | src/preamble.js | 2 | ||||
-rw-r--r-- | tests/cases/gepoverflow.txt | 2 | ||||
-rw-r--r-- | tests/hello_world_gles_shell.html | 6 | ||||
-rwxr-xr-x | tests/runner.py | 73 | ||||
-rw-r--r-- | tests/stat/output.txt | 16 | ||||
-rw-r--r-- | tools/shared.py | 2 |
10 files changed, 72 insertions, 57 deletions
diff --git a/src/library.js b/src/library.js index 48efaa08..6385507c 100644 --- a/src/library.js +++ b/src/library.js @@ -26,7 +26,8 @@ LibraryManager.library = { _impure_ptr: 0, $FS__deps: ['$ERRNO_CODES', '__setErrNo', 'stdin', 'stdout', 'stderr', '_impure_ptr'], - $FS__postset: '__ATINIT__.push({ func: function() { FS.ignorePermissions = false } }); FS.init(); __ATEXIT__.push({ func: function() { FS.quit() } });', + $FS__postset: '__ATINIT__.unshift({ func: function() { FS.ignorePermissions = false; if (!FS.init.initialized) FS.init() } });' + + '__ATEXIT__.push({ func: function() { FS.quit() } });', $FS: { // The path to the current folder. currentPath: '/', @@ -341,7 +342,7 @@ LibraryManager.library = { FS.createFolder('/', 'tmp', true, true); // Create the I/O devices. - var devFolder = FS.createFolder('/', 'dev', true, false); + var devFolder = FS.createFolder('/', 'dev', true, true); var stdin = FS.createDevice(devFolder, 'stdin', input); var stdout = FS.createDevice(devFolder, 'stdout', null, output); var stderr = FS.createDevice(devFolder, 'stderr', null, error); @@ -385,6 +386,9 @@ LibraryManager.library = { _stdout = allocate([2], 'void*', ALLOC_STATIC); _stderr = allocate([3], 'void*', ALLOC_STATIC); + // Other system paths + FS.createPath('/', 'dev/shm/tmp', true, true); // temp files + // Newlib initialization FS.streams[_stdin] = FS.streams[1]; FS.streams[_stdout] = FS.streams[2]; @@ -2173,7 +2177,7 @@ LibraryManager.library = { // ========================================================================== _isFloat: function(text) { - return !!(/^[+]?[0-9]*\.?[0-9]+([eE][+-]?[0-9]+)?$/.exec(text)); + return !!(/^[+-]?[0-9]*\.?[0-9]+([eE][+-]?[0-9]+)?$/.exec(text)); }, // TODO: Document. diff --git a/src/library_gl.js b/src/library_gl.js index e1a7c73b..5cb30299 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -513,6 +513,7 @@ var LibraryGLUT = { }, glutCreateWindow: function(name) { +#if USE_TYPED_ARRAYS try { var ctx = Module.canvas.getContext('experimental-webgl'); if (!ctx) throw 'Could not create canvas :('; @@ -523,6 +524,9 @@ var LibraryGLUT = { } catch (e) { Module.print('(canvas not available)'); } +#else + Module.print('(USE_TYPED_ARRAYS needs to be enabled for WebGL)'); +#endif }, glutInitDisplayMode: function(mode) {}, diff --git a/src/library_sdl.js b/src/library_sdl.js index 35c619b8..7b413c13 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -173,6 +173,12 @@ mergeInto(LibraryManager.library, { }, createContext: function(useWebGL) { +#if !USE_TYPED_ARRAYS + if (useWebGL) { + Module.print('(USE_TYPED_ARRAYS needs to be enabled for WebGL)'); + return null; + } +#endif try { var ctx = Module.canvas.getContext(useWebGL ? 'experimental-webgl' : '2d'); if (!ctx) throw 'Could not create canvas :('; diff --git a/src/postamble.js b/src/postamble.js index ada13016..390f9f27 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -45,6 +45,10 @@ Module['run'] = run; // {{PRE_RUN_ADDITIONS}} +if (Module['preRun']) { + Module['preRun'](); +} + #if INVOKE_RUN #else Module['noInitialRun'] = true; @@ -59,3 +63,7 @@ if (!Module['noInitialRun']) { // {{POST_RUN_ADDITIONS}} +if (Module['postRun']) { + Module['postRun'](); +} + diff --git a/src/preamble.js b/src/preamble.js index 8dd2c39d..e957c212 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -671,7 +671,7 @@ STATICTOP = alignMemoryPage(STACK_MAX); function callRuntimeCallbacks(callbacks) { while(callbacks.length > 0) { - var callback = callbacks.pop(); + var callback = callbacks.shift(); var func = callback.func; if (typeof func === 'number') { func = FUNCTION_TABLE[func]; diff --git a/tests/cases/gepoverflow.txt b/tests/cases/gepoverflow.txt index 50eaf405..164e5c0c 100644 --- a/tests/cases/gepoverflow.txt +++ b/tests/cases/gepoverflow.txt @@ -1,2 +1,2 @@ -*5246526,5247096* +*5246494,5247064* *-514,56* diff --git a/tests/hello_world_gles_shell.html b/tests/hello_world_gles_shell.html index 7f0b2013..d3429e3a 100644 --- a/tests/hello_world_gles_shell.html +++ b/tests/hello_world_gles_shell.html @@ -25,9 +25,6 @@ canvas: document.getElementById('canvas') }; - // The compiled code - {{{ SCRIPT_CODE }}} - // Test code function simulateKeyEvent(keyCode) { var event = document.createEvent("KeyboardEvent"); @@ -50,6 +47,9 @@ }, 0); } addEventListener("load", doTest, false); + + // The compiled code + {{{ SCRIPT_CODE }}} </script> </body> </html> diff --git a/tests/runner.py b/tests/runner.py index aaa9cf69..23937974 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -3289,13 +3289,16 @@ at function.:blag printf("%f, %f\n", atof("1.234567"), atof("cheez")); + float a = -1; + sscanf("-3.03", "%f", &a); + printf("%.4f\n", a); + return 0; } ''' - self.do_run(src, 'en-us : 2*en-r : 99*en : 3*1.234567, 0.000000', - output_nicerizer = lambda x: x.replace('\n', '*')) + self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n-3.0300') - # Part 2: doubles (issue 148) + # Part 2: doubles if Settings.USE_TYPED_ARRAYS == 2: for ftype in ['float', 'double']: src = r''' @@ -3362,18 +3365,19 @@ Pass: 0.000012 0.000012''') Settings.CORRECT_SIGNS = 1 # Just so our output is what we expect. Can flip them both. post = ''' def process(filename): - src = open(filename, 'r').read().replace('FS.init();', '').replace( # Disable normal initialization, replace with ours - '// {{PRE_RUN_ADDITIONS}}', - \'\'\' - FS.createDataFile('/', 'somefile.binary', [100, 200, 50, 25, 10, 77, 123], true, false); // 200 becomes -56, since signed chars are used in memory - FS.createLazyFile('/', 'test.file', 'test.file', true, false); - var test_files_input = 'hi there!'; - var test_files_input_index = 0; - FS.init(function() { - return test_files_input.charCodeAt(test_files_input_index++) || null; - }); - \'\'\' - ) + src = \'\'\' + var Module = { + 'preRun': function() { + FS.createDataFile('/', 'somefile.binary', [100, 200, 50, 25, 10, 77, 123], true, false); // 200 becomes -56, since signed chars are used in memory + FS.createLazyFile('/', 'test.file', 'test.file', true, false); + var test_files_input = 'hi there!'; + var test_files_input_index = 0; + FS.init(function() { + return test_files_input.charCodeAt(test_files_input_index++) || null; + }); + } + }; + \'\'\' + open(filename, 'r').read() open(filename, 'w').write(src) ''' other = open(os.path.join(self.get_dir(), 'test.file'), 'w') @@ -3612,7 +3616,7 @@ def process(filename): f_blocks: 1000000 f_bfree: 500000 f_bavail: 500000 - f_files: 8 + f_files: 10 f_ffree: 1000000 f_favail: 1000000 f_fsid: 42 @@ -4315,19 +4319,6 @@ def process(filename): Settings.FAST_MEMORY = 4*1024*1024 Settings.EXPORTED_FUNCTIONS = ['_main', '_sqlite3_open', '_sqlite3_close', '_sqlite3_exec', '_sqlite3_free', '_callback']; - Settings.INVOKE_RUN = 0 # We append code that does run() ourselves - - post = ''' -def process(filename): - src = open(filename, 'a') - src.write(\'\'\' - FS.createPath('/', 'dev/shm/tmp', true, true); - FS.currentPath = '/dev/shm/tmp'; - run(); - \'\'\') - src.close() -''' - self.do_run(r''' #define SQLITE_DISABLE_LFS #define LONGDOUBLE_TYPE double @@ -4338,8 +4329,7 @@ def process(filename): open(path_from_root('tests', 'sqlite', 'benchmark.txt'), 'r').read(), includes=[path_from_root('tests', 'sqlite')], force_c=True, - js_engines=[SPIDERMONKEY_ENGINE], # V8 is slow - post_build=post)#,build_ll_hook=self.do_autodebug) + js_engines=[SPIDERMONKEY_ENGINE]) # V8 is slow def test_zlib(self): if self.emcc_args is not None and '-O2' in self.emcc_args: @@ -5658,16 +5648,8 @@ f.close() class TestServerHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(s): assert s.path == expectedResult, 'Expected %s, got %s' % (expectedResult, s.path) - httpd.shutdown() - def handle_timeout(): - assert False, 'Timed out while waiting for the browser test to finish' - httpd.shutdown() httpd = BaseHTTPServer.HTTPServer(('localhost', 8888), TestServerHandler) - httpd.timeout = 5; - server_thread = threading.Thread(target=httpd.serve_forever) - server_thread.daemon = True - server_thread.start() - server_thread.join(5.5) + httpd.handle_request() # Finally, do some web browser tests def run_browser(html_file, message, expectedResult = None): @@ -5720,6 +5702,17 @@ f.close() assert os.path.exists('something.html'), output run_browser('something.html', 'You should see animating gears.', '/report_gl_result?true') + # Make sure that OpenGL ES is not available if typed arrays are not used + clear() + output = Popen([EMCC, path_from_root('tests', 'hello_world_gles.c'), '-o', 'something.html', + '-DHAVE_BUILTIN_SINCOS', + '-s', 'USE_TYPED_ARRAYS=0', + '--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')], + stdout=PIPE, stderr=PIPE).communicate() + assert len(output[0]) == 0, output[0] + assert os.path.exists('something.html'), output + run_browser('something.html', 'You should not see animating gears.', '/report_gl_result?false') + def test_eliminator(self): input = open(path_from_root('tools', 'eliminator', 'eliminator-test.js')).read() expected = open(path_from_root('tools', 'eliminator', 'eliminator-test-output.js')).read() diff --git a/tests/stat/output.txt b/tests/stat/output.txt index b5d66fa5..1e6ae74e 100644 --- a/tests/stat/output.txt +++ b/tests/stat/output.txt @@ -2,7 +2,7 @@ ret: 0 errno: 0 st_dev: 1 -st_ino: 8 +st_ino: 2 st_mode: 040777 st_nlink: 1 st_rdev: 0 @@ -24,7 +24,7 @@ S_ISSOCK: 0 ret: 0 errno: 0 st_dev: 1 -st_ino: 9 +st_ino: 3 st_mode: 0100777 st_nlink: 1 st_rdev: 0 @@ -45,11 +45,11 @@ S_ISSOCK: 0 --stat DEVICE-- ret: 0 errno: 0 -st_dev: 11 -st_ino: 11 +st_dev: 5 +st_ino: 5 st_mode: 020777 st_nlink: 1 -st_rdev: 11 +st_rdev: 5 st_size: 0 st_atime: 1200000000 st_mtime: 1200000000 @@ -68,7 +68,7 @@ S_ISSOCK: 0 ret: 0 errno: 0 st_dev: 1 -st_ino: 9 +st_ino: 3 st_mode: 0100777 st_nlink: 1 st_rdev: 0 @@ -90,7 +90,7 @@ S_ISSOCK: 0 ret: 0 errno: 0 st_dev: 1 -st_ino: 10 +st_ino: 4 st_mode: 0120777 st_nlink: 1 st_rdev: 0 @@ -112,7 +112,7 @@ S_ISSOCK: 0 ret: 0 errno: 0 st_dev: 1 -st_ino: 9 +st_ino: 3 st_mode: 0100777 st_nlink: 1 st_rdev: 0 diff --git a/tools/shared.py b/tools/shared.py index dc84bce3..a0e86156 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -395,7 +395,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)'''.replace('$EMSCRIPTEN_ROOT', path_ if env is None: env = Building.get_building_env() env['EMMAKEN_JUST_CONFIGURE'] = '1' - if args[0].find('cmake') > -1: + if 'cmake' in argv[0]: args = Building.handle_CMake_toolchain(args) Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()[0] del env['EMMAKEN_JUST_CONFIGURE'] |