void __test_cursors(Journald *journald) { gchar *cursor; gint result = journald_get_cursor(journald, &cursor); assert_string(cursor, "test_data1", ASSERTION_ERROR("Bad cursor fetched"));\ g_free(cursor); result = journald_next(journald); assert_gint(result, 1, ASSERTION_ERROR("Bad next step result")); result = journald_get_cursor(journald, &cursor); assert_string(cursor, "test_data2", ASSERTION_ERROR("Bad cursor fetched")); g_free(cursor); result = journald_next(journald); assert_gint(result, 0, ASSERTION_ERROR("Should not contain more elements")); result = journald_seek_cursor(journald, "test_data1"); assert_gint(result, 0, ASSERTION_ERROR("Should find cursor")); result = journald_next(journald); assert_gint(result, 1, ASSERTION_ERROR("Bad next step result")); result = journald_get_cursor(journald, &cursor); assert_string(cursor, "test_data1", ASSERTION_ERROR("Bad cursor fetched")); g_free(cursor); result = journald_seek_cursor(journald, "test_data2"); assert_gint(result, 0, ASSERTION_ERROR("Should find cursor")); result = journald_next(journald); assert_gint(result, 1, ASSERTION_ERROR("Bad next step result")); result = journald_get_cursor(journald, &cursor); assert_string(cursor, "test_data2", ASSERTION_ERROR("Bad cursor fetched")); g_free(cursor); }
static gchar * _get_cursor(JournalReader *self) { gchar *cursor; journald_get_cursor(self->journal, &cursor); return cursor; }
void __test_cursors(Journald *journald) { gchar *cursor; journald_seek_head(journald); journald_next(journald); gint result = journald_get_cursor(journald, &cursor); cr_assert_str_eq(cursor, "test_data1", "%s", "Bad cursor fetched"); \ g_free(cursor); result = journald_next(journald); cr_assert_eq(result, 1, "%s", "Bad next step result"); result = journald_get_cursor(journald, &cursor); cr_assert_str_eq(cursor, "test_data2", "%s", "Bad cursor fetched"); g_free(cursor); result = journald_next(journald); cr_assert_eq(result, 0, "%s", "Should not contain more elements"); result = journald_seek_cursor(journald, "test_data1"); cr_assert_eq(result, 0, "%s", "Should find cursor"); result = journald_next(journald); cr_assert_eq(result, 1, "%s", "Bad next step result"); result = journald_get_cursor(journald, &cursor); cr_assert_str_eq(cursor, "test_data1", "%s", "Bad cursor fetched"); g_free(cursor); result = journald_seek_cursor(journald, "test_data2"); cr_assert_eq(result, 0, "%s", "Should find cursor"); result = journald_next(journald); cr_assert_eq(result, 1, "%s", "Bad next step result"); result = journald_get_cursor(journald, &cursor); cr_assert_str_eq(cursor, "test_data2", "%s", "Bad cursor fetched"); g_free(cursor); }
void _test_program_field_test(TestCase *self, TestSource *src, LogMessage *msg) { Journald *journal = self->user_data; gchar *cursor; journald_get_cursor(journal, &cursor); if (strcmp(cursor, "no SYSLOG_IDENTIFIER") != 0) { cr_assert_str_eq(log_msg_get_value(msg, LM_V_PROGRAM, NULL), "syslog_program", "%s", "Bad program name"); g_free(cursor); } else { cr_assert_str_eq(log_msg_get_value(msg, LM_V_PROGRAM, NULL), "comm_program", "%s", "Bad program name"); g_free(cursor); test_source_finish_tc(src); } }