From 0530b0a5ca5e5a21054d7ba83354a230a76eab5b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 17 Jan 2008 18:57:50 +0000 Subject: Don't abort tests 518 and 537 when unable to raise the open-file soft limit --- CHANGES | 3 +++ tests/libtest/lib518.c | 17 ++++++++++++++++- tests/libtest/lib537.c | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 89b091ceb..405655afe 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,9 @@ Changelog +Yang Tse (17 Jan 2008) +- Don't abort tests 518 and 537 when unable to raise the open-file soft limit. + Daniel S (16 Jan 2008) - Nathan Coulter's patch that makes runtests.pl respect the PATH when figuring out what valgrind to run. diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 3b83ae378..22680688b 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -153,12 +153,27 @@ static int rlimit(int keep_open) if (rl.rlim_cur != rl.rlim_max) { +#ifdef OPEN_MAX + if ((rl.rlim_cur > 0) && + (rl.rlim_cur < OPEN_MAX)) { + fprintf(stderr, "raising soft limit up to OPEN_MAX\n"); + rl.rlim_cur = OPEN_MAX; + if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + /* on failure don't abort just issue a warning */ + store_errmsg("setrlimit() failed", ERRNO); + fprintf(stderr, "%s\n", msgbuff); + msgbuff[0] = '\0'; + } + } +#endif + fprintf(stderr, "raising soft limit up to hard limit\n"); rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + /* on failure don't abort just issue a warning */ store_errmsg("setrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); - return -2; + msgbuff[0] = '\0'; } /* get current open file limits */ diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index b4b2b7a93..1f5a34221 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -148,12 +148,27 @@ static int rlimit(int keep_open) if (rl.rlim_cur != rl.rlim_max) { +#ifdef OPEN_MAX + if ((rl.rlim_cur > 0) && + (rl.rlim_cur < OPEN_MAX)) { + fprintf(stderr, "raising soft limit up to OPEN_MAX\n"); + rl.rlim_cur = OPEN_MAX; + if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + /* on failure don't abort just issue a warning */ + store_errmsg("setrlimit() failed", ERRNO); + fprintf(stderr, "%s\n", msgbuff); + msgbuff[0] = '\0'; + } + } +#endif + fprintf(stderr, "raising soft limit up to hard limit\n"); rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + /* on failure don't abort just issue a warning */ store_errmsg("setrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); - return -2; + msgbuff[0] = '\0'; } /* get current open file limits */ -- cgit v1.2.3