diff options
author | rbuj <[email protected]> | 2020-05-19 13:08:51 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-06-10 12:17:26 +0200 |
commit | feff11d4cd8d257aa940cfb48dd91b8d1e1f3929 (patch) | |
tree | 0f377680cd13de09c303b56ada5e2dc3fb1bdb8c /logview | |
parent | 99f23bd4f1058110af946d7068b3b4cc369dbad3 (diff) | |
download | mate-utils-feff11d4cd8d257aa940cfb48dd91b8d1e1f3929.tar.bz2 mate-utils-feff11d4cd8d257aa940cfb48dd91b8d1e1f3929.tar.xz |
logview: Use test-reader test with log file path
Diffstat (limited to 'logview')
-rw-r--r-- | logview/src/tests/test-reader.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/logview/src/tests/test-reader.c b/logview/src/tests/test-reader.c index b9ef5d40..e4e9dd9d 100644 --- a/logview/src/tests/test-reader.c +++ b/logview/src/tests/test-reader.c @@ -52,9 +52,48 @@ callback (LogviewLog *log, int main (int argc, char **argv) { + GError *error = NULL; + gchar *log_filename = NULL; + gchar *usage; + GOptionContext *context; + GOptionEntry entries [] = + { { "file", 'f', 0, G_OPTION_ARG_FILENAME, &log_filename, "The log file, e.g. /var/log/dpkg.log.2.gz", NULL }, + { NULL } }; + + context = g_option_context_new (NULL); + g_option_context_add_main_entries (context, entries, NULL); + + if (!g_option_context_parse (context, &argc, &argv, &error)) { + if (error) { + g_printerr ("%s\n\n", error->message); + g_error_free (error); + } + goto arg_error; + } + + if (!log_filename) { + g_printerr ("ERROR: You must specify the log file.\n\n"); + goto arg_error; + } + + g_option_context_free (context); + loop = g_main_loop_new (NULL, FALSE); - logview_log_create ("/var/log/dpkg.log.2.gz", callback, NULL); + logview_log_create (log_filename, callback, NULL); + g_main_loop_run (loop); + g_main_loop_unref (loop); + + g_free (log_filename); + return 0; + +arg_error: + usage = g_option_context_get_help (context, TRUE, NULL); + g_printerr ("%s", usage); + g_free (usage); + g_option_context_free (context); + + return 1; } |