From 64c0065986b4a9c3f8410c4408db8088c00751bf Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 9 Mar 2023 15:53:42 +1100 Subject: [PATCH] Build libtest even if CMOCKA is not available Be more selective about what is not built when CMOCKA is not available so that fuzz/dns_qp and fuzz/dns_qpkey_name can link against it. --- Makefile.am | 2 -- fuzz/Makefile.am | 34 +++++++++++----------------------- tests/Makefile.am | 6 +++++- tests/libtest/Makefile.am | 7 +++++-- 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/Makefile.am b/Makefile.am index 26c45e0736..63bb88fd7b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,9 +3,7 @@ include $(top_srcdir)/Makefile.top SUBDIRS = . lib doc # build libtest before fuzz/* and bin/tests -if HAVE_CMOCKA SUBDIRS += tests -endif HAVE_CMOCKA # run fuzz tests before system tests SUBDIRS += fuzz bin diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am index 05904a97dc..d2e3931c00 100644 --- a/fuzz/Makefile.am +++ b/fuzz/Makefile.am @@ -6,15 +6,19 @@ AM_CFLAGS += \ AM_CPPFLAGS += \ $(LIBISC_CFLAGS) \ $(LIBDNS_CFLAGS) \ - $(LIBUV_CFLAGS) \ - -DFUZZDIR=\"$(abs_srcdir)\" + $(LIBUV_CFLAGS) \ + -DFUZZDIR=\"$(abs_srcdir)\" \ + -I$(top_srcdir)/lib/dns \ + -I$(top_srcdir)/lib/isc \ + -I$(top_srcdir)/tests/include AM_LDFLAGS += \ $(FUZZ_LDFLAGS) -LDADD += \ - libfuzzmain.la \ - $(LIBDNS_LIBS) \ +LDADD += \ + libfuzzmain.la \ + $(top_builddir)/tests/libtest/libtest.la \ + $(LIBDNS_LIBS) \ $(LIBISC_LIBS) check_LTLIBRARIES = libfuzzmain.la @@ -28,6 +32,8 @@ check_PROGRAMS = \ dns_message_parse \ dns_name_fromtext_target \ dns_name_fromwire \ + dns_qp \ + dns_qpkey_name \ dns_rdata_fromtext \ dns_rdata_fromwire_text \ isc_lex_getmastertoken \ @@ -51,24 +57,6 @@ dns_name_fromwire_SOURCES = \ old.c \ old.h -if HAVE_CMOCKA - -check_PROGRAMS += \ - dns_qp \ - dns_qpkey_name - -AM_CPPFLAGS += \ - -I$(top_srcdir)/lib/dns \ - -I$(top_srcdir)/lib/isc \ - -I$(top_srcdir)/tests/include - -# libisc needs to appear after libtest -LDADD += \ - $(top_builddir)/tests/libtest/libtest.la \ - $(LIBISC_LIBS) - -endif HAVE_CMOCKA - TESTS = $(check_PROGRAMS) if HAVE_FUZZ_LOG_COMPILER diff --git a/tests/Makefile.am b/tests/Makefile.am index 3a1a0241fe..9e27f39289 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,6 +12,10 @@ LDADD += \ $(LIBDNS_LIBS) \ $(LIBNS_LIBS) -SUBDIRS = libtest isc dns ns isccfg irs bench +SUBDIRS = libtest + +if HAVE_CMOCKA +SUBDIRS += isc dns ns isccfg irs bench +endif HAVE_CMOCKA check_PROGRAMS = diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 43472699a9..68708d463d 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -16,13 +16,16 @@ LDADD += \ noinst_LTLIBRARIES = libtest.la libtest_la_SOURCES = \ - ../include/tests/dns.h \ ../include/tests/isc.h \ ../include/tests/ns.h \ ../include/tests/qp.h \ - dns.c \ isc.c \ ns.c \ qp.c +if HAVE_CMOCKA +libtest_la_SOURCES += \ + ../include/tests/dns.h \ + dns.c +endif HAVE_CMOCKA include $(top_srcdir)/Makefile.tests