From b128602a0465ae3066ad0b2b7321eceddc20e191 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 19 Oct 2012 07:50:18 +0400 Subject: [PATCH] Improve staticrootstest checks (tests) * tests/staticrootstest.c (libsrl_init): Report error (and exit) if libsrl_init returns NULL; report the corresponding error if staticroot content is not as expected. --- tests/staticrootstest.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/staticrootstest.c b/tests/staticrootstest.c index f0b45bb..5d5cb3e 100644 --- a/tests/staticrootstest.c +++ b/tests/staticrootstest.c @@ -37,6 +37,10 @@ int main(void) /*GC_INIT(); staticroot = GC_MALLOC(sizeof(struct treenode));*/ staticroot = libsrl_init(); + if (NULL == staticroot) { + fprintf(stderr, "GC_malloc returned NULL\n"); + return 2; + } memset(staticroot, 0x42, sizeof(struct treenode)); GC_gcollect(); for (i = 0; i < 10; ++i) { @@ -44,16 +48,20 @@ int main(void) GC_gcollect(); } for (i = 0; i < (int)sizeof(struct treenode); ++i) { - if (staticroot[i] != 0x42) + if (staticroot[i] != 0x42) { + fprintf(stderr, "Memory check failed\n"); return -1; + } } for (i = 0; i < 10; ++i) { root[i] = libsrl_mktree(12); GC_gcollect(); } for (i = 0; i < (int)sizeof(struct treenode); ++i) { - if (staticroot[i] != 0x42) + if (staticroot[i] != 0x42) { + fprintf(stderr, "Memory check failed\n"); return -1; + } } return 0; } -- 2.7.4