15 #include "../../crmcommon_private.h" 38 mk_fake_text_output(
char **argv) {
46 retval->
init = fake_text_init;
62 teardown(
void **state) {
68 invalid_entries(
void **state) {
75 {
"",
"", null_message_fn },
76 {
"", NULL, null_message_fn },
84 assert_int_equal(g_hash_table_size(out->
messages), 0);
90 valid_entries(
void **state) {
94 {
"msg1",
"text", null_message_fn },
95 {
"msg2",
"text", null_message_fn_2 },
102 assert_int_equal(g_hash_table_size(out->
messages), 2);
103 assert_ptr_equal(g_hash_table_lookup(out->
messages,
"msg1"), null_message_fn);
104 assert_ptr_equal(g_hash_table_lookup(out->
messages,
"msg2"), null_message_fn_2);
110 duplicate_message_ids(
void **state) {
114 {
"msg1",
"text", null_message_fn },
115 {
"msg1",
"text", null_message_fn_2 },
122 assert_int_equal(g_hash_table_size(out->
messages), 1);
123 assert_ptr_equal(g_hash_table_lookup(out->
messages,
"msg1"), null_message_fn_2);
129 duplicate_functions(
void **state) {
133 {
"msg1",
"text", null_message_fn },
134 {
"msg2",
"text", null_message_fn },
141 assert_int_equal(g_hash_table_size(out->
messages), 2);
142 assert_ptr_equal(g_hash_table_lookup(out->
messages,
"msg1"), null_message_fn);
143 assert_ptr_equal(g_hash_table_lookup(out->
messages,
"msg2"), null_message_fn);
149 default_handler(
void **state) {
153 {
"msg1",
"default", null_message_fn },
160 assert_int_equal(g_hash_table_size(out->
messages), 1);
161 assert_ptr_equal(g_hash_table_lookup(out->
messages,
"msg1"), null_message_fn);
167 override_default_handler(
void **state) {
171 {
"msg1",
"default", null_message_fn },
172 {
"msg1",
"text", null_message_fn_2 },
179 assert_int_equal(g_hash_table_size(out->
messages), 1);
180 assert_ptr_equal(g_hash_table_lookup(out->
messages,
"msg1"), null_message_fn_2);
186 cmocka_unit_test_setup_teardown(invalid_entries, setup, teardown),
187 cmocka_unit_test_setup_teardown(valid_entries, setup, teardown),
188 cmocka_unit_test_setup_teardown(duplicate_message_ids, setup, teardown),
189 cmocka_unit_test_setup_teardown(duplicate_functions, setup, teardown),
190 cmocka_unit_test_setup_teardown(default_handler, setup, teardown),
191 cmocka_unit_test_setup_teardown(override_default_handler, setup, teardown))
void pcmk__register_messages(pcmk__output_t *out, const pcmk__message_entry_t *table)
int(* message)(pcmk__output_t *out, const char *message_id,...)
const char * fmt_name
The name of this output formatter.
void pcmk__register_message(pcmk__output_t *out, const char *message_id, pcmk__message_fn_t fn)
PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(not_found), cmocka_unit_test(find_attrB), cmocka_unit_test(find_attrA_matching))
int pcmk__call_message(pcmk__output_t *out, const char *message_id,...)
GHashTable * messages
Custom messages that are currently registered on this formatter.
G_GNUC_INTERNAL int pcmk__bare_output_new(pcmk__output_t **out, const char *fmt_name, const char *filename, char **argv)
Formatted output for pacemaker tools.
void(* register_message)(pcmk__output_t *out, const char *message_id, pcmk__message_fn_t fn)
void(* free_priv)(pcmk__output_t *out)
bool(* init)(pcmk__output_t *out)
#define pcmk__assert_asserts(stmt)
int pcmk__register_format(GOptionGroup *group, const char *name, pcmk__output_factory_t create, const GOptionEntry *options)
void pcmk__output_free(pcmk__output_t *out)
void pcmk__unregister_formats(void)
This structure contains everything that makes up a single output formatter.