diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-05-01 13:11:17 +0800 |
---|---|---|
committer | Geoff Levand <geoff@infradead.org> | 2013-05-03 16:21:11 -0700 |
commit | 5399335e509f1866d071f03f6163b86ae608d9c5 (patch) | |
tree | 0d1486e32a6f89b55e7d77283b39702d1cb86fe6 /test/lib | |
parent | 0fad1573c93563fcd62c992d73e9d25161b80076 (diff) | |
download | talos-petitboot-5399335e509f1866d071f03f6163b86ae608d9c5.tar.gz talos-petitboot-5399335e509f1866d071f03f6163b86ae608d9c5.zip |
test/lib: Add empty list test
Check that the list iterators work on empty lists too.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/list-test.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/lib/list-test.c b/test/lib/list-test.c index de629ee..c532282 100644 --- a/test/lib/list-test.c +++ b/test/lib/list-test.c @@ -60,12 +60,28 @@ int main(void) list_remove(&item->list); } + /* we should see that the list is empty */ i = 0; - fprintf(stderr, "-- list_for_each_entry --\n"); + fprintf(stderr, "-- list_for_each_entry(empty) --\n"); list_for_each_entry(&tester, item, list) { fprintf(stderr, "%d: %d: %p -> %p\n", i++, item->value, item, item->list.next); } + if (i) { + fprintf(stderr, "Error: list should be empty\n"); + return EXIT_FAILURE; + } + + i = 0; + fprintf(stderr, "-- list_for_each_entry_safe(empty) --\n"); + list_for_each_entry_safe(&tester, item, tmp, list) { + fprintf(stderr, "%d: %d: %p -> %p\n", i++, item->value, item, item->list.next); + } + + if (i) { + fprintf(stderr, "Error: list should be empty\n"); + return EXIT_FAILURE; + } fprintf(stderr, "-- done --\n"); return EXIT_SUCCESS; } |