From 912cd6b3becb250c46582c701e617764709137d4 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 12 Mar 2013 18:16:38 +0100 Subject: iptables-unit: Add debug option It is impossible to see the normal unit test output with all DBG() enabled by default. --- tools/iptables-unit.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'tools/iptables-unit.c') diff --git a/tools/iptables-unit.c b/tools/iptables-unit.c index 52aa9193..49b05e04 100644 --- a/tools/iptables-unit.c +++ b/tools/iptables-unit.c @@ -296,14 +296,51 @@ static void test_nat_basic1(void) g_free(service); } +static gchar *option_debug = NULL; + +static gboolean parse_debug(const char *key, const char *value, + gpointer user_data, GError **error) +{ + if (value) + option_debug = g_strdup(value); + else + option_debug = g_strdup("*"); + + return TRUE; +} + +static GOptionEntry options[] = { + { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG, + G_OPTION_ARG_CALLBACK, parse_debug, + "Specify debug options to enable", "DEBUG" }, + { NULL }, +}; + int main(int argc, char *argv[]) { + GOptionContext *context; + GError *error = NULL; int err; g_test_init(&argc, &argv, NULL); - __connman_log_init(argv[0], "*", FALSE, FALSE, + context = g_option_context_new(NULL); + g_option_context_add_main_entries(context, options, NULL); + + if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) { + if (error != NULL) { + g_printerr("%s\n", error->message); + g_error_free(error); + } else + g_printerr("An unknown error occurred\n"); + return 1; + } + + g_option_context_free(context); + + __connman_log_init(argv[0], option_debug, FALSE, FALSE, "Unit Tests Connection Manager", VERSION); + __connman_iptables_init(); __connman_nat_init(); @@ -323,5 +360,7 @@ int main(int argc, char *argv[]) __connman_nat_cleanup(); __connman_iptables_cleanup(); + g_free(option_debug); + return err; } -- cgit v1.2.3