Permalink
Browse files

Squash for test-os.js fix

  • Loading branch information...
1 parent fee02db commit 74b60fab8fbc99f34d460b620ff193931f23ca01 Kevin Jones committed Jun 20, 2012
Showing with 16 additions and 15 deletions.
  1. +16 −15 test/simple/test-os.js
@@ -30,7 +30,7 @@ var os = require('os');
process.env.TMPDIR = '/tmpdir';
process.env.TMP = '/tmp';
process.env.TEMP = '/temp';
-var t = ( process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp' );
+var t = (process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp');
assert.equal(os.tmpDir(), '/tmpdir');
process.env.TMPDIR = '';
assert.equal(os.tmpDir(), '/tmp');
@@ -74,23 +74,24 @@ if (process.platform != 'sunos') {
assert.ok(os.totalmem() > 0);
}
-
+// Check at least 1 IPv4 loopback exists & all have correct details
var interfaces = os.networkInterfaces();
console.error(interfaces);
-switch (platform) {
- case 'linux':
- var filter = function(e) { return e.address == '127.0.0.1'; };
- var actual = interfaces.lo.filter(filter);
- var expected = [{ address: '127.0.0.1', family: 'IPv4', internal: true }];
- assert.deepEqual(actual, expected);
- break;
- case 'win32':
- var filter = function(e) { return e.address == '127.0.0.1'; };
- var actual = interfaces['Loopback Pseudo-Interface 1'].filter(filter);
- var expected = [{ address: '127.0.0.1', family: 'IPv4', internal: true }];
- assert.deepEqual(actual, expected);
- break;
+
+var expected = { address: '127.0.0.1', family: 'IPv4', internal: true };
+var found = false;
+for (var iname in interfaces) {
+ var inter = interfaces[iname];
+
+ var addrs = inter.length;
+ for (var a = 0; a < addrs; a++) {
+ if (inter[a].address == '127.0.0.1') {
+ assert.deepEqual(inter[a], expected);
+ found = true;
+ }
+ }
}
+assert(found);
var EOL = os.EOL;
assert.ok(EOL.length > 0);

0 comments on commit 74b60fa

Please sign in to comment.