From: Ivan Maidanski Date: Fri, 19 Oct 2012 03:50:18 +0000 (+0400) Subject: Improve staticrootstest checks (tests) X-Git-Tag: gc7_4_0~191 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b128602a0465ae3066ad0b2b7321eceddc20e191;p=gc 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. --- diff --git a/tests/staticrootstest.c b/tests/staticrootstest.c index f0b45bb6..5d5cb3eb 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; }