summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2013-03-12 17:16:38 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-03-18 12:31:26 (GMT)
commit912cd6b3becb250c46582c701e617764709137d4 (patch)
tree62edf1dbca4861e979289990507e251d1a5043c9 /tools
parent2111d6e8f63a03b6945ab8005ea437c63b2bd6b8 (diff)
downloadconnman-912cd6b3becb250c46582c701e617764709137d4.zip
connman-912cd6b3becb250c46582c701e617764709137d4.tar.gz
connman-912cd6b3becb250c46582c701e617764709137d4.tar.bz2
iptables-unit: Add debug option
It is impossible to see the normal unit test output with all DBG() enabled by default.
Diffstat (limited to 'tools')
-rw-r--r--tools/iptables-unit.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/tools/iptables-unit.c b/tools/iptables-unit.c
index 52aa919..49b05e0 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;
}