diff --git a/lib/pengine/tests/status/Makefile.am b/lib/pengine/tests/status/Makefile.am index 6adc9dfbc4..345c280c3c 100644 --- a/lib/pengine/tests/status/Makefile.am +++ b/lib/pengine/tests/status/Makefile.am @@ -1,24 +1,25 @@ # # Copyright 2022 the Pacemaker project contributors # # The version control history for this file may have further details. # # This source code is licensed under the GNU General Public License version 2 # or later (GPLv2+) WITHOUT ANY WARRANTY. # AM_CPPFLAGS = -I$(top_srcdir)/include \ -I$(top_builddir)/include \ -I$(top_srcdir)/lib/common LDADD = $(top_builddir)/lib/common/libcrmcommon_test.la \ $(top_builddir)/lib/pengine/libpe_status_test.la AM_LDFLAGS = $(LDFLAGS_WRAP) include $(top_srcdir)/mk/tap.mk # Add "_test" to the end of all test program names to simplify .gitignore. check_PROGRAMS = pe_find_node_any_test \ pe_find_node_id_test \ pe_find_node_test \ - pe_new_working_set_test + pe_new_working_set_test \ + set_working_set_defaults_test TESTS = $(check_PROGRAMS) diff --git a/lib/pengine/tests/status/set_working_set_defaults_test.c b/lib/pengine/tests/status/set_working_set_defaults_test.c new file mode 100644 index 0000000000..38c9574a81 --- /dev/null +++ b/lib/pengine/tests/status/set_working_set_defaults_test.c @@ -0,0 +1,56 @@ +/* + * Copyright 2022 the Pacemaker project contributors + * + * The version control history for this file may have further details. + * + * This source code is licensed under the GNU Lesser General Public License + * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. + */ + +#include +#include "mock_private.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +static void +check_defaults(void **state) { + uint32_t flags; + pe_working_set_t *data_set = calloc(1, sizeof(pe_working_set_t)); + + set_working_set_defaults(data_set); + + flags = pe_flag_stop_rsc_orphans|pe_flag_symmetric_cluster|pe_flag_stop_action_orphans; + + if (!strcmp(PCMK__CONCURRENT_FENCING_DEFAULT, "true")) { + flags |= pe_flag_concurrent_fencing; + } + + + assert_null(data_set->priv); + assert_int_equal(data_set->order_id, 1); + assert_int_equal(data_set->action_id, 1); + assert_int_equal(data_set->no_quorum_policy, no_quorum_stop); + assert_int_equal(data_set->flags, flags); + + /* Avoid calling pe_free_working_set here so we don't artificially + * inflate the coverage numbers. + */ + free(data_set); +} + +int main(int argc, char **argv) { + const struct CMUnitTest tests[] = { + cmocka_unit_test(check_defaults), + }; + + cmocka_set_message_output(CM_OUTPUT_TAP); + return cmocka_run_group_tests(tests, NULL, NULL); +}