From eeb7e40044b4a53e9726bacd1185a2106683c674 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Thu, 9 Jan 2025 17:41:41 +0100 Subject: [PATCH 01/13] Enabled subdir-objects in AM_INIT_AUTOMAKE This way we don't get annoying warnings like: ``` warning: source file '$(srcdir)/../../libutils/statistics.c' is in a subdirectory, but option 'subdir-objects' is disabled ``` Ticket: CFE-2780 Signed-off-by: Lars Erik Wik --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 27771ae050..18fcfea99a 100644 --- a/configure.ac +++ b/configure.ac @@ -69,7 +69,7 @@ m4_define(SERIAL_TESTS, m4_bmatch(AUTOMAKE_VERSION, [^1\.\([0-9]\|1[0-1]\)\(\.\| AC_MSG_RESULT(AUTOMAKE_VERSION) -AM_INIT_AUTOMAKE([tar-ustar] SERIAL_TESTS) +AM_INIT_AUTOMAKE([tar-ustar] SERIAL_TESTS [subdir-objects]) AM_MAINTAINER_MODE([enable]) m4_divert_text([DEFAULTS], [: "${AR_FLAGS=cr}"]) From 7fac8b3b88e4589a99b2927d9593d064fafd2ec2 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 10 Jan 2025 10:19:19 +0100 Subject: [PATCH 02/13] Fixed warning AC_PROG_LEX without either yywrap or noyywrap is obsolete Ticket: CFE-2780 Signed-off-by: Lars Erik Wik --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 18fcfea99a..d80e1e58d7 100644 --- a/configure.ac +++ b/configure.ac @@ -143,7 +143,7 @@ m4_ifdef([LT_INIT], [AC_DISABLE_STATIC AC_PROG_LIBTOOL]) -AM_PROG_LEX +AC_PROG_LEX(noyywrap) AC_PROG_YACC AC_PROG_INSTALL AC_PATH_PROG([PERL], [perl]) From 65cbcda0548b7cd90d522787f4606674f3b9834f Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 10 Jan 2025 10:26:23 +0100 Subject: [PATCH 03/13] Fixed warning from running autoupdate on configure.ac Ticket: CFE-2780 Signed-off-by: Lars Erik Wik --- configure.ac | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index d80e1e58d7..55900b5546 100644 --- a/configure.ac +++ b/configure.ac @@ -29,7 +29,7 @@ dnl # Run ./autogen.sh to build configure script dnl # dnl ########################################################################## -AC_PREREQ(2.63) +AC_PREREQ([2.63]) m4_define([cfversion_from_env], m4_normalize(m4_esyscmd([echo $EXPLICIT_VERSION]))) m4_define([cfversion_from_file], m4_normalize(m4_esyscmd([cat CFVERSION]))) @@ -46,7 +46,7 @@ m4_ifval(cfversion_from_env, [ ]) -AC_INIT(cfengine, cfversion) +AC_INIT([cfengine],[cfversion]) AC_CONFIG_SRCDIR([libpromises/generic_agent.c]) AC_CANONICAL_TARGET @@ -137,11 +137,11 @@ AS_CASE([${target_os}], dnl GCC specific flags m4_include([m4/cf3_gcc_flags.m4]) -# Use either new LT_INIT or old AC_DISABLE_STATIC/AC_PROG_LIBTOOL macros +# Use either new LT_INIT or old AC_DISABLE_STATIC/LT_INIT macros m4_ifdef([LT_INIT], [LT_INIT([disable-static])], [AC_DISABLE_STATIC - AC_PROG_LIBTOOL]) + LT_INIT]) AC_PROG_LEX(noyywrap) AC_PROG_YACC @@ -819,9 +819,6 @@ AC_CHECK_HEADERS(sys/jail.h, [], [], [AC_INCLUDES_DEFAULT ]) AC_CHECK_HEADERS(net/route.h netinet/in.h netinet/ip.h) - -AC_HEADER_STDC -AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_HEADER_DIRENT AC_HEADER_STDBOOL From 822799c160f6db56d38e592caf6fda494807ce24 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 10 Jan 2025 11:27:21 +0100 Subject: [PATCH 04/13] Fixed warning non-POSIX variable name Ticket: CFE-2780 Signed-off-by: Lars Erik Wik --- examples/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index 662351a12e..ad5f6a53bf 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -29,10 +29,10 @@ MAINTAINERCLEANFILES = Makefile.in mdate-sh # only re-run the outputs for examples that already have an example_output block remake: - perl ./remake_outputs.pl $(shell grep -l example_output $(dist_examples_DATA)) + perl ./remake_outputs.pl `shell grep -l example_output $(dist_examples_DATA)` recheck: - perl ./remake_outputs.pl -c $(shell grep -l example_output $(dist_examples_DATA)) + perl ./remake_outputs.pl -c `shell grep -l example_output $(dist_examples_DATA)` recheck_verbose: - perl ./remake_outputs.pl -v -c $(shell grep -l example_output $(dist_examples_DATA)) + perl ./remake_outputs.pl -v -c `shell grep -l example_output $(dist_examples_DATA)` From 5ed7b9d35d56c802ddf3a1d5317ac015b3c34d7c Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 10 Jan 2025 14:11:38 +0100 Subject: [PATCH 05/13] Fixed non-POSIX variable name warning ``` tests/acceptance/Makefile.am:103: warning: wildcard [0-9]*: non-POSIX variable name tests/acceptance/Makefile.am:103: (probably a GNU make extension) ``` Ticket: CFE-2780 Signed-off-by: Lars Erik Wik --- tests/acceptance/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/Makefile.am b/tests/acceptance/Makefile.am index 4e76f8df8e..ec8042d15a 100644 --- a/tests/acceptance/Makefile.am +++ b/tests/acceptance/Makefile.am @@ -100,7 +100,7 @@ EXTRA_DIST = default.cf.sub dcs.cf.sub plucked.cf.sub run_with_server.cf.sub \ root-MD5=617eb383deffef843ea856b129d0a423.priv # Recursively include all tests in the dist tarball and set proper permissions -EXTRA_DIST += $(wildcard [0-9]*) +EXTRA_DIST += `wildcard [0-9]*` dist-hook: chmod -R go-w $(distdir) From e2bc2ff122b5d4125ec0ead3ea9666704c8cc0bf Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 10 Jan 2025 14:29:29 +0100 Subject: [PATCH 06/13] Reapply "Fix init_script_test_helper not being cleaned properly." Looks like 520144f11a2267734a88e1aaf4aa9edd333d0dac was an attempt to fix init_script_test_helper from not being cleaned properly. This commit was reverted in ebd97bd29beee6de6b82d4565e588e86adf31127, and another attempt was added in 9dc759f448a202ee413814aa4b64d365df4fbc85. However, the revert actually removed the entire `init_script_test_helper` binary from being compiled. This reapplying the first fix, and combining it with the second fix should do the trick. Found this while trying to clear the warning: ``` tests/unit/Makefile.am:402: warning: variable 'init_script_test_helper_SOURCES' is defined but no program or tests/unit/Makefile.am:402: library has 'init_script_test_helper' as canonical name (possible typo) ``` This reverts commit ebd97bd29beee6de6b82d4565e588e86adf31127. --- tests/unit/Makefile.am | 1 + tests/unit/init_script_test.sh | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 3a4bb0a9d4..0bc3034b23 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -407,6 +407,7 @@ nfs_test_LDADD = ../../libpromises/libpromises.la libtest.la init_script_test_helper_SOURCES = init_script_test_helper.c init_script_test.sh: init_script_test_helper CLEANFILES += init_script_test_helper +noinst_PROGRAMS += init_script_test_helper endif EXTRA_DIST += init_script_test_helper.c EXTRA_DIST += init_script_test.sh diff --git a/tests/unit/init_script_test.sh b/tests/unit/init_script_test.sh index f105ede55d..dddcc8587b 100755 --- a/tests/unit/init_script_test.sh +++ b/tests/unit/init_script_test.sh @@ -91,10 +91,10 @@ fi # Fail on any error. set -e -cp init_script_test_helper $CFTEST_PREFIX/bin/cf-test-execd -cp init_script_test_helper $CFTEST_PREFIX/bin/cf-test-serverd -cp init_script_test_helper $CFTEST_PREFIX/bin/cf-test-monitord -cp init_script_test_helper $CFTEST_PREFIX/bin/cf-test-agent +cp .libs/init_script_test_helper $CFTEST_PREFIX/bin/cf-test-execd +cp .libs/init_script_test_helper $CFTEST_PREFIX/bin/cf-test-serverd +cp .libs/init_script_test_helper $CFTEST_PREFIX/bin/cf-test-monitord +cp .libs/init_script_test_helper $CFTEST_PREFIX/bin/cf-test-agent touch $CFTEST_PREFIX/inputs/promises.cf From ffb9631186695cc69ed3646ec97504ad9930b41e Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 10 Jan 2025 17:10:21 +0100 Subject: [PATCH 07/13] Remove references to `top_sourcedir` in Makefile.am I don't know why, but this was necessary, and all the other tests does this. I was getting the following errors after enabling subdir-objects in `AM_INIT_AUTOMAKE`: ``` Makefile:1843: ../../cf-upgrade/.deps/cf_upgrade_test-alloc-mini.Po: No such file or directory Makefile:1844: ../../cf-upgrade/.deps/cf_upgrade_test-command_line.Po: No such file or directory Makefile:1845: ../../cf-upgrade/.deps/cf_upgrade_test-configuration.Po: No such file or directory Makefile:1846: ../../cf-upgrade/.deps/cf_upgrade_test-log.Po: No such file or directory Makefile:1847: ../../cf-upgrade/.deps/cf_upgrade_test-process.Po: No such file or directory Makefile:1848: ../../cf-upgrade/.deps/cf_upgrade_test-update.Po: No such file or directory ``` Ticket: CFE-2780 Signed-off-by: Lars Erik Wik --- tests/unit/Makefile.am | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 0bc3034b23..ca14c72960 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -386,17 +386,17 @@ verify_databases_test_LDADD = ../../cf-agent/libcf-agent.la libtest.la iteration_test_SOURCES = iteration_test.c cf_upgrade_test_SOURCES = cf_upgrade_test.c \ - $(top_srcdir)/cf-upgrade/alloc-mini.c \ - $(top_srcdir)/cf-upgrade/alloc-mini.h \ - $(top_srcdir)/cf-upgrade/command_line.c \ - $(top_srcdir)/cf-upgrade/command_line.h \ - $(top_srcdir)/cf-upgrade/configuration.c \ - $(top_srcdir)/cf-upgrade/configuration.h \ - $(top_srcdir)/cf-upgrade/log.c $(top_srcdir)/cf-upgrade/log.h \ - $(top_srcdir)/cf-upgrade/process.c $(top_srcdir)/cf-upgrade/process.h \ - $(top_srcdir)/cf-upgrade/update.c \ - $(top_srcdir)/cf-upgrade/update.h -cf_upgrade_test_CPPFLAGS = -I$(top_srcdir)/cf-upgrade -I$(top_srcdir)/libntech/libutils -I$(top_srcdir) + ../../cf-upgrade/alloc-mini.c \ + ../../cf-upgrade/alloc-mini.h \ + ../../cf-upgrade/command_line.c \ + ../../cf-upgrade/command_line.h \ + ../../cf-upgrade/configuration.c \ + ../../cf-upgrade/configuration.h \ + ../../cf-upgrade/log.c ../../cf-upgrade/log.h \ + ../../cf-upgrade/process.c ../../cf-upgrade/process.h \ + ../../cf-upgrade/update.c \ + ../../cf-upgrade/update.h +cf_upgrade_test_CPPFLAGS = -I../../cf-upgrade -I../../libntech/libutils -I../../ cf_upgrade_test_LDADD = libtest.la ../../libntech/libcompat/libcompat.la if !NT From 326739a31d3bf7ae490960068d70765d73fcfa76 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Mon, 13 Jan 2025 10:41:25 +0100 Subject: [PATCH 08/13] Removed linking libraries to init_script_test_helper The `init_script_test_helper` binary does not require any libraries. The libraries `libpromises.la` and `libtest.la` were previously added through the `LDADD` variable in the top of Makefile.am. Ticket: CFE-2780 Signed-off-by: Lars Erik Wik --- tests/unit/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index ca14c72960..44311bfb56 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -404,6 +404,7 @@ check_PROGRAMS += nfs_test nfs_test_SOURCES = nfs_test.c nfs_test_LDADD = ../../libpromises/libpromises.la libtest.la +init_script_test_helper_LDADD = init_script_test_helper_SOURCES = init_script_test_helper.c init_script_test.sh: init_script_test_helper CLEANFILES += init_script_test_helper From 675a5d91418faeb7a5ee867561196ab9c154867d Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Mon, 13 Jan 2025 11:07:24 +0100 Subject: [PATCH 09/13] Removed reference to $(srcdir) in test/load/Makefile.am For some reason it causes the following error ``` 10:58:19 Makefile:598: ../../libpromises/.deps/lastseen.Po: No such file or directory 10:58:19 make[3]: *** No rule to make target '../../libpromises/.deps/lastseen.Po'. Stop. ``` in bootstrap_pr while doing `make dist` in Jenkins. Ticket: CFE-2780 Signed-off-by: Lars Erik Wik --- tests/load/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/load/Makefile.am b/tests/load/Makefile.am index 89c5762d81..29a820f79b 100644 --- a/tests/load/Makefile.am +++ b/tests/load/Makefile.am @@ -54,8 +54,8 @@ db_load_LDADD = ../unit/libdb.la lastseen_load_SOURCES = lastseen_load.c \ - $(srcdir)/../../libpromises/lastseen.c \ - $(srcdir)/../../libntech/libutils/statistics.c + ../../libpromises/lastseen.c \ + ../../libntech/libutils/statistics.c lastseen_load_LDADD = ../unit/libdb.la ../../libpromises/libpromises.la endif From 0913bbde6b72b45027f5ed15fa752bc324f7b99a Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Mon, 13 Jan 2025 11:14:19 +0100 Subject: [PATCH 10/13] Revert "Fixed non-POSIX variable name warning" This reverts commit ba693ca41ae7110d08b62fd440b91a30ed9c0166. --- tests/acceptance/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/Makefile.am b/tests/acceptance/Makefile.am index ec8042d15a..4e76f8df8e 100644 --- a/tests/acceptance/Makefile.am +++ b/tests/acceptance/Makefile.am @@ -100,7 +100,7 @@ EXTRA_DIST = default.cf.sub dcs.cf.sub plucked.cf.sub run_with_server.cf.sub \ root-MD5=617eb383deffef843ea856b129d0a423.priv # Recursively include all tests in the dist tarball and set proper permissions -EXTRA_DIST += `wildcard [0-9]*` +EXTRA_DIST += $(wildcard [0-9]*) dist-hook: chmod -R go-w $(distdir) From 0141270b0de9b0165aed6313d490311a5e279d31 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 9 May 2025 12:20:53 +0200 Subject: [PATCH 11/13] Fixed failures in distclean target Building stuff from libutils in test/unit causes make distclean to delete the same files twice resulting in failure. This happens as an effect of enabling subdir-objects which causes recursive builds. Ticket: CFE-2780 Signed-off-by: Lars Erik Wik --- tests/unit/Makefile.am | 168 ++++++++++------------------------------- 1 file changed, 41 insertions(+), 127 deletions(-) diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 44311bfb56..98ebce07e8 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -54,37 +54,6 @@ AM_CFLAGS = $(PTHREAD_CFLAGS) check_LTLIBRARIES = libtest.la libtest_la_SOURCES = cmockery.c cmockery.h schema.h test.c test.h -libtest_la_LIBADD = ../../libntech/libcompat/libcompat.la - - -check_LTLIBRARIES += libdb.la -libdb_la_SOURCES = db_stubs.c \ - ../../libpromises/dbm_api.c \ - ../../libpromises/dbm_quick.c \ - ../../libpromises/dbm_tokyocab.c \ - ../../libpromises/dbm_lmdb.c \ - ../../libpromises/dbm_migration.c \ - ../../libpromises/dbm_migration_lastseen.c \ - ../../libpromises/global_mutex.c \ - ../../cf-check/backup.c \ - ../../cf-check/diagnose.c \ - ../../cf-check/lmdump.c \ - ../../cf-check/repair.c \ - ../../cf-check/replicate_lmdb.c \ - ../../cf-check/utilities.c \ - ../../cf-check/validate.c \ - ../../libntech/libutils/logging.c \ - ../../libntech/libutils/mutex.c \ - ../../libntech/libutils/cleanup.c -if HPUX -libdb_la_SOURCES += ../../libpromises/cf3globals.c -endif -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 -libdb_la_CFLAGS = $(AM_CFLAGS) - check_PROGRAMS = \ processes_select_test \ arg_split_test \ @@ -216,33 +185,15 @@ set_domainname_test_LDADD = libtest.la ../../libpromises/libpromises.la regex_test_SOURCES = regex_test.c ../../libpromises/match_scope.c -protocol_test_SOURCES = protocol_test.c \ - ../../cf-serverd/server_common.c \ - ../../cf-serverd/server_tls.c \ - ../../cf-serverd/server.c \ - ../../cf-serverd/cf-serverd-enterprise-stubs.c \ - ../../cf-serverd/server_transform.c \ - ../../cf-serverd/cf-serverd-functions.c \ - ../../cf-serverd/server_access.c \ - ../../cf-serverd/strlist.c -protocol_test_LDADD = ../../libpromises/libpromises.la libtest.la +protocol_test_SOURCES = protocol_test.c +protocol_test_LDADD = ../../libpromises/libpromises.la libtest.la ../../cf-serverd/libcf-serverd.la if HAVE_AVAHI_CLIENT if HAVE_AVAHI_COMMON -findhub_test_SOURCES = findhub_test.c \ - ../../cf-agent/findhub.c \ - ../../cf-agent/load_avahi.c - -avahi_config_test_SOURCES = avahi_config_test.c \ - ../../cf-serverd/server_common.c \ - ../../cf-serverd/server_tls.c \ - ../../cf-serverd/server.c \ - ../../cf-serverd/server_transform.c \ - ../../cf-serverd/cf-serverd-enterprise-stubs.c \ - ../../cf-serverd/server_access.c \ - ../../cf-serverd/server_classic.c \ - ../../cf-serverd/strlist.c +findhub_test_SOURCES = findhub_test.c + +avahi_config_test_SOURCES = avahi_config_test.c avahi_config_test_LDADD = ../../libpromises/libpromises.la libtest.la endif @@ -252,31 +203,18 @@ db_test_SOURCES = db_test.c 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 = libtest.la libdb.la +db_concurrent_test_LDADD = libtest.la ../../libpromises/libpromises.la -lastseen_test_SOURCES = lastseen_test.c \ - ../../libntech/libutils/statistics.c -#lastseen_test_CPPFLAGS = $(libdb_la_CPPFLAGS) +lastseen_test_SOURCES = lastseen_test.c lastseen_test_LDADD = libtest.la ../../libpromises/libpromises.la lastseen_migration_test_SOURCES = lastseen_migration_test.c -#lastseen_migration_test_CPPFLAGS = $(libdb_la_CPPFLAGS) lastseen_migration_test_LDADD = ../../libpromises/libpromises.la CLEANFILES = *.gcno *.gcda cfengine-enterprise.so -package_versions_compare_test_SOURCES = package_versions_compare_test.c \ - ../../cf-agent/package_module.c \ - ../../cf-agent/verify_packages.c \ - ../../cf-agent/verify_new_packages.c \ - ../../cf-agent/vercmp.c \ - ../../cf-agent/vercmp_internal.c \ - ../../cf-agent/retcode.c \ - ../../libpromises/match_scope.c - -#package_versions_compare_test_CPPFLAGS = $(AM_CPPFLAGS) -package_versions_compare_test_LDADD = ../../libpromises/libpromises.la \ +package_versions_compare_test_SOURCES = package_versions_compare_test.c +package_versions_compare_test_LDADD = ../../cf-agent/libcf-agent.la ../../libpromises/libpromises.la \ libtest.la files_copy_test_SOURCES = files_copy_test.c @@ -285,15 +223,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 \ - ../../libpromises/patches.c \ - ../../libpromises/constants.c -logging_test_LDADD = libtest.la ../../libntech/libutils/libutils.la +logging_test_SOURCES = logging_test.c +logging_test_LDADD = libtest.la ../../libpromises/libpromises.la -connection_management_test_SOURCES = connection_management_test.c \ - ../../cf-serverd/server_common.c \ - ../../cf-serverd/server_tls.c +connection_management_test_SOURCES = connection_management_test.c connection_management_test_LDADD = ../../libpromises/libpromises.la \ libtest.la \ ../../cf-serverd/libcf-serverd.la @@ -310,11 +243,8 @@ if LINUX check_PROGRAMS += linux_process_test -linux_process_test_SOURCES = linux_process_test.c \ - ../../libpromises/process_unix.c \ - ../../libpromises/process_linux.c \ - ../../libntech/libutils/file_lib.c -linux_process_test_LDADD = libtest.la ../../libntech/libutils/libutils.la +linux_process_test_SOURCES = linux_process_test.c +linux_process_test_LDADD = libtest.la ../../libpromises/libpromises.la endif @@ -325,11 +255,8 @@ check_PROGRAMS += aix_process_test # because they provide dummy versions of some standard functions. set_domainname_test_LDFLAGS = -Wl,-bexpall evalfunction_test_LDFLAGS = -Wl,-bexpall -aix_process_test_SOURCES = aix_process_test.c \ - ../../libpromises/process_unix.c \ - ../../libpromises/process_aix.c \ - ../../libntech/libutils/file_lib.c -aix_process_test_LDADD = libtest.la ../../libntech/libutils/libutils.la +aix_process_test_SOURCES = aix_process_test.c +aix_process_test_LDADD = libtest.la ../../libpromises/libpromises.la endif @@ -337,67 +264,54 @@ if SOLARIS check_PROGRAMS += solaris_process_test -solaris_process_test_SOURCES = solaris_process_test.c \ - ../../libpromises/process_unix.c \ - ../../libpromises/process_solaris.c \ - ../../libntech/libutils/file_lib.c -solaris_process_test_LDADD = libtest.la ../../libntech/libutils/libutils.la +solaris_process_test_SOURCES = solaris_process_test.c +solaris_process_test_LDADD = libtest.la ../../libpromises/libpromises.la endif -process_terminate_unix_test_SOURCES = process_terminate_unix_test.c \ - ../../libpromises/process_unix.c -process_terminate_unix_test_LDADD = libtest.la ../../libntech/libutils/libutils.la +process_terminate_unix_test_SOURCES = process_terminate_unix_test.c +process_terminate_unix_test_LDADD = libtest.la ../../libpromises/libpromises.la -exec_config_test_SOURCES = exec-config-test.c \ - ../../cf-execd/exec-config.c ../../cf-execd/execd-config.c -exec_config_test_LDADD = libtest.la ../../libpromises/libpromises.la +exec_config_test_SOURCES = exec-config-test.c +exec_config_test_LDADD = libtest.la ../../libpromises/libpromises.la ../../cf-execd/libcf-execd.la sysinfo_test_LDADD = libtest.la \ ../../libenv/libenv.la \ ../../libpromises/libpromises.la -mon_cpu_test_SOURCES = mon_cpu_test.c \ - ../../cf-monitord/mon.h \ - ../../cf-monitord/mon_cpu.c -mon_cpu_test_LDADD = ../../libpromises/libpromises.la libtest.la +mon_cpu_test_SOURCES = mon_cpu_test.c +mon_cpu_test_LDADD = ../../libpromises/libpromises.la libtest.la ../../cf-monitord/libcf-monitord.la -mon_load_test_SOURCES = mon_load_test.c \ - ../../cf-monitord/mon.h \ - ../../cf-monitord/mon_load.c -mon_load_test_LDADD = ../../libpromises/libpromises.la libtest.la +mon_load_test_SOURCES = mon_load_test.c +mon_load_test_LDADD = ../../libpromises/libpromises.la libtest.la ../../cf-monitord/libcf-monitord.la -mon_processes_test_SOURCES = mon_processes_test.c \ - ../../cf-monitord/mon.h \ - ../../cf-monitord/mon_processes.c -mon_processes_test_LDADD = ../../libpromises/libpromises.la libtest.la +mon_processes_test_SOURCES = mon_processes_test.c +mon_processes_test_LDADD = ../../libpromises/libpromises.la libtest.la ../../cf-monitord/libcf-monitord.la key_test_SOURCES = key_test.c key_test_LDADD = ../../libpromises/libpromises.la \ - ../../libntech/libutils/libutils.la \ libtest.la -strlist_test_SOURCES = strlist_test.c \ - ../../cf-serverd/strlist.c \ - ../../cf-serverd/strlist.h +strlist_test_SOURCES = strlist_test.c +strlist_test_LDADD = ../../libpromises/libpromises.la libtest.la ../../cf-serverd/libcf-serverd.la verify_databases_test_LDADD = ../../cf-agent/libcf-agent.la libtest.la iteration_test_SOURCES = iteration_test.c cf_upgrade_test_SOURCES = cf_upgrade_test.c \ - ../../cf-upgrade/alloc-mini.c \ - ../../cf-upgrade/alloc-mini.h \ - ../../cf-upgrade/command_line.c \ - ../../cf-upgrade/command_line.h \ - ../../cf-upgrade/configuration.c \ - ../../cf-upgrade/configuration.h \ - ../../cf-upgrade/log.c ../../cf-upgrade/log.h \ - ../../cf-upgrade/process.c ../../cf-upgrade/process.h \ - ../../cf-upgrade/update.c \ - ../../cf-upgrade/update.h +- ../../cf-upgrade/alloc-mini.c \ +- ../../cf-upgrade/alloc-mini.h \ +- ../../cf-upgrade/command_line.c \ +- ../../cf-upgrade/command_line.h \ +- ../../cf-upgrade/configuration.c \ +- ../../cf-upgrade/configuration.h \ +- ../../cf-upgrade/log.c ../../cf-upgrade/log.h \ +- ../../cf-upgrade/process.c ../../cf-upgrade/process.h \ +- ../../cf-upgrade/update.c \ +- ../../cf-upgrade/update.h cf_upgrade_test_CPPFLAGS = -I../../cf-upgrade -I../../libntech/libutils -I../../ -cf_upgrade_test_LDADD = libtest.la ../../libntech/libcompat/libcompat.la +cf_upgrade_test_LDADD = libtest.la ../../libpromises/libpromises.la if !NT check_PROGRAMS += nfs_test From 6776fb15a2ccf589ecb6013e821a566f216be6f5 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 9 May 2025 14:39:48 +0200 Subject: [PATCH 12/13] Try this Signed-off-by: Lars Erik Wik --- tests/unit/process_terminate_unix_test.c | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/unit/process_terminate_unix_test.c b/tests/unit/process_terminate_unix_test.c index 3dffc6b1b4..d3f61b7f4a 100644 --- a/tests/unit/process_terminate_unix_test.c +++ b/tests/unit/process_terminate_unix_test.c @@ -15,30 +15,30 @@ /* Settings */ -time_t proc_1_start_time; -time_t proc_1_reaction_time; -bool proc_1_int_blocked; -bool proc_1_term_blocked; -bool proc_1_have_access; +static time_t proc_1_start_time; +static time_t proc_1_reaction_time; +static bool proc_1_int_blocked; +static bool proc_1_term_blocked; +static bool proc_1_have_access; /* State */ -time_t current_time; +static time_t current_time; -bool exists; -bool stopped; +static bool exists; +static bool stopped; -time_t signal_time; -bool has_stop; -bool has_cont; -bool has_int; -bool has_term; -bool has_kill; +static time_t signal_time; +static bool has_stop; +static bool has_cont; +static bool has_int; +static bool has_term; +static bool has_kill; /* History */ -bool was_stopped; -int exit_signal; +static bool was_stopped; +static int exit_signal; void InitTime(void) { From 63aa9702590aa5c8e84b30fdddfc561314b607e3 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 9 May 2025 13:54:01 +0200 Subject: [PATCH 13/13] Fix macOS Ticket: None Changelog: None Signed-off-by: Lars Erik Wik --- tests/unit/Makefile.am | 2 +- tests/unit/logging_test.c | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 98ebce07e8..5c4d6b76b8 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -224,7 +224,7 @@ sort_test_SOURCES = sort_test.c sort_test_LDADD = libtest.la ../../libpromises/libpromises.la logging_test_SOURCES = logging_test.c -logging_test_LDADD = libtest.la ../../libpromises/libpromises.la +logging_test_LDADD = libtest.la ../../libntech/libutils/libutils.la connection_management_test_SOURCES = connection_management_test.c connection_management_test_LDADD = ../../libpromises/libpromises.la \ diff --git a/tests/unit/logging_test.c b/tests/unit/logging_test.c index cc4468edd0..bdd3b4474b 100644 --- a/tests/unit/logging_test.c +++ b/tests/unit/logging_test.c @@ -6,9 +6,27 @@ #include #include +/** + * To avoid linking issues with libpromises.so in logging_test, specifically + * when mocking the sendto function, the files syslog_client.c, patches.c, and + * constants.c must be directly included into test_logging.c. + * + * This direct inclusion is necessary because: + * - Linking with libpromises.so while mocking sendto would cause macOS to use + * the incorrect function during unit testing. + * - Adding these files to test_logging_SOURCES is not feasible due to a bug in + * the current autotools version used by the bootstrap PR machine. With + * subdir_objects enabled, this would cause the distclean target to fail by + * attempting to delete generated files twice. + */ +#include +#include +#include + + // This test uses syslog_client.c directly, without libpromises, // this is necessary so we don't get "undefined symbol" errors: -char VFQNAME[CF_MAXVARSIZE]; +static char VFQNAME[CF_MAXVARSIZE]; static struct sockaddr *got_address;