Skip to content

Commit

Permalink
OoM list adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alobbs committed Jun 25, 2014
1 parent 5af4d9e commit 4df04f3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
32 changes: 31 additions & 1 deletion libchula/test/OOM/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,37 @@
#include "oom.h"

int
list_new (void)
list_add (void)
{
ret_t ret;
size_t s1, s2;
chula_list_t list = LIST_HEAD_INIT(list);

for (int i=0; i<10; i++) {
/* Add a new list entry */
chula_list_get_len (&list, &s1);
ret = chula_list_content_add (&list, INT_TO_POINTER(i));
chula_list_get_len (&list, &s2);

/* Check return code */
assert (((ret == ret_ok) && (s2 > s1)) ||
((ret == ret_nomem) && (s2 <= s1)));
}

chula_list_content_free (&list, NULL);

for (int i=0; i<10; i++) {
/* Add a new list entry */
chula_list_get_len (&list, &s1);
ret = chula_list_content_add_tail (&list, INT_TO_POINTER(100 + i));
chula_list_get_len (&list, &s2);

/* Check return code */
assert (((ret == ret_ok) && (s2 > s1)) ||
((ret == ret_nomem) && (s2 <= s1)));
}

chula_list_content_free (&list, NULL);

return 0;
}
2 changes: 1 addition & 1 deletion libchula/test/OOM/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
#ifndef OOM_LIST
#define OOM_LIST

int list_new (void);
int list_add (void);

#endif /* OOM_LIST */
2 changes: 1 addition & 1 deletion libchula/test/OOM/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ main (int argc, char *argv[])
SCHED_FAIL (buffer_encoders);
SCHED_FAIL (buffer_repr);

SCHED_FAIL (list_new);
SCHED_FAIL (list_add);

/* Clean up */
chula_mem_mgr_reset(&mgr);
Expand Down

0 comments on commit 4df04f3

Please sign in to comment.