Set rlimits on OS X. Enable tests on OSX (except valgrind). setrlimit error handling.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3209 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2016-04-17 12:56:46 +00:00
parent b917cbe08f
commit 72544179c9
3 changed files with 24 additions and 9 deletions

View File

@ -18,7 +18,7 @@
v8::Platform* gPlatform = 0; v8::Platform* gPlatform = 0;
void shedPrivileges() { void shedPrivileges() {
#if !defined (_WIN32) && !defined (__MACH__) #if !defined (_WIN32)
struct rlimit zeroLimit; struct rlimit zeroLimit;
zeroLimit.rlim_cur = 0; zeroLimit.rlim_cur = 0;
zeroLimit.rlim_max = 0; zeroLimit.rlim_max = 0;
@ -36,19 +36,26 @@ void shedPrivileges() {
if (setrlimit(RLIMIT_FSIZE, &zeroLimit) != 0) { if (setrlimit(RLIMIT_FSIZE, &zeroLimit) != 0) {
perror("setrlimit(RLIMIT_FSIZE, {0, 0})"); perror("setrlimit(RLIMIT_FSIZE, {0, 0})");
} exit(-1);
if (setrlimit(RLIMIT_LOCKS, &zeroLimit) != 0) {
perror("setrlimit(RLIMIT_LOCKS, {0, 0})");
}
if (setrlimit(RLIMIT_MSGQUEUE, &zeroLimit) != 0) {
perror("setrlimit(RLIMIT_MSGQUEUE, {0, 0})");
} }
if (setrlimit(RLIMIT_NOFILE, &zeroLimit) != 0) { if (setrlimit(RLIMIT_NOFILE, &zeroLimit) != 0) {
perror("setrlimit(RLIMIT_NOFILE, {0, 0})"); perror("setrlimit(RLIMIT_NOFILE, {0, 0})");
exit(-1);
} }
if (setrlimit(RLIMIT_NPROC, &zeroLimit) != 0) { if (setrlimit(RLIMIT_NPROC, &zeroLimit) != 0) {
perror("setrlimit(RLIMIT_NPROC, {0, 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 #endif
} }

View File

@ -1,5 +1,10 @@
#!/bin/bash #!/bin/bash
if [ ! -x /usr/bin/valgrind ]; then
echo "SKIP"
exit 0
fi
cat > test.js << EOF cat > test.js << EOF
print("hi"); print("hi");
EOF EOF

View File

@ -7,7 +7,7 @@ import shutil
import subprocess import subprocess
import sys import sys
if sys.platform != 'linux2': if sys.platform not in ('darwin', 'linux2'):
print 'Tests are only enabled on Linux.' print 'Tests are only enabled on Linux.'
exit(0) exit(0)
@ -51,6 +51,9 @@ for test in selectedTests:
process = subprocess.Popen(['bash', test], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=tmp, env=env) process = subprocess.Popen(['bash', test], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=tmp, env=env)
stdout, stderr = process.communicate() stdout, stderr = process.communicate()
if process.returncode == 0: if process.returncode == 0:
if stdout.strip() == "SKIP":
print 'SKIPPED', test
else:
print 'PASSED', test print 'PASSED', test
passCount += 1 passCount += 1
else: else: