summaryrefslogtreecommitdiff
path: root/logview/src/tests
diff options
context:
space:
mode:
authormonsta <[email protected]>2015-09-09 10:46:57 +0300
committermonsta <[email protected]>2015-09-09 10:46:57 +0300
commitc9cadcd53d03e73475dd266aad223a1ebc9229b5 (patch)
tree0166a7c33476e9d9a4a2a3a3b66bde69594dc242 /logview/src/tests
parent09a33e1feefbf5bc06eb5692b03c894c3b48daa9 (diff)
downloadmate-utils-c9cadcd53d03e73475dd266aad223a1ebc9229b5.tar.bz2
mate-utils-c9cadcd53d03e73475dd266aad223a1ebc9229b5.tar.xz
logview: move sources to src/ subdir
Diffstat (limited to 'logview/src/tests')
-rw-r--r--logview/src/tests/Makefile.am9
-rw-r--r--logview/src/tests/test-reader.c60
2 files changed, 69 insertions, 0 deletions
diff --git a/logview/src/tests/Makefile.am b/logview/src/tests/Makefile.am
new file mode 100644
index 00000000..b7b668c3
--- /dev/null
+++ b/logview/src/tests/Makefile.am
@@ -0,0 +1,9 @@
+AM_CPPFLAGS = \
+ $(GLIB_CFLAGS) \
+ $(GIO_CFLAGS) \
+ -I../
+
+noinst_PROGRAMS = test-reader
+
+test_reader_SOURCES = test-reader.c ../logview-log.c ../logview-utils.c
+test_reader_LDADD = $(GLIB_LIBS) $(GIO_LIBS) $(Z_LIBS) -lm
diff --git a/logview/src/tests/test-reader.c b/logview/src/tests/test-reader.c
new file mode 100644
index 00000000..b9ef5d40
--- /dev/null
+++ b/logview/src/tests/test-reader.c
@@ -0,0 +1,60 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "../logview-log.h"
+#include "../logview-utils.h"
+
+#include <glib.h>
+#include <gio/gio.h>
+
+static GMainLoop *loop;
+
+static void
+new_lines_cb (LogviewLog *log,
+ const char **lines,
+ GSList *new_days,
+ GError *error,
+ gpointer user_data)
+{
+ int i;
+ guint8 day;
+ Day *day_s;
+ GSList *days, *l;
+
+ for (i = 0; lines[i]; i++) {
+ g_print ("line %d: %s\n", i, lines[i]);
+ }
+ g_print ("outside read, lines no %u\n", logview_log_get_cached_lines_number (log));
+
+ days = log_read_dates (lines, logview_log_get_timestamp (log));
+ g_print ("\ndays %p\n", days);
+
+ for (l = days; l; l = l->next) {
+ day_s = l->data;
+ g_print ("\nday %u month %u\n", g_date_get_day (day_s->date), g_date_get_month (day_s->date));
+ }
+
+ g_object_unref (log);
+
+ g_main_loop_quit (loop);
+}
+
+static void
+callback (LogviewLog *log,
+ GError *error,
+ gpointer user_data)
+{
+ g_print ("callback! err %p, log %p\n", error, log);
+
+ logview_log_read_new_lines (log, NULL, new_lines_cb, NULL);
+}
+
+int main (int argc, char **argv)
+{
+ loop = g_main_loop_new (NULL, FALSE);
+ logview_log_create ("/var/log/dpkg.log.2.gz", callback, NULL);
+ g_main_loop_run (loop);
+
+ return 0;
+}