Modify Test Code for NTP Server APIs 16/294216/4 accepted/tizen/unified/20230628.023641
authorAnjali Nijhara <a.nijhara@samsung.com>
Wed, 14 Jun 2023 09:42:10 +0000 (15:12 +0530)
committerJaehyun Kim <jeik01.kim@samsung.com>
Mon, 26 Jun 2023 08:27:27 +0000 (08:27 +0000)
Change-Id: I55ff3bd145a12349d3c448d9ec933bedf54a52dc

test/connection_test.c

index 3db86eb..417c1d6 100755 (executable)
@@ -2991,6 +2991,63 @@ int test_get_clock_update_info(void)
        return 1;
 }
 
+int test_set_ntp_server(void)
+{
+       int rv = 0;
+       char input_str1[100] = {0,};
+
+       if (test_get_user_string("Enter NTP Server Url (Enter for skip) :", input_str1, 100)) {
+
+               g_strstrip(input_str1);
+
+               rv = connection_set_ntp_server(connection, input_str1);
+
+               if (rv != CONNECTION_ERROR_NONE) {
+                       printf("Fail to set NTP Server [%s]\n", test_print_error(rv));
+                       return -1;
+               }
+
+               printf("Retval = [%s]\n",test_print_error(rv));
+       }
+
+       return 1;
+}
+
+int test_get_ntp_server(void)
+{
+       int rv = 0;
+       char *ntp_server;
+
+       rv = connection_get_ntp_server(connection, &ntp_server);
+
+       if (rv != CONNECTION_ERROR_NONE) {
+               printf("Fail to get ntp server [%s]\n", test_print_error(rv));
+               return -1;
+       }
+
+       printf("Retval = [%s] NTP Server : [%s]\n", test_print_error(rv), ntp_server);
+
+       free(ntp_server);
+
+       return 1;
+}
+
+int test_clear_ntp_server(void)
+{
+       int rv = 0;
+
+       rv = connection_clear_ntp_server(connection);
+
+       if (rv != CONNECTION_ERROR_NONE) {
+               printf("Fail to clear ntp server[%s]\n", test_print_error(rv));
+               return -1;
+       }
+
+       printf("Retval = [%s]\n", test_print_error(rv));
+
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -3083,6 +3140,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("S   - Connect Ethernet EAP)\n");
                printf("T   - Get EAPoL info)\n");
                printf("U   - Get Clock update info)\n");
+               printf("V   - Set NTP Server\n");
+               printf("W   - Get NTP Server\n");
+               printf("X   - Clear NTP Server\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
                printf("ENTER   - Show options menu.......\n");
        }
@@ -3249,6 +3309,15 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'U':
                rv = test_get_clock_update_info();
                break;
+       case 'V':
+               rv = test_set_ntp_server();
+               break;
+       case 'W':
+               rv = test_get_ntp_server();
+               break;
+       case 'X':
+               rv = test_clear_ntp_server();
+               break;
        }
 
        if (rv == 1)