Browse Source

test updates

v0.9.4-release
isaacs 12 years ago
parent
commit
b4df1e62de
  1. 3
      test/simple/test-child-process-ipc.js
  2. 21
      test/simple/test-http-header-response-splitting.js
  3. 15
      test/simple/test-tls-pause.js

3
test/simple/test-child-process-ipc.js

@ -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();

21
test/simple/test-http-header-response-splitting.js

@ -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' });
@ -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;
@ -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);

15
test/simple/test-tls-pause.js

@ -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() {
@ -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);
@ -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();

Loading…
Cancel
Save