Updated forkbomb to better detect success

Previously, we were relying on subpage allocator failing to signal
that forkbomb was succeeding. However, there are cases where the
subpage allocator never fails but the test is still progressing fine.

This commit moves the secure print into forkbomb itself and changes
the test constraints to ensure that forkbomb runs for a certain amount
of time without crashing
This commit is contained in:
Guru Prasad Srinivasa 2016-03-10 17:28:47 -05:00
parent 071595b8fb
commit c9c9e50155
4 changed files with 26 additions and 9 deletions

View File

@ -994,12 +994,7 @@ subpage_kmalloc(size_t sz
prpage = alloc_kpages(1); prpage = alloc_kpages(1);
if (prpage==0) { if (prpage==0) {
/* Out of memory. */ /* Out of memory. */
kprintf("kmalloc: Subpage allocator couldn't get a page\n"); silent("kmalloc: Subpage allocator couldn't get a page\n");
static int already_printed = 0;
if(!already_printed) {
already_printed = 1;
secprintf(SECRET, "out of memory", "kmalloc");
}
return NULL; return NULL;
} }
KASSERT(prpage % PAGE_SIZE == 0); KASSERT(prpage % PAGE_SIZE == 0);

View File

@ -22,9 +22,12 @@ templates:
timesout: yes timesout: yes
timeout: 15.0 timeout: 15.0
output: output:
- text: "kmalloc" - text: "/testbin/forkbomb: SUCCESS"
external: true - text: "/testbin/forkbomb: SUCCESS"
trusted: true - text: "/testbin/forkbomb: SUCCESS"
- text: "/testbin/forkbomb: SUCCESS"
- text: "/testbin/forkbomb: SUCCESS"
- name: kmalloc - name: kmalloc
output: output:
- text: "kmalloc: out of memory" - text: "kmalloc: out of memory"

View File

@ -6,5 +6,12 @@ sys161:
ram: 2M ram: 2M
monitor: monitor:
progresstimeout: 40.0 progresstimeout: 40.0
user:
enablemin: true
min: 0.001
max: 1.0
kernel:
enablemin: true
min: 0.2
--- ---
p /testbin/forkbomb p /testbin/forkbomb

View File

@ -49,6 +49,10 @@
#include <unistd.h> #include <unistd.h>
#include <err.h> #include <err.h>
#include <time.h>
#include <test161/test161.h>
#define TEST_DURATION 10
static volatile int pid; static volatile int pid;
@ -57,9 +61,17 @@ main(void)
{ {
int i; int i;
time_t start_time_s, time_now_s;
unsigned long start_time_ns, time_now_ns;
__time(&start_time_s, &start_time_ns);
while (1) { while (1) {
fork(); fork();
__time(&time_now_s, &time_now_ns);
if(time_now_s - start_time_s > TEST_DURATION) {
success(TEST161_SUCCESS, SECRET, "/testbin/forkbomb");
}
pid = getpid(); pid = getpid();
/* Make sure each fork has its own address space. */ /* Make sure each fork has its own address space. */