diff --git a/src/main.cpp b/src/main.cpp index ea30c4d6..29a68ea7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,7 @@ v8::Platform* gPlatform = 0; void shedPrivileges() { -#if !defined (_WIN32) && !defined (__MACH__) +#if !defined (_WIN32) struct rlimit zeroLimit; zeroLimit.rlim_cur = 0; zeroLimit.rlim_max = 0; @@ -36,19 +36,26 @@ void shedPrivileges() { if (setrlimit(RLIMIT_FSIZE, &zeroLimit) != 0) { perror("setrlimit(RLIMIT_FSIZE, {0, 0})"); - } - if (setrlimit(RLIMIT_LOCKS, &zeroLimit) != 0) { - perror("setrlimit(RLIMIT_LOCKS, {0, 0})"); - } - if (setrlimit(RLIMIT_MSGQUEUE, &zeroLimit) != 0) { - perror("setrlimit(RLIMIT_MSGQUEUE, {0, 0})"); + exit(-1); } if (setrlimit(RLIMIT_NOFILE, &zeroLimit) != 0) { perror("setrlimit(RLIMIT_NOFILE, {0, 0})"); + exit(-1); } if (setrlimit(RLIMIT_NPROC, &zeroLimit) != 0) { perror("setrlimit(RLIMIT_NPROC, {0, 0})"); + exit(-1); } +#if !defined (__MACH__) + if (setrlimit(RLIMIT_LOCKS, &zeroLimit) != 0) { + perror("setrlimit(RLIMIT_LOCKS, {0, 0})"); + exit(-1); + } + if (setrlimit(RLIMIT_MSGQUEUE, &zeroLimit) != 0) { + perror("setrlimit(RLIMIT_MSGQUEUE, {0, 0})"); + exit(-1); + } +#endif #endif } diff --git a/tests/02-valgrind b/tests/02-valgrind index 64c2d6cf..570a567d 100755 --- a/tests/02-valgrind +++ b/tests/02-valgrind @@ -1,5 +1,10 @@ #!/bin/bash +if [ ! -x /usr/bin/valgrind ]; then + echo "SKIP" + exit 0 +fi + cat > test.js << EOF print("hi"); EOF diff --git a/tools/run-tests b/tools/run-tests index 1611d708..8c9c31b5 100755 --- a/tools/run-tests +++ b/tools/run-tests @@ -7,7 +7,7 @@ import shutil import subprocess import sys -if sys.platform != 'linux2': +if sys.platform not in ('darwin', 'linux2'): print 'Tests are only enabled on Linux.' exit(0) @@ -51,7 +51,10 @@ for test in selectedTests: process = subprocess.Popen(['bash', test], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=tmp, env=env) stdout, stderr = process.communicate() if process.returncode == 0: - print 'PASSED', test + if stdout.strip() == "SKIP": + print 'SKIPPED', test + else: + print 'PASSED', test passCount += 1 else: print 'FAILED', test