projects
/
libc-test
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d289688
)
add setrlimit to test run
author
nsz
<nsz@port70.net>
Wed, 28 Mar 2012 23:37:26 +0000
(
01:37
+0200)
committer
nsz
<nsz@port70.net>
Wed, 28 Mar 2012 23:37:26 +0000
(
01:37
+0200)
common/t.c
patch
|
blob
|
history
diff --git
a/common/t.c
b/common/t.c
index
2373b09
..
3d39efc
100644
(file)
--- a/
common/t.c
+++ b/
common/t.c
@@
-5,6
+5,8
@@
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include <unistd.h>
#include "test.h"
#include <unistd.h>
#include "test.h"
@@
-30,7
+32,7
@@
void error__(const char *n, int l, const char *s, ...) {
va_list ap;
if (failed == 0 && nfailed == 0)
va_list ap;
if (failed == 0 && nfailed == 0)
- dprintf(1, "FAIL\n"
, n
);
+ dprintf(1, "FAIL\n");
failed = 1;
dprintf(1, " ERROR %s %s:%d: ", name, n, l);
va_start(ap, s);
failed = 1;
dprintf(1, " ERROR %s %s:%d: ", name, n, l);
va_start(ap, s);
@@
-38,6
+40,16
@@
void error__(const char *n, int l, const char *s, ...) {
va_end(ap);
}
va_end(ap);
}
+static void setrl(int r, long lim) {
+ struct rlimit rl;
+
+ if (getrlimit(r, &rl))
+ error("getrlimit %d: %s\n", r, strerror(errno));
+ rl.rlim_cur = lim;
+ if (setrlimit(r, &rl))
+ error("setrlimit %d: %s\n", r, strerror(errno));
+}
+
static void run(const char *n, void (*f)()) {
pid_t pid;
int s;
static void run(const char *n, void (*f)()) {
pid_t pid;
int s;
@@
-51,6
+63,9
@@
static void run(const char *n, void (*f)()) {
pid = fork();
if (pid == 0) {
/* run test in a child process */
pid = fork();
if (pid == 0) {
/* run test in a child process */
+ setrl(RLIMIT_CORE, 1<<24);
+ setrl(RLIMIT_STACK, 1<<16);
+ setrl(RLIMIT_CPU, 2);
f();
exit(failed);
}
f();
exit(failed);
}