Add test to start/stop ICMP ping 05/191805/1
authorYu <jiung.yu@samsung.com>
Wed, 24 Oct 2018 01:53:29 +0000 (10:53 +0900)
committerYu <jiung.yu@samsung.com>
Wed, 24 Oct 2018 05:05:54 +0000 (14:05 +0900)
Change-Id: I04cf58f4faed8c07eb17ab166e0b2ee96180248b
Signed-off-by: Yu Jiung <jiung.yu@samsung.com>
test/inm-test.c

index 0dedd83443ab084c9412d96add086a5cc9f541db..5f32ef758bfa9f5d9dde431d4f33318751aa4d73 100644 (file)
@@ -139,6 +139,8 @@ enum {
 
        CMD_INM_ICMP_PING_INIT,
        CMD_INM_ICMP_PING_DEINIT,
+       CMD_INM_ICMP_PING_START,
+       CMD_INM_ICMP_PING_STOP,
        CMD_MAX,
 };
 
@@ -231,6 +233,8 @@ menu_str_t g_menu_str[] = {
                {CMD_INM_STOP_CHECK_GATEWAY, "CMD_INM_STOP_CHECK_GATEWAY"},
                {CMD_INM_ICMP_PING_INIT, "CMD_INM_ICMP_PING_INIT"},
                {CMD_INM_ICMP_PING_DEINIT, "CMD_INM_ICMP_PING_DEINIT"},
+               {CMD_INM_ICMP_PING_START, "CMD_INM_ICMP_PING_START"},
+               {CMD_INM_ICMP_PING_STOP, "CMD_INM_ICMP_PING_STOP"},
 
                { -1, NULL }, };
 
@@ -1818,13 +1822,14 @@ void test_inm_stop_check_gateway()
 }
 
 static void __icmp_ping_cb (gboolean found,
+               gchar *reason,
                gchar *ip,
                gpointer user_data)
 {
        if (!ip)
                return;
 
-       printf("%s %s\n", ip, found ? "Found" : "Not found");
+       printf("%s %s %s\n", ip, found ? "Found" : "Not found", reason ? reason : "");
 
        return;
 }
@@ -1902,6 +1907,60 @@ void test_inm_icmp_ping_deinit()
        return;
 }
 
+
+void test_inm_icmp_ping_start()
+{
+       char *target_ip;
+       int ret = 0;
+
+       target_ip = NULL;
+
+       printf("Input target IP address :\n");
+       if (scanf(" %18ms", &target_ip) < 1)
+               return;
+       if (strlen(target_ip) <= 0)
+               printf("invalid IP !!\n");
+       else
+               printf("IP: [%s]\n", target_ip);
+
+       ret = inm_icmp_ping_start(target_ip, 0, 0, 0);
+       if (ret == INM_ICMP_PING_ERROR_NONE) {
+               printf(MAKE_GREEN"inm_icmp_ping_start"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"inm_icmp_ping_start: %s ",
+                               print_icmp_ping_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+       free(target_ip);
+}
+
+void test_inm_icmp_ping_stop()
+{
+       char *target_ip;
+       int ret = 0;
+
+       target_ip = NULL;
+
+       printf("Input target IP address :\n");
+       if (scanf(" %18ms", &target_ip) < 1)
+               return;
+       if (strlen(target_ip) <= 0)
+               printf("invalid IP !!\n");
+       else
+               printf("IP: [%s]\n", target_ip);
+
+       ret = inm_icmp_ping_stop(target_ip);
+       if (ret == INM_ICMP_PING_ERROR_NONE) {
+               printf(MAKE_GREEN"inm_icmp_ping_stop"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"inm_icmp_ping_stop: %s ",
+                               print_icmp_ping_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       free(target_ip);
+}
+
 typedef void (*test_func)(void);
 
 typedef struct {
@@ -1995,6 +2054,8 @@ menu_func_s g_menu_func[] = {
 
                {CMD_INM_ICMP_PING_INIT, test_inm_icmp_ping_init},
                {CMD_INM_ICMP_PING_DEINIT, test_inm_icmp_ping_deinit},
+               {CMD_INM_ICMP_PING_START, test_inm_icmp_ping_start},
+               {CMD_INM_ICMP_PING_STOP, test_inm_icmp_ping_stop},
 
 
                { -1, NULL }, };