summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck.py57
-rw-r--r--src/support/threads.cpp9
2 files changed, 42 insertions, 24 deletions
diff --git a/check.py b/check.py
index e0d569373..1cadd2386 100755
--- a/check.py
+++ b/check.py
@@ -471,31 +471,42 @@ def run_validator_tests():
def run_torture_tests():
print '\n[ checking torture testcases... ]\n'
- unexpected_result_count = 0
+ # torture tests are parallel anyhow, don't create multiple threads in each child
+ old_cores = os.environ.get('BINARYEN_CORES')
+ try:
+ os.environ['BINARYEN_CORES'] = '1'
+
+ unexpected_result_count = 0
+
+ import test.waterfall.src.link_assembly_files as link_assembly_files
+ s2wasm_torture_out = os.path.abspath(os.path.join(options.binaryen_test, 's2wasm-torture-out'))
+ if os.path.isdir(s2wasm_torture_out):
+ shutil.rmtree(s2wasm_torture_out)
+ os.mkdir(s2wasm_torture_out)
+ unexpected_result_count += link_assembly_files.run(
+ linker=os.path.abspath(S2WASM_EXE),
+ files=os.path.abspath(os.path.join(options.binaryen_test, 'torture-s', '*.s')),
+ fails=os.path.abspath(os.path.join(options.binaryen_test, 's2wasm_known_gcc_test_failures.txt')),
+ out=s2wasm_torture_out)
+ assert os.path.isdir(s2wasm_torture_out), 'Expected output directory %s' % s2wasm_torture_out
+
+ import test.waterfall.src.execute_files as execute_files
+ unexpected_result_count += execute_files.run(
+ runner=os.path.abspath(WASM_SHELL_EXE),
+ files=os.path.abspath(os.path.join(s2wasm_torture_out, '*.wast')),
+ fails=os.path.abspath(os.path.join(options.binaryen_test, 's2wasm_known_binaryen_shell_test_failures.txt')),
+ out='',
+ wasmjs='')
- import test.waterfall.src.link_assembly_files as link_assembly_files
- s2wasm_torture_out = os.path.abspath(os.path.join(options.binaryen_test, 's2wasm-torture-out'))
- if os.path.isdir(s2wasm_torture_out):
shutil.rmtree(s2wasm_torture_out)
- os.mkdir(s2wasm_torture_out)
- unexpected_result_count += link_assembly_files.run(
- linker=os.path.abspath(S2WASM_EXE),
- files=os.path.abspath(os.path.join(options.binaryen_test, 'torture-s', '*.s')),
- fails=os.path.abspath(os.path.join(options.binaryen_test, 's2wasm_known_gcc_test_failures.txt')),
- out=s2wasm_torture_out)
- assert os.path.isdir(s2wasm_torture_out), 'Expected output directory %s' % s2wasm_torture_out
-
- import test.waterfall.src.execute_files as execute_files
- unexpected_result_count += execute_files.run(
- runner=os.path.abspath(WASM_SHELL_EXE),
- files=os.path.abspath(os.path.join(s2wasm_torture_out, '*.wast')),
- fails=os.path.abspath(os.path.join(options.binaryen_test, 's2wasm_known_binaryen_shell_test_failures.txt')),
- out='',
- wasmjs='')
-
- shutil.rmtree(s2wasm_torture_out)
- if unexpected_result_count:
- fail('%s failures' % unexpected_result_count, '0 failures')
+ if unexpected_result_count:
+ fail('%s failures' % unexpected_result_count, '0 failures')
+
+ finally:
+ if old_cores:
+ os.environ['BINARYEN_CORES'] = old_cores
+ else:
+ del os.environ['BINARYEN_CORES']
def run_vanilla_tests():
print '\n[ checking emcc WASM_BACKEND testcases...]\n'
diff --git a/src/support/threads.cpp b/src/support/threads.cpp
index 3e32ffb15..31c900ceb 100644
--- a/src/support/threads.cpp
+++ b/src/support/threads.cpp
@@ -111,7 +111,14 @@ void ThreadPool::initialize(size_t num) {
ready.store(threads.size()); // initial state before first resetThreadsAreReady()
resetThreadsAreReady();
for (size_t i = 0; i < num; i++) {
- threads.emplace_back(make_unique<Thread>());
+ try {
+ threads.emplace_back(make_unique<Thread>());
+ } catch (std::system_error&) {
+ // failed to create a thread - don't use multithreading, as if num cores == 1
+ DEBUG_POOL("could not create thread\n");
+ threads.clear();
+ return;
+ }
}
DEBUG_POOL("initialize() waiting\n");
condition.wait(lock, [this]() { return areThreadsReady(); });