Skip to content

Commit

Permalink
test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Dec 14, 2012
1 parent bb56dcc commit b4df1e6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
3 changes: 3 additions & 0 deletions test/simple/test-child-process-ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ child.stdout.setEncoding('utf8');
child.stdout.on('data', function(data) {
console.log('child said: ' + JSON.stringify(data));
if (!gotHelloWorld) {
console.error('testing for hello world');
assert.equal('hello world\r\n', data);
gotHelloWorld = true;
console.error('writing echo me');
child.stdin.write('echo me\r\n');
} else {
console.error('testing for echo me');
assert.equal('echo me\r\n', data);
gotEcho = true;
child.stdin.end();
Expand Down
21 changes: 12 additions & 9 deletions test/simple/test-http-header-response-splitting.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var testIndex = 0,
responses = 0;

var server = http.createServer(function(req, res) {
console.error('request', testIndex);
switch (testIndex++) {
case 0:
res.writeHead(200, { test: 'foo \r\ninvalid: bar' });
Expand All @@ -41,6 +42,7 @@ var server = http.createServer(function(req, res) {
res.writeHead(200, { test: 'foo \n\n\ninvalid: bar' });
break;
case 4:
console.error('send request, then close');
res.writeHead(200, { test: 'foo \r\n \r\n \r\ninvalid: bar' });
server.close();
break;
Expand All @@ -49,15 +51,16 @@ var server = http.createServer(function(req, res) {
}
res.end('Hi mars!');
});
server.listen(common.PORT);

for (var i = 0; i < 5; i++) {
var req = http.get({ port: common.PORT, path: '/' }, function(res) {
assert.strictEqual(res.headers.test, 'foo invalid: bar');
assert.strictEqual(res.headers.invalid, undefined);
responses++;
});
}
server.listen(common.PORT, function() {
for (var i = 0; i < 5; i++) {
var req = http.get({ port: common.PORT, path: '/' }, function(res) {
assert.strictEqual(res.headers.test, 'foo invalid: bar');
assert.strictEqual(res.headers.invalid, undefined);
responses++;
res.resume();
});
}
});

process.on('exit', function() {
assert.strictEqual(responses, 5);
Expand Down
15 changes: 13 additions & 2 deletions test/simple/test-tls-pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var received = 0;

var server = tls.Server(options, function(socket) {
socket.pipe(socket);
socket.on('data', function(c) {
console.error('data', c.length);
});
});

server.listen(common.PORT, function() {
Expand All @@ -49,11 +52,16 @@ server.listen(common.PORT, function() {
port: common.PORT,
rejectUnauthorized: false
}, function() {
console.error('connected');
client.pause();
common.debug('paused');
send();
function send() {
if (client.write(new Buffer(bufSize))) {
console.error('sending');
var ret = client.write(new Buffer(bufSize));
console.error('write => %j', ret);
if (false !== ret) {
console.error('write again');
sent += bufSize;
assert.ok(sent < 100 * 1024 * 1024); // max 100MB
return process.nextTick(send);
Expand All @@ -62,12 +70,15 @@ server.listen(common.PORT, function() {
common.debug('sent: ' + sent);
resumed = true;
client.resume();
common.debug('resumed');
console.error('resumed', client);
}
});
client.on('data', function(data) {
console.error('data');
assert.ok(resumed);
received += data.length;
console.error('received', received);
console.error('sent', sent);
if (received >= sent) {
common.debug('received: ' + received);
client.end();
Expand Down

0 comments on commit b4df1e6

Please sign in to comment.