Skip to content

Commit ff54de3

Browse files
dcpleungcarlescufi
authored andcommitted
tests: logging/log_api: add bits to test backend events
This adds a few bits to the log_api tests to test backend event notifications. Signed-off-by: Daniel Leung <[email protected]>
1 parent d0d6e11 commit ff54de3

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/subsys/logging/log_api/src/mock_backend.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ void mock_log_backend_validate(const struct log_backend *backend, bool panic)
102102
zassert_equal(mock->msg_rec_idx, mock->msg_proc_idx,
103103
"%p Recored:%d, Got: %d", mock, mock->msg_rec_idx, mock->msg_proc_idx);
104104
zassert_equal(mock->panic, panic, NULL);
105+
106+
#if defined(CONFIG_LOG_MODE_DEFERRED) && \
107+
defined(CONFIG_LOG_PROCESS_THREAD)
108+
zassert_true(mock->evt_notified, NULL);
109+
#endif
105110
}
106111

107112
struct test_str {
@@ -200,9 +205,26 @@ static void dropped(const struct log_backend *const backend, uint32_t cnt)
200205
}
201206

202207

208+
#if defined(CONFIG_LOG_MODE_DEFERRED) && \
209+
defined(CONFIG_LOG_PROCESS_THREAD)
210+
static void notify(const struct log_backend *const backend,
211+
enum log_backend_evt event,
212+
union log_backend_evt_arg *arg)
213+
{
214+
struct mock_log_backend *mock = backend->cb->ctx;
215+
216+
mock->evt_notified = true;
217+
}
218+
#endif
219+
203220
const struct log_backend_api mock_log_backend_api = {
204221
.process = process,
205222
.panic = panic,
206223
.init = mock_init,
207224
.dropped = IS_ENABLED(CONFIG_LOG_MODE_IMMEDIATE) ? NULL : dropped,
225+
226+
#if defined(CONFIG_LOG_MODE_DEFERRED) && \
227+
defined(CONFIG_LOG_PROCESS_THREAD)
228+
.notify = notify,
229+
#endif
208230
};

tests/subsys/logging/log_api/src/mock_backend.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ struct mock_log_backend {
3434
int msg_proc_idx;
3535
int exp_drop_cnt;
3636
int drop_cnt;
37+
38+
#if defined(CONFIG_LOG_MODE_DEFERRED) && \
39+
defined(CONFIG_LOG_PROCESS_THREAD)
40+
bool evt_notified;
41+
#endif
3742
};
3843

3944
void mock_log_backend_reset(const struct log_backend *backend);

0 commit comments

Comments
 (0)