17 static bool init_succeeds =
true;
31 mk_fake_text_output(
char **argv) {
39 retval->
init = fake_text_init;
55 teardown(
void **state) {
61 empty_formatters(
void **state) {
68 invalid_params(
void **state) {
74 no_such_format(
void **state) {
81 create_fails(
void **state) {
94 fopen_fails(
void **state) {
98 #if defined(HAVE_FOPEN64) && defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) && (SIZEOF_LONG < 8) 99 expect_string(__wrap_fopen64, pathname,
"destfile");
100 expect_string(__wrap_fopen64, mode,
"w");
101 will_return(__wrap_fopen64, EPERM);
114 init_fails(
void **state) {
117 init_succeeds =
false;
119 init_succeeds =
true;
123 everything_succeeds(
void **state) {
127 assert_string_equal(out->
fmt_name,
"text");
128 assert_ptr_equal(out->
dest, stdout);
129 assert_false(out->
quiet);
131 assert_string_equal(getenv(
"OCF_OUTPUT_FORMAT"),
"text");
137 no_fmt_name_given(
void **state) {
141 assert_string_equal(out->
fmt_name,
"text");
147 cmocka_unit_test(empty_formatters),
148 cmocka_unit_test_setup_teardown(invalid_params, setup, teardown),
149 cmocka_unit_test_setup_teardown(no_such_format, setup, teardown),
150 cmocka_unit_test_setup_teardown(create_fails, setup, teardown),
151 cmocka_unit_test_setup_teardown(init_fails, setup, teardown),
152 cmocka_unit_test_setup_teardown(fopen_fails, setup, teardown),
153 cmocka_unit_test_setup_teardown(everything_succeeds, setup, teardown),
154 cmocka_unit_test_setup_teardown(no_fmt_name_given, setup, teardown))
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)
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
int pcmk__call_message(pcmk__output_t *out, const char *message_id,...)
GHashTable * messages
Custom messages that are currently registered on this formatter.
Formatted output for pacemaker tools.
void(* register_message)(pcmk__output_t *out, const char *message_id, pcmk__message_fn_t fn)
bool quiet
Should this formatter supress most output?
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)
FILE * dest
Where output should be written.
void pcmk__output_free(pcmk__output_t *out)
void pcmk__unregister_formats(void)
FILE * __wrap_fopen(const char *pathname, const char *mode)
This structure contains everything that makes up a single output formatter.
int pcmk__output_new(pcmk__output_t **out, const char *fmt_name, const char *filename, char **argv)
void * __wrap_calloc(size_t nmemb, size_t size)