diff --git a/test/simple/test-child-process-fork-getconnections.js b/test/simple/test-child-process-fork-getconnections.js index 597c23fd2b7..f8fed6884f5 100644 --- a/test/simple/test-child-process-fork-getconnections.js +++ b/test/simple/test-child-process-fork-getconnections.js @@ -36,7 +36,7 @@ if (process.argv[2] === 'child') { sockets.push(socket); socket.on('end', function() { if (!this.closingOnPurpose) - throw new Error('[c] closing by accident! ' + process._errno); + throw new Error('[c] closing by accident!'); }); } diff --git a/test/simple/test-child-process-kill-throw.js b/test/simple/test-child-process-kill-throw.js deleted file mode 100644 index 4beba7e7a21..00000000000 --- a/test/simple/test-child-process-kill-throw.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var common = require('../common'); -var assert = require('assert'); - -if (process.argv[2] === 'child') { - process.exit(0); -} else { - var spawn = require('child_process').spawn; - var child = spawn(process.execPath, [process.argv[1], 'child']); - - var error = {}; - child.on('exit', function() { - child._handle = { - kill: function() { - process._errno = 42; - return -1; - } - }; - child.once('error', function(err) { - error = err; - }); - child.kill(); - }); - - process.on('exit', function() { - // we shouldn't reset errno since it accturlly isn't set - // because of the fake .kill method - assert.equal(error.syscall, 'kill'); - }); -} diff --git a/test/simple/test-process-wrap.js b/test/simple/test-process-wrap.js index 655c8281586..d07c3adf887 100644 --- a/test/simple/test-process-wrap.js +++ b/test/simple/test-process-wrap.js @@ -44,7 +44,7 @@ p.onexit = function(exitCode, signal) { processExited = true; }; -pipe.onread = function(b, off, len) { +pipe.onread = function(err, b, off, len) { assert.ok(processExited); if (b) { gotPipeData = true; diff --git a/test/simple/test-stream2-stderr-sync.js b/test/simple/test-stream2-stderr-sync.js index 2b83617e9da..efcb50546ae 100644 --- a/test/simple/test-stream2-stderr-sync.js +++ b/test/simple/test-stream2-stderr-sync.js @@ -23,6 +23,9 @@ var common = require('../common.js'); var assert = require('assert'); +var util = require('util'); + +var errnoException = util._errnoException; function parent() { var spawn = require('child_process').spawn; @@ -62,11 +65,12 @@ function child0() { } W.prototype._write = function(chunk, encoding, cb) { - var req = handle.writeUtf8String(chunk.toString() + '\n'); + var req = { oncomplete: afterWrite }; + var err = handle.writeUtf8String(req, chunk.toString() + '\n'); + if (err) throw errnoException(err, 'write'); // here's the problem. // it needs to tell the Writable machinery that it's ok to write // more, but that the current buffer length is handle.writeQueueSize - req.oncomplete = afterWrite if (req.writeQueueSize === 0) req.cb = cb; else diff --git a/test/simple/test-tcp-wrap-connect.js b/test/simple/test-tcp-wrap-connect.js index 3da8d932e17..43fb37ac701 100644 --- a/test/simple/test-tcp-wrap-connect.js +++ b/test/simple/test-tcp-wrap-connect.js @@ -26,14 +26,20 @@ var TCP = process.binding('tcp_wrap').TCP; function makeConnection() { var client = new TCP(); - var req = client.connect('127.0.0.1', common.PORT); + var req = {}; + var err = client.connect(req, '127.0.0.1', common.PORT); + assert.equal(err, 0); + req.oncomplete = function(status, client_, req_) { assert.equal(0, status); assert.equal(client, client_); assert.equal(req, req_); console.log('connected'); - var shutdownReq = client.shutdown(); + var shutdownReq = {}; + var err = client.shutdown(shutdownReq); + assert.equal(err, 0); + shutdownReq.oncomplete = function(status, client_, req_) { console.log('shutdown complete'); assert.equal(0, status); diff --git a/test/simple/test-tcp-wrap-listen.js b/test/simple/test-tcp-wrap-listen.js index 6b805f3a6b1..1a3dc12ee98 100644 --- a/test/simple/test-tcp-wrap-listen.js +++ b/test/simple/test-tcp-wrap-listen.js @@ -36,7 +36,7 @@ var slice, sliceCount = 0, eofCount = 0; var writeCount = 0; var recvCount = 0; -server.onconnection = function(client) { +server.onconnection = function(err, client) { assert.equal(0, client.writeQueueSize); console.log('got connection'); @@ -49,13 +49,15 @@ server.onconnection = function(client) { client.readStart(); client.pendingWrites = []; - client.onread = function(buffer) { + client.onread = function(err, buffer) { if (buffer) { assert.ok(buffer.length > 0); assert.equal(0, client.writeQueueSize); - var req = client.writeBuffer(buffer); + var req = {}; + var err = client.writeBuffer(req, buffer); + assert.equal(err, 0); client.pendingWrites.push(req); console.log('client.writeQueueSize: ' + client.writeQueueSize); @@ -112,5 +114,3 @@ process.on('exit', function() { assert.equal(1, writeCount); assert.equal(1, recvCount); }); - - diff --git a/test/simple/test-tcp-wrap.js b/test/simple/test-tcp-wrap.js index 10f7038c831..bc1e14e68a4 100644 --- a/test/simple/test-tcp-wrap.js +++ b/test/simple/test-tcp-wrap.js @@ -23,17 +23,16 @@ var common = require('../common'); var assert = require('assert'); var TCP = process.binding('tcp_wrap').TCP; +var uv = process.binding('uv'); var handle = new TCP(); // Should be able to bind to the common.PORT -var r = handle.bind('0.0.0.0', common.PORT); -assert.equal(0, r); +var err = handle.bind('0.0.0.0', common.PORT); +assert.equal(err, 0); // Should not be able to bind to the same port again -var r = handle.bind('0.0.0.0', common.PORT); -assert.equal(-1, r); -console.log(process._errno); -assert.equal(process._errno, 'EINVAL'); +err = handle.bind('0.0.0.0', common.PORT); +assert.equal(err, uv.UV_EINVAL); handle.close();