Skip to content

Commit

Permalink
test case for last checkin. IGNORE
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Harren committed Feb 22, 2004
1 parent 7082f52 commit 17e8e85
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/small1/oom.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

// What happens if malloc returns null?

#include "testharness.h"
#include <malloc.h>
#include <sys/resource.h>
#include <unistd.h>

struct list {
struct list* next;
int data[1024*10];
};

int main() {
struct list* p = 0;

// This test tries to run out of memory. To avoid annoying other users,
// put a 10MB limit on the memory that is allocated to this test.
const int heapSize = 1024*1024*10;
struct rlimit limit = {heapSize, heapSize};
int res = setrlimit(RLIMIT_DATA, &limit);
if (res != 0){
printf("***setrlimit didn't work");
}

while(1) {
//Eventually, malloc returns null. Hopefully, CCured won't try to
//dereference it.
struct list* newp = malloc(sizeof(struct list));
if (! newp) { break; }
newp->next = p;
p = newp;
}
SUCCESS;
}

1 change: 1 addition & 0 deletions test/testcil.pl
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@

$TEST->addTests("testrun/typeof1", "", ['cil']);
$TEST->addTests("testrun/semicolon", "_GNUCC=1", ['cil']);
$TEST->addTests("testrun/oom", "", ['inferbox']);

$TEST->add2Tests("merge-ar", "");
#
Expand Down

0 comments on commit 17e8e85

Please sign in to comment.