From 7049d7b4746dc5dae82d608ac12dc6e1cf11035e Mon Sep 17 00:00:00 2001 From: Roman Reiss Date: Tue, 7 Apr 2015 20:41:07 +0200 Subject: [PATCH] test: increase timeouts on ARM This commit introduces platform-specific test timeouts for the ARM architectures. ARMv6 is notoriously slow so gets very large timeouts on both the timeout value for each test, as well as certain problematic individual tests. ARMv7 and ARMv8 also get slightly increased headroom. PR-URL: https://github.com/iojs/io.js/pull/1366 Fixes: https://github.com/iojs/io.js/issues/1343 Reviewed-By: Ben Noordhuis --- test/common.js | 10 ++++++++++ test/parallel/test-child-process-fork-net2.js | 11 +++++++---- test/parallel/test-debug-signal-cluster.js | 2 +- test/parallel/test-fs-empty-readStream.js | 4 ++-- test/parallel/test-http-end-throw-socket-handling.js | 2 +- test/parallel/test-repl-timeout-throw.js | 2 +- test/parallel/test-tls-fast-writing.js | 2 +- test/parallel/test-tls-wrap-timeout.js | 4 +++- test/sequential/test-force-repl.js | 2 +- test/sequential/test-net-GH-5504.js | 2 +- tools/test.py | 5 +++-- tools/utils.py | 4 +++- 12 files changed, 34 insertions(+), 16 deletions(-) diff --git a/test/common.js b/test/common.js index 1ef491e4033..1e85d3db33b 100644 --- a/test/common.js +++ b/test/common.js @@ -179,6 +179,16 @@ exports.spawnPwd = function(options) { } }; +exports.platformTimeout = function(ms) { + if (process.arch !== 'arm') + return ms; + + if (process.config.variables.arm_version === '6') + return 6 * ms; // ARMv6 + + return 2 * ms; // ARMv7 and up. +}; + var knownGlobals = [setTimeout, setInterval, setImmediate, diff --git a/test/parallel/test-child-process-fork-net2.js b/test/parallel/test-child-process-fork-net2.js index 171abb729a4..c69fe84eadd 100644 --- a/test/parallel/test-child-process-fork-net2.js +++ b/test/parallel/test-child-process-fork-net2.js @@ -128,13 +128,13 @@ if (process.argv[2] === 'child') { server.listen(common.PORT, '127.0.0.1'); - var timeElasped = 0; + var timeElapsed = 0; var closeServer = function() { console.error('[m] closeServer'); var startTime = Date.now(); server.on('close', function() { console.error('[m] emit(close)'); - timeElasped = Date.now() - startTime; + timeElapsed = Date.now() - startTime; }); console.error('[m] calling server.close'); @@ -149,11 +149,14 @@ if (process.argv[2] === 'child') { }, 200); }; + var min = 190; + var max = common.platformTimeout(1500); process.on('exit', function() { assert.equal(disconnected, count); assert.equal(connected, count); assert.ok(closeEmitted); - assert.ok(timeElasped >= 190 && timeElasped <= 1000, - 'timeElasped was not between 190 and 1000 ms'); + assert.ok(timeElapsed >= min && timeElapsed <= max, + `timeElapsed was not between ${min} and ${max} ms:` + + `${timeElapsed}`); }); } diff --git a/test/parallel/test-debug-signal-cluster.js b/test/parallel/test-debug-signal-cluster.js index 026e2932622..c8b03875908 100644 --- a/test/parallel/test-debug-signal-cluster.js +++ b/test/parallel/test-debug-signal-cluster.js @@ -51,7 +51,7 @@ function onNoMoreLines() { setTimeout(function testTimedOut() { assert(false, 'test timed out.'); -}, 6000).unref(); +}, common.platformTimeout(3000)).unref(); process.on('exit', function onExit() { // Kill processes in reverse order to avoid timing problems on Windows where diff --git a/test/parallel/test-fs-empty-readStream.js b/test/parallel/test-fs-empty-readStream.js index bd6e1912977..0c470076da7 100644 --- a/test/parallel/test-fs-empty-readStream.js +++ b/test/parallel/test-fs-empty-readStream.js @@ -22,7 +22,7 @@ fs.open(emptyFile, 'r', function (error, fd) { setTimeout(function () { assert.equal(readEmit, true); - }, 50); + }, common.platformTimeout(50)); }); fs.open(emptyFile, 'r', function (error, fd) { @@ -43,5 +43,5 @@ fs.open(emptyFile, 'r', function (error, fd) { setTimeout(function () { assert.equal(readEmit, false); - }, 50); + }, common.platformTimeout(50)); }); diff --git a/test/parallel/test-http-end-throw-socket-handling.js b/test/parallel/test-http-end-throw-socket-handling.js index a8566beac8c..92a5ae6a38d 100644 --- a/test/parallel/test-http-end-throw-socket-handling.js +++ b/test/parallel/test-http-end-throw-socket-handling.js @@ -32,7 +32,7 @@ server.listen(common.PORT, function() { setTimeout(function() { process.removeListener('uncaughtException', catcher); throw new Error('Taking too long!'); -}, 1000).unref(); +}, common.platformTimeout(1000)).unref(); process.on('uncaughtException', catcher); var errors = 0; diff --git a/test/parallel/test-repl-timeout-throw.js b/test/parallel/test-repl-timeout-throw.js index f1713413451..eea2bea3ac9 100644 --- a/test/parallel/test-repl-timeout-throw.js +++ b/test/parallel/test-repl-timeout-throw.js @@ -44,7 +44,7 @@ child.stdout.once('data', function() { ' });\n' + '});"";\n'); - setTimeout(child.stdin.end.bind(child.stdin), 200); + setTimeout(child.stdin.end.bind(child.stdin), common.platformTimeout(200)); } }); diff --git a/test/parallel/test-tls-fast-writing.js b/test/parallel/test-tls-fast-writing.js index 7fd3c8f9dcd..e9245aa0d5e 100644 --- a/test/parallel/test-tls-fast-writing.js +++ b/test/parallel/test-tls-fast-writing.js @@ -22,7 +22,7 @@ var gotDrain = false; var timer = setTimeout(function() { console.log('not ok - timed out'); process.exit(1); -}, 500); +}, common.platformTimeout(500)); function onconnection(conn) { conn.on('data', function(c) { diff --git a/test/parallel/test-tls-wrap-timeout.js b/test/parallel/test-tls-wrap-timeout.js index 7bb5bb1b0df..3013f688865 100644 --- a/test/parallel/test-tls-wrap-timeout.js +++ b/test/parallel/test-tls-wrap-timeout.js @@ -27,7 +27,9 @@ var server = tls.createServer(options, function(c) { server.listen(common.PORT, function() { var socket = net.connect(common.PORT, function() { - socket.setTimeout(240, assert.fail); + socket.setTimeout(common.platformTimeout(240), function() { + throw new Error('timeout'); + }); var tsocket = tls.connect({ socket: socket, diff --git a/test/sequential/test-force-repl.js b/test/sequential/test-force-repl.js index fa17297ad25..c0ad1484ff2 100644 --- a/test/sequential/test-force-repl.js +++ b/test/sequential/test-force-repl.js @@ -7,7 +7,7 @@ var cp = spawn(process.execPath, ['-i']); var gotToEnd = false; var timeoutId = setTimeout(function() { throw new Error('timeout!'); -}, 1000); // give node + the repl 1 second to boot up +}, common.platformTimeout(1000)); // give node + the repl 1 second to boot up cp.stdout.setEncoding('utf8'); diff --git a/test/sequential/test-net-GH-5504.js b/test/sequential/test-net-GH-5504.js index ef2e1ceb29b..2ee0a1d86d7 100644 --- a/test/sequential/test-net-GH-5504.js +++ b/test/sequential/test-net-GH-5504.js @@ -72,7 +72,7 @@ function parent() { setTimeout(function() { throw new Error('hang'); }); - }, 4000).unref(); + }, common.platformTimeout(2000)).unref(); var s = spawn(node, [__filename, 'server'], opt); var c; diff --git a/tools/test.py b/tools/test.py index efb2ed7f3ce..1de2661dc3a 100755 --- a/tools/test.py +++ b/tools/test.py @@ -729,8 +729,9 @@ FLAGS = { 'debug' : ['--enable-slow-asserts', '--debug-code', '--verify-heap'], 'release' : []} TIMEOUT_SCALEFACTOR = { - 'arm' : { 'debug' : 8, 'release' : 2 }, # The ARM buildbots are slow. - 'ia32' : { 'debug' : 4, 'release' : 1 } } + 'armv6' : { 'debug' : 12, 'release' : 3 }, # The ARM buildbots are slow. + 'arm' : { 'debug' : 8, 'release' : 2 }, + 'ia32' : { 'debug' : 4, 'release' : 1 } } class Context(object): diff --git a/tools/utils.py b/tools/utils.py index 2b312a2e103..03c56aefb85 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -73,7 +73,9 @@ def GuessOS(): def GuessArchitecture(): id = platform.machine() id = id.lower() # Windows 7 capitalizes 'AMD64'. - if id.startswith('arm') or id == 'aarch64': + if id.startswith('armv6'): # Can return 'armv6l'. + return 'armv6' + elif id.startswith('arm') or id == 'aarch64': return 'arm' elif (not id) or (not re.match('(x|i[3-6])86$', id) is None): return 'ia32'