Skip to content

Commit

Permalink
Merge pull request #5662 from larsewi/automake
Browse files Browse the repository at this point in the history
CFE-4471: General clean-up of tests/unit/Makefile.am
  • Loading branch information
larsewi authored Dec 12, 2024
2 parents 871e87e + 18e8ce4 commit 2fd6406
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 34 deletions.
38 changes: 9 additions & 29 deletions tests/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,10 @@ 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

check_LTLIBRARIES += libstr.la
libstr_la_SOURCES = \
../../libntech/libutils/buffer.c \
../../libntech/libutils/encode.c \
../../libntech/libutils/logging.c \
../../libntech/libutils/misc_lib.c \
../../libntech/libutils/regex.c \
../../libntech/libutils/sequence.c \
../../libntech/libutils/string_lib.c \
../../libntech/libutils/writer.c
libstr_la_LIBADD = libtest.la


check_LTLIBRARIES += libdb.la
libdb_la_SOURCES = db_stubs.c \
Expand All @@ -99,7 +79,7 @@ libdb_la_SOURCES = db_stubs.c \
if HPUX
libdb_la_SOURCES += ../../libpromises/cf3globals.c
endif
libdb_la_LIBADD = libstr.la ../../libntech/libutils/libutils.la
libdb_la_LIBADD = ../../libntech/libutils/libutils.la
#libdb_la_CPPFLAGS = $(LMDB_CPPFLAGS) $(TOKYOCABINET_CPPFLAGS) $(QDBM_CPPFLAGS)
# Make sure that source files are compiled to separate object files
# libdb_la-file.o
Expand Down Expand Up @@ -222,10 +202,7 @@ EXTRA_enterprise_extension_test_DEPENDENCIES = cfengine-enterprise.la
endif

set_domainname_test_SOURCES = set_domainname_test.c
set_domainname_test_LDADD = libstr.la ../../libpromises/libpromises.la

str_test_SOURCES = str_test.c
str_test_LDADD = libstr.la
set_domainname_test_LDADD = libtest.la ../../libpromises/libpromises.la

regex_test_SOURCES = regex_test.c ../../libpromises/match_scope.c

Expand Down Expand Up @@ -266,14 +243,14 @@ db_test_LDADD = libtest.la ../../libpromises/libpromises.la

db_concurrent_test_SOURCES = db_concurrent_test.c
#db_concurrent_test_CPPFLAGS = $(libdb_la_CPPFLAGS)
db_concurrent_test_LDADD = libdb.la
db_concurrent_test_LDADD = libtest.la libdb.la

lastseen_test_SOURCES = lastseen_test.c \
../../libpromises/item_lib.c \
../../libpromises/lastseen.c \
../../libntech/libutils/statistics.c
#lastseen_test_CPPFLAGS = $(libdb_la_CPPFLAGS)
lastseen_test_LDADD = libdb.la ../../libpromises/libpromises.la
lastseen_test_LDADD = libtest.la libdb.la ../../libpromises/libpromises.la

lastseen_migration_test_SOURCES = lastseen_migration_test.c \
../../libpromises/lastseen.c \
Expand Down Expand Up @@ -303,7 +280,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 \
Expand Down
10 changes: 7 additions & 3 deletions tests/unit/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <alloc.h>

char *file_read_string(FILE *in)
static char *file_read_string(FILE *in)
{
fpos_t pos;
long size;
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down

0 comments on commit 2fd6406

Please sign in to comment.