apparmor/tests/stress/subdomain/open.c
Steve Beattie 66286494a2 Resurrect another of the stress tests; it kinda works, though it requires
killall-ing a few things in order to make it stop. And alas, it does seem
to eventually cause kernel hangs with 2.6.32-16. (Committing now before ext4
eats my changes and brain.)
2010-03-10 20:56:47 -08:00

34 lines
656 B
C

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <linux/unistd.h>
#define MAX_LOOP 1000000
int main(int argc, char *argv[])
{
int fd, i, success, fail;
char *o_file = "/bin/ls";
if (argc > 1)
o_file = argv[1];
for (i=0, success=0, fail=0; i<MAX_LOOP; i++) {
// for (i=0, success=0, fail=0; !i; i++) {
fd = open(o_file, O_RDONLY);
if (fd != -1) {
success++;
close(fd);
} else {
printf("open: %s\n", strerror(errno));
fail++;
}
}
printf("Iterations: %d\tSuccess: %d\t Fail: %d\n",
MAX_LOOP, success, fail);
return 0;
}