summaryrefslogtreecommitdiff
path: root/test/common.js
diff options
context:
space:
mode:
authorJohan Bergström <bugs@bergstroem.nu>2015-03-17 12:06:48 +1100
committerJohan Bergström <bugs@bergstroem.nu>2015-03-19 09:11:50 +1100
commitc15e81afdd5413f94df23eb82b6fc65875cb07fb (patch)
tree580f0433e3b1fff6693cce1dbb3de0682317df43 /test/common.js
parentfe0f015c5159633127e268ebfc5db121883bc35c (diff)
downloadnodejs-c15e81afdd5413f94df23eb82b6fc65875cb07fb.tar.gz
nodejs-c15e81afdd5413f94df23eb82b6fc65875cb07fb.tar.bz2
nodejs-c15e81afdd5413f94df23eb82b6fc65875cb07fb.zip
test: Introduce knowledge of FreeBSD jails
FreeBSD jails act differently than your average vm or similar application container. All routing passes through one ip address, which makes things like localhost or 0.0.0.0 resolve differently. Introduce a helper that allows us to verify if we're in a jail and another one for returning an ip address for localhost. Also, skip one test instead of trading additional complexity in common.js for one specific user scenario. PR-URL: https://github.com/iojs/io.js/pull/1167 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/common.js')
-rw-r--r--test/common.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/common.js b/test/common.js
index 901425b28..e0db00175 100644
--- a/test/common.js
+++ b/test/common.js
@@ -21,6 +21,35 @@ exports.tmpDir = path.join(exports.testDir, exports.tmpDirName);
var opensslCli = null;
+Object.defineProperty(exports, 'inFreeBSDJail', {
+ get: function() {
+ if (process.platform === 'freebsd' &&
+ child_process.execSync('sysctl -n security.jail.jailed').toString() ===
+ '1\n') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+});
+
+Object.defineProperty(exports, 'localhost_ipv4', {
+ get: function() {
+ if (exports.inFreeBSDJail) {
+ // Jailed network interfaces are a bit special - since we need to jump
+ // through loops, as well as this being an exception case, assume the
+ // user will provide this instead.
+ if (process.env.LOCALHOST)
+ return process.env.LOCALHOST;
+
+ console.error('Looks like we\'re in a FreeBSD Jail. ' +
+ 'Please provide your default interface address ' +
+ 'as LOCALHOST or expect some tests to fail.');
+ }
+ return '127.0.0.1';
+ }
+});
+
// opensslCli defined lazily to reduce overhead of spawnSync
Object.defineProperty(exports, 'opensslCli', {get: function() {
if (opensslCli !== null) return opensslCli;