void vprint_message(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
void vprint_error(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
+enum cm_message_output {
+ CM_OUTPUT_STDOUT,
+};
+
+/**
+ * @brief Function to set the output format for a test.
+ *
+ * The ouput format for the test can either be set globally using this
+ * function or overriden with environment variable CMOCKA_MESSAGE_OUTPUT.
+ *
+ * The environment variable can be set to either STDOUT or SUBUNIT.
+ *
+ * @param[in] output The output format to use for the test.
+ *
+ */
+void cmocka_set_message_output(enum cm_message_output output);
+
/** @} */
#endif /* CMOCKA_H_ */
/* List of all currently allocated blocks. */
static CMOCKA_THREAD ListNode global_allocated_blocks;
+static enum cm_message_output global_msg_output = CM_OUTPUT_STDOUT;
+
#ifndef _WIN32
/* Signals caught by exception_handler(). */
static const int exception_signals[] = {
static void cmprintf_group_start(const size_t num_tests)
{
- cmprintf_group_start_standard(num_tests);
+ switch (global_msg_output) {
+ case CM_OUTPUT_STDOUT:
+ cmprintf_group_start_standard(num_tests);
+ break;
+ }
}
static void cmprintf_group_finish(size_t total_executed,
size_t total_errors,
struct CMUnitTestState *cm_tests)
{
- cmprintf_group_finish_standard(total_executed,
- total_passed,
- total_failed,
- total_errors,
- cm_tests);
+ switch (global_msg_output) {
+ case CM_OUTPUT_STDOUT:
+ cmprintf_group_finish_standard(total_executed,
+ total_passed,
+ total_failed,
+ total_errors,
+ cm_tests);
+ break;
+ }
}
static void cmprintf(enum cm_printf_type type,
const char *test_name,
const char *error_message)
{
- cmprintf_standard(type, test_name, error_message);
+ switch (global_msg_output) {
+ case CM_OUTPUT_STDOUT:
+ cmprintf_standard(type, test_name, error_message);
+ break;
+ }
+}
+
+void cmocka_set_message_output(enum cm_message_output output)
+{
+ global_msg_output = output;
}
/****************************************************************************