[wifi_manager_test] Support for AP names that include spaces 98/226798/1 submit/tizen/20200324.061720
authorJaehyun Kim <jeik01.kim@samsung.com>
Thu, 5 Mar 2020 10:19:30 +0000 (19:19 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Thu, 5 Mar 2020 10:19:30 +0000 (19:19 +0900)
Change-Id: I0246933b8482526d265f2fc4086b373ee9a96364
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
test/wifi_manager_test.c

index 92fa6b6..c1566cc 100755 (executable)
@@ -372,7 +372,7 @@ static bool __test_found_connect_ap_callback(wifi_manager_ap_h ap, void *user_da
                if (required) {
                        char passphrase[100];
                        printf("Input passphrase for %s : ", ap_name);
-                       rv = scanf("%99s", passphrase);
+                       rv = scanf(" %99s", passphrase);
 
                        rv = wifi_manager_ap_set_passphrase(ap, passphrase);
                        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -413,7 +413,7 @@ static bool __test_found_connect_wps_callback(wifi_manager_ap_h ap, void *user_d
                char pin[32] = {0,};
 
                printf("%s - Input WPS method (1:PBC, 2:PIN) :\n", ap_name);
-               rv = scanf("%9d", &user_sel);
+               rv = scanf(" %9d", &user_sel);
 
                switch (user_sel) {
                case 1:
@@ -559,7 +559,7 @@ static bool __test_found_eap_ap_callback(wifi_manager_ap_h ap, void *user_data)
 
                char input_str1[100];
                printf("Input user name for %s : ", ap_name);
-               rv = scanf("%99s", input_str1);
+               rv = scanf(" %99s", input_str1);
 
                char input_str2[100];
                printf("Input password for %s : ", ap_name);
@@ -665,7 +665,7 @@ static bool __test_found_set_autoconnect_ap_callback(wifi_manager_ap_h ap, void
 
        if (__test_compare_ap_name(ap_name, ap_name_part)) {
                printf("[Wi-Fi] Input command number (enable[1], disable[0]) : ");
-               rv = scanf("%9d", &enable);
+               rv = scanf(" %9d", &enable);
                if (rv <= 0) {
                        g_free(ap_name);
                        return false;
@@ -773,7 +773,7 @@ static bool __test_found_change_ip_method_callback(wifi_manager_ap_h ap, void *u
                int prefix_len;
 
                printf("Input new method type (1:dhcp, 2:manual, 3:auto) :\n");
-               rv = scanf("%9d", &method);
+               rv = scanf(" %9d", &method);
                if (rv <= 0) {
                        g_free(ap_name);
                        return false;
@@ -987,7 +987,7 @@ static bool __test_found_change_proxy_method_callback(wifi_manager_ap_h ap, void
                int method;
 
                printf("Input new method type (1:direct, 2:manual, 3:auto) :\n");
-               rv = scanf("%9d", &method);
+               rv = scanf(" %9d", &method);
                if (rv <= 0) {
                        g_free(ap_name);
                        return false;
@@ -1470,7 +1470,7 @@ static bool __test_found_specific_ap_callback(wifi_manager_ap_h ap, void *user_d
                {
                        char passphrase[100];
                        printf("Input passphrase for %s : ", ap_name);
-                       rv = scanf("%99s", passphrase);
+                       rv = scanf(" %99s", passphrase);
 
                        rv = wifi_manager_ap_set_passphrase(ap, passphrase);
                        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -1484,7 +1484,7 @@ static bool __test_found_specific_ap_callback(wifi_manager_ap_h ap, void *user_d
                {
                        char input_str1[100];
                        printf("Input user name for %s : ", ap_name);
-                       rv = scanf("%99s", input_str1);
+                       rv = scanf(" %99s", input_str1);
 
                        char input_str2[100];
                        printf("Input password for %s : ", ap_name);
@@ -1794,7 +1794,7 @@ int test_wifi_manager_connect(void)
                return -1;
 
        printf("Input a part of AP name to connect : ");
-       rv = scanf("%32s", data.ap_name);
+       rv = scanf(" %32[^\n]s", data.ap_name);
        data.is_found = false;
 
        rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_ap_callback, (void*)&data);
@@ -1818,7 +1818,7 @@ int test_wifi_manager_set_ip_conflict_detect_enable()
        bool state = false;
 
        printf("Input '1'(enable)/'0'(disable) for ip conflict detection : ");
-       rv = scanf("%d", &choice);
+       rv = scanf(" %d", &choice);
        if (choice == 1)
                state = true;
        else if (choice == 0)
@@ -1904,7 +1904,7 @@ int test_wifi_manager_set_ip_conflict_period()
        int initial_interval;
 
        printf("Enter initial interval for ARP ping\n");
-       rv = scanf("%d", &initial_interval);
+       rv = scanf(" %d", &initial_interval);
        if (rv <= 0)
                return -1;
 
@@ -1925,7 +1925,7 @@ int test_wifi_manager_connect_specific_ap(void)
        char ap_name[33];
 
        printf("Input a part of specific AP name to connect : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
        if (rv <= 0)
                return -1;
 
@@ -1951,7 +1951,7 @@ int test_wifi_manager_disconnect(void)
                return -1;
 
        printf("Input a part of AP name to disconnect : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
 
        rv = wifi_manager_foreach_found_ap(wifi, __test_found_disconnect_ap_callback, ap_name);
        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -1974,7 +1974,7 @@ int test_wifi_manager_connect_wps(void)
                return -1;
 
        printf("Input a part of AP name to connect by wps : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
 
        rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_wps_callback, ap_name);
        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -1997,7 +1997,7 @@ int test_wifi_manager_forget_ap(void)
                return -1;
 
        printf("Input a part of AP name to forget : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
 
        rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_callback, ap_name);
        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -2021,7 +2021,7 @@ int test_wifi_manager_connect_eap_ap(void)
                return -1;
 
        printf("Input a part of AP name to connect : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
 
        rv = wifi_manager_foreach_found_ap(wifi, __test_found_eap_ap_callback, ap_name);
        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -2044,7 +2044,7 @@ int test_wifi_manager_set_ip_method(void)
                return -1;
 
        printf("Input a part of AP name to change IP method : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
        if (rv <= 0)
                return -1;
 
@@ -2069,7 +2069,7 @@ int test_wifi_manager_set_proxy_method(void)
                return -1;
 
        printf("Input a part of AP name to change Proxy method : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
        if (rv <= 0)
                return -1;
 
@@ -2094,7 +2094,7 @@ int test_wifi_manager_get_ap_info(void)
                return -1;
 
        printf("Input a part of AP name to get detailed info : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
        if (rv <= 0)
                return -1;
 
@@ -2135,12 +2135,12 @@ int test_wifi_manager_config_save(void)
 
        printf("Input AP configuration\n");
        printf("Name : ");
-       rv = scanf("%32s", name);
+       rv = scanf(" %32[^\n]s", name);
        if (rv <= 0)
                return -1;
 
        printf("Passphrase : ");
-       rv = scanf("%99s", passphrase);
+       rv = scanf(" %99s", passphrase);
        if (rv <= 0)
                return -1;
 
@@ -2416,12 +2416,12 @@ int test_wifi_manager_config_remove(void)
 
        printf("Input AP configuration\n");
        printf("Name : ");
-       rv = scanf("%32s", c.name);
+       rv = scanf(" %32[^\n]s", c.name);
        if (rv <= 0)
                return -1;
 
        printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
-       rv = scanf("%d", &c.type);
+       rv = scanf(" %d", &c.type);
        if (rv <= 0)
                return -1;
 
@@ -2599,13 +2599,13 @@ int test_wifi_manager_connect_hidden_ap(void)
                return -1;
 
        printf("Input hidden AP name to connect : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
        printf("Input Security Type :\n");
        printf("0 -> WIFI_SECURITY_TYPE_NONE\n");
        printf("1 -> WIFI_SECURITY_TYPE_WEP\n");
        printf("2 -> WIFI_SECURITY_TYPE_WPA_PSK/WIFI_SECURITY_TYPE_WPA2_PSK\n");
 
-       rv = scanf("%d", &sec_type);
+       rv = scanf(" %d", &sec_type);
        if (sec_type == 1 || sec_type == 2) {
                printf("Input hidden AP passphrase : ");
                rv = scanf("%64s", passphrase);
@@ -2658,7 +2658,7 @@ int test_wifi_manager_connect_wps_pin_without_ssid(void)
 
        printf("Input pin to wps pin connect : ");
 
-       rv = scanf("%8s", pin);
+       rv = scanf(" %8s", pin);
        if (rv <= 0)
                return -1;
 
@@ -2713,7 +2713,7 @@ int test_wifi_manager_forget_ap_async(void)
                return -1;
 
        printf("Input a part of AP name to forget : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
 
        rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_async_callback, ap_name);
        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -2732,7 +2732,7 @@ int test_wifi_manager_set_autoscan_state(void)
        int rv = 0;
 
        printf("Input enable/disable for autoscan (0:enable, 1:disable) :\n");
-       rv = scanf("%9d", &autoscan);
+       rv = scanf(" %9d", &autoscan);
 
        if (rv <= 0) {
                printf("Invalid input!\n");
@@ -2767,7 +2767,7 @@ int test_wifi_manager_set_autoscan_mode(void)
        int rv = 0;
 
        printf("Input autoscan mode (0:exponential, 1:periodic) :\n");
-       rv = scanf("%9d", &mode);
+       rv = scanf(" %9d", &mode);
 
        if (rv <= 0) {
                printf("Invalid input!\n");
@@ -3026,7 +3026,7 @@ int test_wifi_manager_netlink_scan(void)
 
                for (i = 0; i < num; i++) {
                        printf("Input ssid:\n");
-                       rv = scanf("%32s", ssid);
+                       rv = scanf(" %32[^\n]s", ssid);
 
                        rv = wifi_manager_netlink_scan_set_ssid(netlink_scan, ssid);
                        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -3047,7 +3047,7 @@ int test_wifi_manager_netlink_scan(void)
 
        if (add_vsie) {
                printf("Input vsie:\n");
-               rv = scanf("%250s", vsie);
+               rv = scanf(" %250s", vsie);
 
                rv = wifi_manager_netlink_scan_set_vsie(netlink_scan, vsie);
                if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -3216,7 +3216,7 @@ int test_wifi_manager_specific_ap_start_multi_scan(void)
                if (scan_type == 0) { /** multi ssid scan */
                        for (i = 0; i < num; i++) {
                                printf("Input ssid[%d]:\n", i);
-                               rv = scanf("%32s", ssid);
+                               rv = scanf(" %32[^\n]s", ssid);
 
                                rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
                                if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -3227,7 +3227,7 @@ int test_wifi_manager_specific_ap_start_multi_scan(void)
                } else { /** multi frequency scan */
                        for (i = 0; i < num; i++) {
                                printf("Input freq[%d]:\n", i);
-                               rv = scanf("%d", &freq);
+                               rv = scanf(" %d", &freq);
                                rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
                                if (rv != WIFI_MANAGER_ERROR_NONE) {
                                        printf("Failed to set freq [%s]", __test_convert_error_to_string(rv));
@@ -3245,7 +3245,7 @@ int test_wifi_manager_specific_ap_start_multi_scan(void)
 
                for (i = 0; i < num; i++) {
                        printf("Input ssid:\n");
-                       rv = scanf("%32s", ssid);
+                       rv = scanf(" %32[^\n]s", ssid);
 
                        rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
                        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -3253,7 +3253,7 @@ int test_wifi_manager_specific_ap_start_multi_scan(void)
                                return -1;
                        }
                        printf("Input freq:\n");
-                       rv = scanf("%d", &freq);
+                       rv = scanf(" %d", &freq);
 
                        rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
                        if (rv != WIFI_MANAGER_ERROR_NONE) {
@@ -3303,7 +3303,7 @@ int test_wifi_manager_set_auto_connect(void)
        int mode;
 
        printf("Auto connect mode (1:enable, 0:disable) : ");
-       rv = scanf("%d", &mode);
+       rv = scanf(" %d", &mode);
        if (rv <= 0)
                return -1;
 
@@ -3344,7 +3344,7 @@ int test_wifi_manager_set_ap_auto_connect(void)
                return -1;
 
        printf("[Wi-Fi] Input a part of AP name to set : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
        if (rv <= 0)
                return -1;
 
@@ -3369,7 +3369,7 @@ int test_wifi_manager_get_ap_auto_connect(void)
                return -1;
 
        printf("[Wi-Fi] Input a part of AP name to get : ");
-       rv = scanf("%32s", ap_name);
+       rv = scanf(" %32[^\n]s", ap_name);
        if (rv <= 0)
                return -1;
 
@@ -3389,7 +3389,7 @@ int test_wifi_manager_set_passpoint_enable(void)
        int enable;
 
        printf("Enter passpoint on/off(0:off, 1:on) : \n");
-       rv = scanf("%d", &enable);
+       rv = scanf(" %d", &enable);
        if (rv <= 0)
                return -1;