[UTC][nsd][NonACR] Fix TC fail for emulator 36/282736/3
authorSeonah Moon <seonah1.moon@samsung.com>
Tue, 11 Oct 2022 03:09:09 +0000 (12:09 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Tue, 11 Oct 2022 04:58:39 +0000 (13:58 +0900)
Change-Id: Ie6b2e102fbac8fc36945e2536de74d42d9830f69
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
src/utc/nsd/CMakeLists.txt
src/utc/nsd/utc-nsd-common.c [new file with mode: 0755]
src/utc/nsd/utc-nsd-common.h [new file with mode: 0755]
src/utc/nsd/utc-nsd-dnssd-browse.c
src/utc/nsd/utc-nsd-dnssd-register.c

index af12a2b6dde4f9a2854d73b6fa7985aad6a00ced..17072d1c53687c18364d6b073db900df158e1737 100644 (file)
@@ -5,6 +5,7 @@ SET(RPM_NAME "core-${PKG_NAME}-tests")
 
 SET(CAPI_LIB "nsd-ssdp nsd-dns-sd")
 SET(TC_SOURCES
+       utc-nsd-common.c
     utc-nsd-ssdp-browse.c
     utc-nsd-ssdp-register.c
     utc-nsd-dnssd-browse.c
diff --git a/src/utc/nsd/utc-nsd-common.c b/src/utc/nsd/utc-nsd-common.c
new file mode 100755 (executable)
index 0000000..2e7da58
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// Copyright (c) 2022 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "utc-nsd-common.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <system_info.h>
+
+static int bIsEmulator = -1;
+
+static bool _is_emulator()
+{
+       char *val = NULL;
+
+       if (bIsEmulator != -1)
+               return bIsEmulator;
+
+       if (system_info_get_platform_string(MODEL_NAME_KEY, &val) < 0) {
+               free(val);
+               return false;
+       }
+
+       bIsEmulator = strncmp(val, MODEL_NAME_EMULATOR, strlen(MODEL_NAME_EMULATOR)) == 0 ? true : false;
+       free(val);
+       return bIsEmulator;
+}
+
+const char *nsd_get_interface_name()
+{
+       if (_is_emulator())
+               return ETHERNET_INTF;
+       else
+               return WIFI_INTF;
+}
diff --git a/src/utc/nsd/utc-nsd-common.h b/src/utc/nsd/utc-nsd-common.h
new file mode 100755 (executable)
index 0000000..51ad9d9
--- /dev/null
@@ -0,0 +1,28 @@
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//#ifndef _UTC_NSD_COMMON_H_
+//#define _UTC_NSD_COMMON_H_
+
+#define MODEL_NAME_KEY         "http://tizen.org/system/model_name"
+#define MODEL_NAME_EMULATOR    "Emulator"
+
+#define WIFI_INTF              "wlan0"
+#define ETHERNET_INTF  "eth0"
+
+const char *nsd_get_interface_name();
+
+//#endif  /* _UTC_NSD_COMMON_H_ */
index 7085f43676d1631404ec68ac85b31dd8a790e6f0..458010cefb0c0d5baeeccc7c033cac7c7d940127 100755 (executable)
@@ -18,8 +18,9 @@
 #include <glib.h>
 #include <stdlib.h>
 #include <string.h>
-
 #include <system_info.h>
+
+#include "utc-nsd-common.h"
 //& set: Nsd-dnssd-browse
 
 static bool g_feature = true;
@@ -202,7 +203,7 @@ int utc_nsd_dnssd_browse_service_p(void)
                return 0;
        }
 
-       ret = dnssd_browse_service("_ftp._tcp", "wlan0", &browser_id, __found_cb, NULL);
+       ret = dnssd_browse_service("_ftp._tcp", nsd_get_interface_name(), &browser_id, __found_cb, NULL);
        assert_eq(ret, DNSSD_ERROR_NONE);
 
        ret = dnssd_cancel_browse_service(browser_id);
@@ -228,7 +229,7 @@ int utc_nsd_dnssd_browse_service_n(void)
                return 0;
        }
 
-       ret = dnssd_browse_service("_ftp._tcp", "wlan0", NULL, __found_cb, NULL);
+       ret = dnssd_browse_service("_ftp._tcp", nsd_get_interface_name(), NULL, __found_cb, NULL);
        assert_eq(ret, DNSSD_ERROR_INVALID_PARAMETER);
        return 0;
 }
@@ -253,7 +254,7 @@ int utc_nsd_dnssd_cancel_browse_service_n(void)
                return 0;
        }
 
-       ret = dnssd_browse_service("_ftp._tcp", "wlan0", &browser_id, __found_cb, NULL);
+       ret = dnssd_browse_service("_ftp._tcp", nsd_get_interface_name(), &browser_id, __found_cb, NULL);
        assert_eq(ret, DNSSD_ERROR_NONE);
 
        ret = dnssd_cancel_browse_service(0);
@@ -334,7 +335,7 @@ int utc_nsd_dnssd_create_remote_service_p(void)
                return 0;
        }
 
-       ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", &serv_id);
+       ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), &serv_id);
        assert_eq(ret, DNSSD_ERROR_NONE);
 
        dnssd_destroy_remote_service(serv_id);
@@ -360,7 +361,7 @@ int utc_nsd_dnssd_create_remote_service_n(void)
                return 0;
        }
 
-       ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", NULL);
+       ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), NULL);
        assert_eq(ret, DNSSD_ERROR_INVALID_PARAMETER);
 
        return 0;
@@ -385,7 +386,7 @@ int utc_nsd_dnssd_destroy_remote_service_p(void)
                return 0;
        }
 
-       ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", &serv_id);
+       ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), &serv_id);
        assert_eq(ret, DNSSD_ERROR_NONE);
 
        ret = dnssd_destroy_remote_service(serv_id);
@@ -413,7 +414,7 @@ int utc_nsd_dnssd_detroy_remote_service_n(void)
                return 0;
        }
 
-       ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", &serv_id);
+       ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), &serv_id);
        assert_eq(ret, DNSSD_ERROR_NONE);
 
        ret = dnssd_destroy_remote_service(serv_id + 1);
@@ -448,7 +449,7 @@ int utc_nsd_dnssd_resolve_service_p(void)
                return 0;
        }
 
-       ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", &service);
+       ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), &service);
        assert_eq(ret, DNSSD_ERROR_NONE);
 
        ret = dnssd_resolve_service(service, __resolved_cb, NULL);
index 6cb325415f85e82ef2ed86d79b120c14947136b6..b545603c15a8feb2eb818e52f9203fab1de26f12 100755 (executable)
@@ -21,6 +21,8 @@
 #include <system_info.h>
 #include <dns-sd.h>
 
+#include "utc-nsd-common.h"
+
 //& set: Nsd-dnssd-register
 
 static GMainLoop* loop = NULL;
@@ -494,7 +496,7 @@ int utc_nsd_dnssd_set_interface_p(void)
 
        dnssd_create_local_service("_ftp._tcp", &serv_id);
 
-       ret = dnssd_service_set_interface(serv_id, "wlan0");
+       ret = dnssd_service_set_interface(serv_id, nsd_get_interface_name());
        assert_eq(ret, DNSSD_ERROR_NONE);
 
        dnssd_destroy_local_service(serv_id);
@@ -523,7 +525,7 @@ int utc_nsd_dnssd_set_interface_n1(void)
 
        dnssd_create_local_service("_ftp._tcp", &serv_id);
 
-       ret = dnssd_service_set_interface(serv_id + 1, "wlan0");
+       ret = dnssd_service_set_interface(serv_id + 1, nsd_get_interface_name());
        assert_eq(ret, DNSSD_ERROR_SERVICE_NOT_FOUND);
 
        dnssd_destroy_local_service(serv_id);
@@ -582,7 +584,7 @@ int utc_nsd_dnssd_get_interface_p(void)
 
        dnssd_create_local_service("_ftp._tcp", &serv_id);
 
-       ret = dnssd_service_set_interface(serv_id, "wlan0");
+       ret = dnssd_service_set_interface(serv_id, nsd_get_interface_name());
        assert_eq(ret, DNSSD_ERROR_NONE);
 
        ret = dnssd_service_get_interface(serv_id, &interface);