Fix a bunch more tests to run in STRICT mode (#11124)

Tested with `./tests/runner.py strict`.  There are still a few
that need more work but this covers the low hanging fruit.
This commit is contained in:
Sam Clegg 2020-05-12 15:25:43 -04:00 коммит произвёл GitHub
Родитель d262c2a6c5
Коммит cccf9bf536
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 27 добавлений и 24 удалений

Просмотреть файл

@ -196,7 +196,7 @@ if (ENVIRONMENT_IS_NODE) {
console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?');
throw e;
}
Worker = nodeWorkerThreads.Worker;
global.Worker = nodeWorkerThreads.Worker;
#endif
#if WASM == 2
@ -337,7 +337,7 @@ if (ENVIRONMENT_IS_NODE) {
// Polyfill the performance object, which emscripten pthreads support
// depends on for good timing.
if (typeof performance === 'undefined') {
performance = require('perf_hooks').performance;
global.performance = require('perf_hooks').performance;
}
}
#endif

Просмотреть файл

@ -307,7 +307,7 @@ if (typeof process === 'object' && typeof process.versions === 'object' && typeo
var nodeWorkerThreads = require('worker_threads');
Worker = nodeWorkerThreads.Worker;
global.Worker = nodeWorkerThreads.Worker;
var parentPort = nodeWorkerThreads.parentPort;

Просмотреть файл

@ -10,9 +10,9 @@
#include <emscripten.h>
int main() {
printf("QS: %d\n", emscripten_get_compiler_setting("QUANTUM_SIZE"));
printf("EXIT_RUNTIME: %d\n", emscripten_get_compiler_setting("EXIT_RUNTIME"));
assert((unsigned)emscripten_get_compiler_setting("OPT_LEVEL") <= 3);
assert((unsigned)emscripten_get_compiler_setting("DEBUG_LEVEL") <= 4);
printf("EV: %s\n", (char*)emscripten_get_compiler_setting("EMSCRIPTEN_VERSION"));
printf("EMSCRIPTEN_VERSION: %s\n", (char*)emscripten_get_compiler_setting("EMSCRIPTEN_VERSION"));
}

Просмотреть файл

@ -1,2 +1,2 @@
QS: 4
EV: waka
EXIT_RUNTIME: 0
EMSCRIPTEN_VERSION: waka

Просмотреть файл

@ -13,7 +13,7 @@ int main() {
printf("%d %d %d %d %s\n", c[0] & 0xff, c[1] & 0xff, c[2] & 0xff, c[3] & 0xff,
c);
emscripten_run_script(
"cheez = _malloc(100);"
"var cheez = _malloc(100);"
"Module.stringToUTF8(\"μ†ℱ ╋ℯ╳╋ 😇\", cheez, 100);"
"out([UTF8ToString(cheez), Module.getValue(cheez, "
"'i8')&0xff, Module.getValue(cheez+1, 'i8')&0xff, "

Просмотреть файл

@ -1,7 +1,7 @@
var dummy_device = FS.makedev(64, 0);
FS.registerDevice(dummy_device, {});
FS.mkdir('/forbidden', 0000);
FS.mkdir('/forbidden', 0o000);
FS.mkdir('/forbidden/test');
FS.mkdir('/abc');
FS.mkdir('/abc/123');

Просмотреть файл

@ -12,7 +12,7 @@ int main()
EM_ASM(
FS.writeFile('testfile', 'a=1\nb=2\n');
var stream = FS.open('testfile', 'a');
fd = FS.write(stream, new Uint8Array([99, 61, 51]) /* c=3 */, 0, 3);
var fd = FS.write(stream, new Uint8Array([99, 61, 51]) /* c=3 */, 0, 3);
// check invalid whence
var ex;

1
tests/runner.py поставляемый
Просмотреть файл

@ -244,6 +244,7 @@ core_test_modes = [
'wasm3',
'wasms',
'wasmz',
'strict'
]
if shared.Settings.WASM_BACKEND:

8
tests/test_core.py поставляемый
Просмотреть файл

@ -8817,6 +8817,8 @@ NODEFS is no longer included by default; build with -lnodefs.js
def test_undefined_main(self):
if self.get_setting('LLD_REPORT_UNDEFINED'):
self.skipTest('LLD_REPORT_UNDEFINED does not allow implicit undefined main')
if self.get_setting('STRICT'):
self.skipTest('STRICT does not allow implicit undefined main')
# By default in emscripten we allow main to be undefined. Its used when
# building library code that has no main.
# TODO(sbc): Simplify the code by making this an opt-in feature.
@ -8868,7 +8870,7 @@ NODEFS is no longer included by default; build with -lnodefs.js
self.do_run_in_out_file_test('tests', 'core', 'test_get_exported_function')
def test_auto_detect_main(self):
if not self.get_setting('LLD_REPORT_UNDEFINED'):
if not self.get_setting('LLD_REPORT_UNDEFINED') and not self.get_setting('STRICT'):
self.do_run_in_out_file_test('tests', 'core', 'test_ctors_no_main')
# Disabling IGNORE_MISSING_MAIN should cause link to fail due to missing main
@ -8975,7 +8977,8 @@ asm2nn = make_run('asm2nn', emcc_args=['-O2'], settings={'WASM': 0}, env={'EMCC_
# wasm
wasm2s = make_run('wasm2s', emcc_args=['-O2'], settings={'SAFE_HEAP': 1})
wasm2ss = make_run('wasm2ss', emcc_args=['-O2'], settings={'STACK_OVERFLOW_CHECK': 2})
strict = make_run('strict', emcc_args=['-O2'], settings={'DEFAULT_TO_CXX': 0})
# Add DEFAULT_TO_CXX=0
strict = make_run('strict', emcc_args=[], settings={'STRICT': 1})
if not shared.Settings.WASM_BACKEND:
# emterpreter
@ -8989,7 +8992,6 @@ if shared.Settings.WASM_BACKEND:
# Experimental modes (not tested by CI)
lld = make_run('lld', emcc_args=[], settings={'LLD_REPORT_UNDEFINED': 1})
strict = make_run('strict', emcc_args=[], settings={'STRICT': 1})
# TestCoreBase is just a shape for the specific subclasses, we don't test it itself
del TestCoreBase # noqa

Просмотреть файл

@ -27,10 +27,10 @@ int main() {
FS.mount(NODEFS, { root: '.' }, 'working');
#endif
FS.chdir('working');
FS.writeFile('forbidden', ''); FS.chmod('forbidden', 0000);
FS.writeFile('readable', ''); FS.chmod('readable', 0444);
FS.writeFile('writeable', ''); FS.chmod('writeable', 0222);
FS.writeFile('allaccess', ''); FS.chmod('allaccess', 0777);
FS.writeFile('forbidden', ''); FS.chmod('forbidden', 0o000);
FS.writeFile('readable', ''); FS.chmod('readable', 0o444);
FS.writeFile('writeable', ''); FS.chmod('writeable', 0o222);
FS.writeFile('allaccess', ''); FS.chmod('allaccess', 0o777);
);
#endif
// Empty path checks #9136 fix
@ -68,10 +68,10 @@ int main() {
// won't have problems on deleting the files. On Windows, calling shutil.rmtree()
// will fail if any of the files are read-only.
EM_ASM(
FS.chmod('forbidden', 0777);
FS.chmod('readable', 0777);
FS.chmod('writeable', 0777);
FS.chmod('allaccess', 0777);
FS.chmod('forbidden', 0o777);
FS.chmod('readable', 0o777);
FS.chmod('writeable', 0o777);
FS.chmod('allaccess', 0o777);
);
#endif

Просмотреть файл

@ -19,7 +19,7 @@ int main() {
FS.mkdir('/folder');
FS.symlink('/folder', '/link');
FS.writeFile('/file', '', { mode: 0777 });
FS.writeFile('/file', '', { mode: 0o777 });
);
char buffer[256];

Просмотреть файл

@ -22,7 +22,7 @@ int main() {
FS.chdir('working');
FS.writeFile('towrite', 'abcdef');
FS.writeFile('toread', 'abcdef');
FS.chmod('toread', 0444);
FS.chmod('toread', 0o444);
);
struct stat s;
@ -87,7 +87,7 @@ int main() {
// won't have problems on deleting the files. On Windows, calling shutil.rmtree()
// will fail if any of the files are read-only.
EM_ASM(
FS.chmod('toread', 0777);
FS.chmod('toread', 0o777);
);
return 0;
}