diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 26c3b4c28c..00a20b97c7 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -52,15 +52,7 @@ AM_CFLAGS = $(PTHREAD_CFLAGS) check_LTLIBRARIES = libtest.la -libtest_la_SOURCES = cmockery.c cmockery.h schema.h test.c test.h \ - ../../libntech/libutils/alloc.c \ - ../../libpromises/patches.c \ - ../../libpromises/constants.c \ - ../../libntech/libutils/known_dirs.c \ - ../../libntech/libutils/map.c \ - ../../libntech/libutils/array_map.c \ - ../../libntech/libutils/hash.c \ - ../../libntech/libutils/hash_map.c +libtest_la_SOURCES = cmockery.c cmockery.h schema.h test.c test.h libtest_la_LIBADD = ../../libntech/libcompat/libcompat.la @@ -303,7 +295,10 @@ files_copy_test_LDADD = libtest.la ../../libpromises/libpromises.la sort_test_SOURCES = sort_test.c sort_test_LDADD = libtest.la ../../libpromises/libpromises.la -logging_test_SOURCES = logging_test.c ../../libpromises/syslog_client.c +logging_test_SOURCES = logging_test.c \ + ../../libpromises/syslog_client.c \ + ../../libpromises/patches.c \ + ../../libpromises/constants.c logging_test_LDADD = libtest.la ../../libntech/libutils/libutils.la connection_management_test_SOURCES = connection_management_test.c \ diff --git a/tests/unit/test.c b/tests/unit/test.c index abea779971..ab41a05b7e 100644 --- a/tests/unit/test.c +++ b/tests/unit/test.c @@ -3,9 +3,8 @@ #include #include #include -#include -char *file_read_string(FILE *in) +static char *file_read_string(FILE *in) { fpos_t pos; long size; @@ -19,7 +18,12 @@ char *file_read_string(FILE *in) assert_int_equal(fseek(in, 0, SEEK_SET), 0); - buffer = xcalloc(size + 1L, sizeof(char)); + buffer = calloc(size + 1L, sizeof(char)); + if (buffer == NULL) + { + fputs("CRITICAL: Unable to allocate memory\n", stderr); + exit(255); + } assert_int_equal(fread(buffer, 1, size, in), size); assert_int_equal(fsetpos(in, &pos), 0); diff --git a/tests/unit/test.h b/tests/unit/test.h index 7533cedb95..a98e77b409 100644 --- a/tests/unit/test.h +++ b/tests/unit/test.h @@ -24,8 +24,6 @@ printf("==================================================\n") -char *file_read_string(FILE *in); - void assert_file_equal(FILE *a, FILE *b); #define assert_double_close(a, b) _assert_double_close(a, b, __FILE__, __LINE__)