Restore disabled tests: test_mem_init and test_mem_init_request (#14828)
This commit is contained in:
Родитель
3d3dff7ce8
Коммит
429063d417
|
@ -1535,7 +1535,8 @@ class BrowserCore(RunnerCore):
|
|||
assert expected or reference, 'a btest must either expect an output, or have a reference image'
|
||||
if args is None:
|
||||
args = []
|
||||
original_args = args.copy()
|
||||
original_args = args
|
||||
args = args.copy()
|
||||
if not os.path.exists(filename):
|
||||
filename = test_file(filename)
|
||||
if reference:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// University of Illinois/NCSA Open Source License. Both these licenses can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <emscripten.h>
|
||||
|
||||
|
@ -14,9 +15,6 @@ const char* EMSCRIPTEN_KEEPALIVE note(int n) {
|
|||
EM_ASM({ out([$0, $1]) }, n, noted);
|
||||
noted = noted | n;
|
||||
EM_ASM({ out(['noted is now', $0]) }, noted);
|
||||
if (noted == 3) {
|
||||
MAYBE_REPORT_RESULT(noted);
|
||||
}
|
||||
return "silly-string";
|
||||
}
|
||||
|
||||
|
@ -24,6 +22,7 @@ const char* EMSCRIPTEN_KEEPALIVE note(int n) {
|
|||
|
||||
int main() {
|
||||
EM_ASM( myJSCallback() ); // calls a global JS func
|
||||
assert(noted == 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,22 +3,21 @@
|
|||
// University of Illinois/NCSA Open Source License. Both these licenses can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
const char *hello = "hello world";
|
||||
int result = 1;
|
||||
putc('g', stdout);
|
||||
putc('o', stdout);
|
||||
putc('!', stdout);
|
||||
if (strchr(hello, 'l') != hello + 2) result = 0;
|
||||
if (strchr(hello, 'w') != hello + 6) result = 0;
|
||||
assert(strchr(hello, 'l') == hello + 2);
|
||||
assert(strchr(hello, 'w') == hello + 6);
|
||||
putc('d', stdout);
|
||||
putc('o', stdout);
|
||||
putc('n', stdout);
|
||||
putc('e', stdout);
|
||||
REPORT_RESULT(result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -2281,8 +2281,8 @@ void *getBindBuffer() {
|
|||
for mem in [0, 1]:
|
||||
self.btest('pre_run_deps.cpp', expected='10', args=['--pre-js', 'pre.js', '--memory-init-file', str(mem)])
|
||||
|
||||
@no_wasm_backend('mem init file')
|
||||
def test_mem_init(self):
|
||||
self.set_setting('WASM_ASYNC_COMPILATION', 0)
|
||||
create_file('pre.js', '''
|
||||
function myJSCallback() { // called from main()
|
||||
Module._note(1);
|
||||
|
@ -2294,21 +2294,17 @@ void *getBindBuffer() {
|
|||
};
|
||||
''')
|
||||
create_file('post.js', '''
|
||||
var assert = function(check, text) {
|
||||
if (!check) {
|
||||
console.log('assert failed: ' + text);
|
||||
maybeReportResultToServer(9);
|
||||
}
|
||||
}
|
||||
Module._note(4); // this happens too early! and is overwritten when the mem init arrives
|
||||
''')
|
||||
|
||||
# with assertions, we notice when memory was written to too early
|
||||
self.btest('mem_init.cpp', expected='9', args=['-s', 'WASM=0', '--pre-js', 'pre.js', '--post-js', 'post.js', '--memory-init-file', '1'])
|
||||
# otherwise, we just overwrite
|
||||
self.btest('mem_init.cpp', expected='3', args=['-s', 'WASM=0', '--pre-js', 'pre.js', '--post-js', 'post.js', '--memory-init-file', '1', '-s', 'ASSERTIONS=0'])
|
||||
args = ['-s', 'WASM=0', '--pre-js', 'pre.js', '--post-js', 'post.js', '--memory-init-file', '1']
|
||||
|
||||
# with assertions, we notice when memory was written to too early
|
||||
expected = 'abort:Assertion failed: native function `note` called before runtime initialization'
|
||||
self.btest('mem_init.cpp', expected=expected, args=args)
|
||||
# otherwise, we just overwrite
|
||||
self.btest_exit('mem_init.cpp', args=args + ['-s', 'ASSERTIONS=0'])
|
||||
|
||||
@no_wasm_backend('mem init file')
|
||||
def test_mem_init_request(self):
|
||||
def test(what, status):
|
||||
print(what, status)
|
||||
|
@ -2320,22 +2316,16 @@ void *getBindBuffer() {
|
|||
|
||||
console.warn = function(x) {
|
||||
if (x.indexOf('a problem seems to have happened with Module.memoryInitializerRequest') >= 0) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'http://localhost:%s/report_result?0');
|
||||
setTimeout(xhr.onload = function() {
|
||||
console.log('close!');
|
||||
window.close();
|
||||
}, 1000);
|
||||
xhr.send();
|
||||
throw 'halt';
|
||||
maybeReportResultToServer('got_error');
|
||||
}
|
||||
console.log('WARNING: ' + x);
|
||||
};
|
||||
''' % self.port)
|
||||
''')
|
||||
self.btest('mem_init_request.cpp', expected=status, args=['-s', 'WASM=0', '--pre-js', 'pre.js', '--memory-init-file', '1'])
|
||||
|
||||
test('test.html.mem', '1')
|
||||
test('nothing.nowhere', '0')
|
||||
self.set_setting('EXIT_RUNTIME')
|
||||
test('test.html.mem', 'exit:0')
|
||||
test('nothing.nowhere', 'got_error')
|
||||
|
||||
def test_runtime_misuse(self):
|
||||
post_prep = '''
|
||||
|
|
Загрузка…
Ссылка в новой задаче