From 3b0f2cecffb9b4a8be63185394064adb989d5ac8 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 9 Aug 2011 17:43:57 -0700 Subject: [PATCH] Fix dd command tests for Windows --- test/common.js | 11 +++++++++++ test/simple/test-http-curl-chunk-problem.js | 12 +++++++----- test/simple/test-pipe-file-to-http.js | 4 +++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/test/common.js b/test/common.js index 45a11b392f7..aea21b2cc2e 100644 --- a/test/common.js +++ b/test/common.js @@ -52,6 +52,17 @@ exports.indirectInstanceOf = function(obj, cls) { }; +exports.ddCommand = function(filename, kilobytes) { + if (process.platform == 'win32') { + return 'fsutil.exe file createnew "' + filename + '" ' + (kilobytes * 1024); + } else { + var blocks = Integer(size / 1024); + return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes; + } +}; + + + // Turn this off if the test should not check for global leaks. exports.globalCheck = true; diff --git a/test/simple/test-http-curl-chunk-problem.js b/test/simple/test-http-curl-chunk-problem.js index 409c769def2..d9ec9ab319d 100644 --- a/test/simple/test-http-curl-chunk-problem.js +++ b/test/simple/test-http-curl-chunk-problem.js @@ -55,11 +55,13 @@ function maybeMakeRequest() { } -cp.exec('dd if=/dev/zero of="' + filename + '" bs=1024 count=10240', - function(err, stdout, stderr) { - if (err) throw err; - maybeMakeRequest(); - }); +var ddcmd = common.ddCommand(filename, 10240); +console.log("dd command: ", ddcmd); + +cp.exec(ddcmd, function(err, stdout, stderr) { + if (err) throw err; + maybeMakeRequest(); +}); var server = http.createServer(function(req, res) { diff --git a/test/simple/test-pipe-file-to-http.js b/test/simple/test-pipe-file-to-http.js index d43eb7f7f7e..ed932336136 100644 --- a/test/simple/test-pipe-file-to-http.js +++ b/test/simple/test-pipe-file-to-http.js @@ -58,7 +58,9 @@ var server = http.createServer(function(req, res) { server.listen(common.PORT); server.on('listening', function() { - var cmd = 'dd if=/dev/zero of="' + filename + '" bs=1024 count=10240'; + var cmd = common.ddCommand(filename, 10240); + console.log("dd command: ", cmd); + cp.exec(cmd, function(err, stdout, stderr) { if (err) throw err; makeRequest();