From de8993575c0a336e097d18c984252cb20d9f2f86 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Tue, 2 Apr 2019 08:56:28 -0400 Subject: [PATCH] efl_check: add API to expect a error Summary: sometimes it is not enough to just disable aborting on critical error messages. Sometimes it is better to explicitly expect an error, and fail the testcase if there is no error. This is used in later commits here. Depends on D8417 Reviewers: YOhoho, segfaultxavi, zmike, woohyun, Jaehyun_Cho Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8519 --- src/tests/efl_check.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/tests/efl_check.h b/src/tests/efl_check.h index d5b0d2fcc2..e4f3e7a202 100644 --- a/src/tests/efl_check.h +++ b/src/tests/efl_check.h @@ -53,6 +53,20 @@ eina_log_abort_on_critical_set(___val); \ } while (0) +#define EXPECT_ERROR_START \ + do { \ + DISABLE_ABORT_ON_CRITICAL_START; \ + Eina_Bool expect_error_start = EINA_FALSE; \ + do { \ + eina_log_print_cb_set(_efl_test_expect_error, &expect_error_start); \ + } while(0) + + +#define EXPECT_ERROR_END \ + ck_assert_int_eq(expect_error_start, EINA_TRUE); \ + DISABLE_ABORT_ON_CRITICAL_END; \ + } while(0) + typedef struct _Efl_Test_Case Efl_Test_Case; struct _Efl_Test_Case { @@ -62,6 +76,15 @@ struct _Efl_Test_Case static int timeout_pid = 0; +EINA_UNUSED static void +_efl_test_expect_error(const Eina_Log_Domain *d EINA_UNUSED, Eina_Log_Level level, const char *file EINA_UNUSED, const char *fnc, int line EINA_UNUSED, const char *fmt EINA_UNUSED, void *data, va_list args EINA_UNUSED) +{ + Eina_Bool *error = (Eina_Bool*) data; + if (level == EINA_LOG_LEVEL_ERR) *error = EINA_TRUE; + + printf("EXPECTED ERROR %s\n", fnc); +} + static void _efl_tests_list(const Efl_Test_Case *etc) {