[AITT] set/get option for AITT
authorgichan2-jang <gichan2.jang@samsung.com>
Wed, 13 Sep 2023 08:07:09 +0000 (17:07 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Fri, 15 Sep 2023 04:40:50 +0000 (13:40 +0900)
 - Add set/get option of AITT.
 - Add releated unittests.

Signed-off-by: gichan2-jang <gichan2.jang@samsung.com>
create aitt handle with edge handle

Signed-off-by: gichan2-jang <gichan2.jang@samsung.com>
src/libnnstreamer-edge/nnstreamer-edge-aitt.c
src/libnnstreamer-edge/nnstreamer-edge-aitt.h
src/libnnstreamer-edge/nnstreamer-edge-internal.c
tests/unittest_nnstreamer-edge-aitt.cc

index fc601b5c128b8d6461bae76a12113296fe902a36..7ba4598bd0419d8393ed98098e723ca8829f68e3 100644 (file)
@@ -38,17 +38,17 @@ typedef struct
   /* event callback for new message */
   nns_edge_event_cb event_cb;
   void *user_data;
+  aitt_option_h option;
 } nns_edge_aitt_handle_s;
 
 /**
  * @brief Create AITT handle and connect to AITT.
  */
 int
-nns_edge_aitt_connect (const char *id, const char *topic, const char *host,
-    const int port, nns_edge_aitt_h * handle)
+nns_edge_aitt_connect (nns_edge_aitt_h handle, const char *id,
+    const char *topic, const char *host, const int port)
 {
   nns_edge_aitt_handle_s *ah;
-  aitt_option_h option;
 
   if (!STR_IS_VALID (id)) {
     nns_edge_loge ("Invalid param, given id is invalid.");
@@ -74,20 +74,11 @@ nns_edge_aitt_connect (const char *id, const char *topic, const char *host,
     nns_edge_loge ("Invalid param, handle should not be null.");
     return NNS_EDGE_ERROR_INVALID_PARAMETER;
   }
+  ah = (nns_edge_aitt_handle_s *) handle;
 
   nns_edge_logd ("Create AITT instance: broker address: %s:%d", host, port);
 
-  ah = (nns_edge_aitt_handle_s *) calloc (1, sizeof (nns_edge_aitt_handle_s));
-  if (!ah) {
-    nns_edge_loge ("Failed to allocate memory for AITT handle.");
-    return NNS_EDGE_ERROR_OUT_OF_MEMORY;
-  }
-
-  option = aitt_option_new ();
-  aitt_option_set (option, AITT_OPT_MY_IP, "localhost");
-
-  ah->aitt_handle = aitt_new (id, option);
-  aitt_option_destroy (option);
+  ah->aitt_handle = aitt_new (id, ah->option);
 
   if (!ah->aitt_handle) {
     nns_edge_loge ("Failed to create AITT handle. AITT internal error.");
@@ -107,7 +98,6 @@ nns_edge_aitt_connect (const char *id, const char *topic, const char *host,
   ah->host = nns_edge_strdup (host);
   ah->port = port;
 
-  *handle = ah;
   return NNS_EDGE_ERROR_NONE;
 }
 
@@ -140,6 +130,8 @@ nns_edge_aitt_close (nns_edge_aitt_h handle)
     ah->aitt_handle = NULL;
   }
 
+  if (ah->option)
+    aitt_option_destroy (ah->option);
   SAFE_FREE (ah->id);
   SAFE_FREE (ah->topic);
   SAFE_FREE (ah->host);
@@ -302,3 +294,139 @@ nns_edge_aitt_send_data (nns_edge_aitt_h handle, nns_edge_data_h data_h)
   SAFE_FREE (data);
   return ret;
 }
+
+/**
+ * @brief Parse aitt option from the key.
+ */
+static aitt_option_e
+_nns_edge_parse_aitt_option (const char *key)
+{
+  aitt_option_e aitt_opt;
+
+  if (0 == strcasecmp (key, "my-ip"))
+    aitt_opt = AITT_OPT_UNKNOWN;
+  else if (0 == strcasecmp (key, "clean-session"))
+    aitt_opt = AITT_OPT_CLEAN_SESSION;
+  else if (0 == strcasecmp (key, "custom-broker"))
+    aitt_opt = AITT_OPT_CUSTOM_BROKER;
+  else if (0 == strcasecmp (key, "service-id"))
+    aitt_opt = AITT_OPT_SERVICE_ID;
+  else if (0 == strcasecmp (key, "location-id"))
+    aitt_opt = AITT_OPT_LOCATION_ID;
+  else if (0 == strcasecmp (key, "root-ca"))
+    aitt_opt = AITT_OPT_ROOT_CA;
+  else if (0 == strcasecmp (key, "custom-rw-file"))
+    aitt_opt = AITT_OPT_CUSTOM_RW_FILE;
+  else
+    aitt_opt = AITT_OPT_UNKNOWN;
+
+  return aitt_opt;
+}
+
+/**
+ * @brief Internal util function to set AITT option.
+ */
+int
+nns_edge_aitt_set_option (nns_edge_aitt_h handle, const char *key,
+    const char *value)
+{
+  nns_edge_aitt_handle_s *ah;
+  aitt_option_e aitt_opt;
+
+  if (!handle) {
+    nns_edge_loge ("Invalid param, given AITT handle is invalid.");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+
+  if (!key) {
+    nns_edge_loge
+        ("The parameter, 'key' is NULL. It should be a valid const char*");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+
+  if (!value) {
+    nns_edge_loge
+        ("The parameter, 'value' is NULL. It should be a valid const char*");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+
+  ah = (nns_edge_aitt_handle_s *) handle;
+
+  aitt_opt = _nns_edge_parse_aitt_option (key);
+  if (AITT_OPT_UNKNOWN == aitt_opt) {
+    nns_edge_loge ("Invalid AITT option key: %s, please check the key", key);
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+
+  if (AITT_ERROR_NONE != aitt_option_set (ah->option, aitt_opt, value)) {
+    nns_edge_loge ("Failed to set AITT option, key:value= %s:%s", key, value);
+    return NNS_EDGE_ERROR_UNKNOWN;
+  }
+
+  return NNS_EDGE_ERROR_NONE;
+}
+
+/**
+ * @brief Internal util function to get AITT option.
+ */
+const char *
+nns_edge_aitt_get_option (nns_edge_aitt_h handle, const char *key)
+{
+  nns_edge_aitt_handle_s *ah;
+  aitt_option_e aitt_opt;
+
+  if (!handle) {
+    nns_edge_loge ("Invalid param, given AITT handle is invalid.");
+    return NULL;
+  }
+
+  if (!key) {
+    nns_edge_loge
+        ("The parameter, 'key' is NULL. It should be a valid const char*");
+    return NULL;
+  }
+
+  ah = (nns_edge_aitt_handle_s *) handle;
+
+  aitt_opt = _nns_edge_parse_aitt_option (key);
+  if (AITT_OPT_UNKNOWN == aitt_opt) {
+    nns_edge_loge ("Invalid AITT option key: %s, please check the key", key);
+    return NULL;
+  }
+
+  return aitt_option_get (ah->option, aitt_opt);
+}
+
+
+/**
+ * @brief Create AITT handle.
+ */
+int
+nns_edge_aitt_create (nns_edge_aitt_h * handle)
+{
+  nns_edge_aitt_handle_s *ah;
+  aitt_option_h option;
+
+  if (!handle) {
+    nns_edge_loge ("Invalid param, handle should not be null.");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+
+  ah = (nns_edge_aitt_handle_s *) calloc (1, sizeof (nns_edge_aitt_handle_s));
+  if (!ah) {
+    nns_edge_loge ("Failed to allocate memory for AITT handle.");
+    return NNS_EDGE_ERROR_OUT_OF_MEMORY;
+  }
+
+  option = aitt_option_new ();
+  if (!option) {
+    nns_edge_loge ("Failed to allocate memory for AITT handle.");
+    nns_edge_free (ah);
+    return NNS_EDGE_ERROR_UNKNOWN;
+  }
+  ah->option = option;
+
+  *handle = ah;
+
+  return NNS_EDGE_ERROR_NONE;
+}
index 3b2a341f9d7b67054e71a4b682bfe7dd899ff6e5..e1a4f799c9e3083377e3efdb952d36c5ee35f9ba 100644 (file)
@@ -23,10 +23,10 @@ typedef void *nns_edge_aitt_h;
 
 #if defined(ENABLE_AITT)
 /**
- * @brief Create AITT handle and connect to AITT.
+ * @brief Connect to AITT.
  * @note This is internal function for AITT.
  */
-int nns_edge_aitt_connect (const char *id, const char *topic, const char *host, const int port, nns_edge_aitt_h *handle);
+int nns_edge_aitt_connect (nns_edge_aitt_h handle, const char *id, const char *topic, const char *host, const int port);
 
 /**
  * @brief Release the AITT handle.
@@ -60,6 +60,22 @@ int nns_edge_aitt_is_connected (nns_edge_aitt_h handle);
  * @brief Internal util function to send edge-data.
  */
 int nns_edge_aitt_send_data (nns_edge_aitt_h handle, nns_edge_data_h data_h);
+
+/**
+ * @brief Internal util function to set AITT option.
+ */
+int nns_edge_aitt_set_option (nns_edge_aitt_h handle, const char *key, const char *value);
+
+/**
+ * @brief Internal util function to get AITT option.
+ */
+const char *nns_edge_aitt_get_option (nns_edge_aitt_h handle, const char *key);
+
+/**
+ * @brief Create AITT handle.
+ */
+int nns_edge_aitt_create (nns_edge_aitt_h *handle);
+
 #else
 #define nns_edge_aitt_connect(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
 #define nns_edge_aitt_close(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
@@ -68,6 +84,9 @@ int nns_edge_aitt_send_data (nns_edge_aitt_h handle, nns_edge_data_h data_h);
 #define nns_edge_aitt_set_event_callback(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
 #define nns_edge_aitt_is_connected(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
 #define nns_edge_aitt_send_data(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_aitt_set_option(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_aitt_get_option(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_aitt_create(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
 #endif /* ENABLE_AITT */
 
 #ifdef __cplusplus
index c83b84ec0807827e61c335e368e2cd701c0874a7..867ee8638178d14b17ea0536066d727b3b5f70c6 100644 (file)
@@ -1261,6 +1261,15 @@ nns_edge_create_handle (const char *id, nns_edge_connect_type_e connect_type,
   nns_edge_metadata_create (&eh->metadata);
   nns_edge_queue_create (&eh->send_queue);
 
+  if (NNS_EDGE_CONNECT_TYPE_AITT == connect_type) {
+    int ret = nns_edge_aitt_create (&eh->broker_h);
+    if (NNS_EDGE_ERROR_NONE != ret) {
+      nns_edge_loge ("Failed to create AITT handle.");
+      nns_edge_release_handle (eh);
+      return ret;
+    }
+  }
+
   *edge_h = eh;
   return NNS_EDGE_ERROR_NONE;
 }
@@ -1339,8 +1348,8 @@ nns_edge_start (nns_edge_h edge_h)
         }
       }
     } else if (NNS_EDGE_CONNECT_TYPE_AITT == eh->connect_type) {
-      ret = nns_edge_aitt_connect (eh->id, eh->topic, eh->dest_host,
-          eh->dest_port, &eh->broker_h);
+      ret = nns_edge_aitt_connect (eh->broker_h, eh->id, eh->topic,
+          eh->dest_host, eh->dest_port);
       if (NNS_EDGE_ERROR_NONE != ret) {
         nns_edge_loge ("Failed to connect to AITT broker.");
         goto done;
@@ -1622,8 +1631,8 @@ nns_edge_connect (nns_edge_h edge_h, const char *dest_host, int dest_port)
       }
     }
   } else if (NNS_EDGE_CONNECT_TYPE_AITT == eh->connect_type) {
-    ret = nns_edge_aitt_connect (eh->id, eh->topic, dest_host, dest_port,
-        &eh->broker_h);
+    ret = nns_edge_aitt_connect (eh->broker_h, eh->id, eh->topic, dest_host,
+        dest_port);
     if (ret != NNS_EDGE_ERROR_NONE) {
       nns_edge_loge ("Failed to connect to AITT broker. %s:%d", dest_host,
           dest_port);
@@ -1863,6 +1872,18 @@ nns_edge_set_info (nns_edge_h edge_h, const char *key, const char *value)
     }
 
     nns_edge_queue_set_limit (eh->send_queue, limit, leaky);
+  } else if (0 == strcasecmp (key, "my-ip") ||
+      0 == strcasecmp (key, "clean-session") ||
+      0 == strcasecmp (key, "custom-broker") ||
+      0 == strcasecmp (key, "service-id") ||
+      0 == strcasecmp (key, "location-id") ||
+      0 == strcasecmp (key, "root-ca") ||
+      0 == strcasecmp (key, "custom-rw-file")) {
+    if (NNS_EDGE_CONNECT_TYPE_AITT == eh->connect_type) {
+      ret = nns_edge_aitt_set_option (eh->broker_h, key, value);
+    } else {
+      nns_edge_metadata_set (eh->metadata, key, value);
+    }
   } else {
     ret = nns_edge_metadata_set (eh->metadata, key, value);
   }
index a8cbcc94403ab993f2a9d2de1a995d89d216b64d..6e0f4dc97f51da32ef4160014ddad04eded0896c 100644 (file)
@@ -262,11 +262,17 @@ TEST(edgeAitt, connectInvalidParam1_n)
   if (!_check_mqtt_broker ())
     return;
 
-  ret = nns_edge_aitt_connect (NULL, "temp-aitt-topic", "127.0.0.1", 1883, &handle);
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_connect (handle, NULL, "temp-aitt-topic", "127.0.0.1", 1883);
   EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
 
-  ret = nns_edge_aitt_connect ("", "temp-aitt-topic", "127.0.0.1", 1883, &handle);
+  ret = nns_edge_aitt_connect (handle, "", "temp-aitt-topic", "127.0.0.1", 1883);
   EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
 }
 
 /**
@@ -280,11 +286,17 @@ TEST(edgeAitt, connectInvalidParam2_n)
   if (!_check_mqtt_broker ())
     return;
 
-  ret = nns_edge_aitt_connect ("temp-aitt-id", NULL, "127.0.0.1", 1883, &handle);
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_connect (handle, "temp-aitt-id", NULL, "127.0.0.1", 1883);
   EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
 
-  ret = nns_edge_aitt_connect ("temp-aitt-id", "", "127.0.0.1", 1883, &handle);
+  ret = nns_edge_aitt_connect (handle, "temp-aitt-id", "", "127.0.0.1", 1883);
   EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
 }
 
 /**
@@ -298,11 +310,17 @@ TEST(edgeAitt, connectInvalidParam3_n)
   if (!_check_mqtt_broker ())
     return;
 
-  ret = nns_edge_aitt_connect ("temp-aitt-id", "temp-aitt-topic", NULL, 1883, &handle);
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_connect (handle, "temp-aitt-id", "temp-aitt-topic", NULL, 1883);
   EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
 
-  ret = nns_edge_aitt_connect ("temp-aitt-id", "temp-aitt-topic", "", 1883, &handle);
+  ret = nns_edge_aitt_connect (handle, "temp-aitt-id", "temp-aitt-topic", "", 1883);
   EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
 }
 
 /**
@@ -315,9 +333,14 @@ TEST(edgeAitt, connectInvalidParam4_n)
 
   if (!_check_mqtt_broker ())
     return;
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
 
-  ret = nns_edge_aitt_connect ("temp-aitt-id", "temp-aitt-topic", "127.0.0.1", 0, &handle);
+  ret = nns_edge_aitt_connect (handle, "temp-aitt-id", "temp-aitt-topic", "127.0.0.1", 0);
   EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
 }
 
 /**
@@ -326,12 +349,19 @@ TEST(edgeAitt, connectInvalidParam4_n)
 TEST(edgeAitt, connectInvalidParam5_n)
 {
   int ret = -1;
+  nns_edge_aitt_h handle;
 
   if (!_check_mqtt_broker ())
     return;
 
-  ret = nns_edge_aitt_connect ("temp-aitt-id", "temp-aitt-topic", "127.0.0.1", 1883, NULL);
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_connect (NULL, "temp-aitt-id", "temp-aitt-topic", "127.0.0.1", 1883);
   EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
 }
 
 /**
@@ -375,7 +405,10 @@ TEST(edgeAitt, publishInvalidParam2_n)
   if (!_check_mqtt_broker ())
     return;
 
-  ret = nns_edge_aitt_connect ("temp-aitt-id", "temp-aitt-topic", "127.0.0.1", 1883, &handle);
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_connect (handle, "temp-aitt-id", "temp-aitt-topic", "127.0.0.1", 1883);
   EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
 
   /* data is null */
@@ -398,7 +431,10 @@ TEST(edgeAitt, publishInvalidParam3_n)
   if (!_check_mqtt_broker ())
     return;
 
-  ret = nns_edge_aitt_connect ("temp-aitt-id", "temp-aitt-topic", "127.0.0.1", 1883, &handle);
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_connect (handle, "temp-aitt-id", "temp-aitt-topic", "127.0.0.1", 1883);
   EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
 
   /* data length is 0 */
@@ -437,6 +473,175 @@ TEST(edgeAitt, checkConnectionInvalidParam_n)
   EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
 }
 
+/**
+ * @brief Set and get AITT option.
+ */
+TEST(edgeAitt, setGetOption_p)
+{
+  int ret = -1;
+  nns_edge_aitt_h handle;
+
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, "custom-broker", "true");
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+  EXPECT_STREQ ("true", nns_edge_aitt_get_option (handle, "custom-broker"));
+
+  ret = nns_edge_aitt_set_option (handle, "clean-session", "true");
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+  EXPECT_STREQ ("true", nns_edge_aitt_get_option (handle, "clean-session"));
+
+  ret = nns_edge_aitt_set_option (handle, "service-id", "test_service_id");
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+  EXPECT_STREQ ("test_service_id", nns_edge_aitt_get_option (handle, "service-id"));
+
+  ret = nns_edge_aitt_set_option (handle, "location-id", "test_location_id");
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+  EXPECT_STREQ ("test_location_id", nns_edge_aitt_get_option (handle, "location-id"));
+
+  ret = nns_edge_aitt_set_option (handle, "root-ca", "root_ca_path");
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+  EXPECT_STREQ ("root_ca_path", nns_edge_aitt_get_option (handle, "root-ca"));
+
+  ret = nns_edge_aitt_set_option (handle, "custom-rw-file", "custom_rw_file_path");
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+  EXPECT_STREQ ("custom_rw_file_path", nns_edge_aitt_get_option (handle, "custom-rw-file"));
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+}
+
+/**
+ * @brief create AITT handle with invalid param.
+ */
+TEST(edgeAitt, createInvalidParam_n)
+{
+  int ret = -1;
+
+  ret = nns_edge_aitt_create (NULL);
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+}
+
+/**
+ * @brief set AITT option with invalid param.
+ */
+TEST(edgeAitt, setOptionInvalidParam_n)
+{
+  int ret = -1;
+  nns_edge_aitt_h handle;
+
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (NULL, "custom-broker", "true");
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, NULL, "true");
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, "custom-broker", NULL);
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, "custom-broker", "not_boolean_str");
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+}
+
+/**
+ * @brief Set custom option even it's not a custom broker.
+ */
+TEST(edgeAitt, setOptionNoCustomBroker_n)
+{
+  int ret = -1;
+  nns_edge_aitt_h handle;
+
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, "custom-broker", "false");
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, "service-id", "test_service_id");
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, "location-id", "test_location_id");
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, "root-ca", "root_ca_path");
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, "custom-rw-file", "custom_rw_file_path");
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+}
+
+/**
+ * @brief set AITT option with invalid key.
+ */
+TEST(edgeAitt, setOptionInvalidkey_n)
+{
+  int ret = -1;
+  nns_edge_aitt_h handle;
+
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_set_option (handle, "invalid_key", "true");
+  EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+}
+
+/**
+ * @brief get AITT option with invalid param.
+ */
+TEST(edgeAitt, getOptionInvalidParam_n)
+{
+  int ret = -1;
+  const char *ret_str = NULL;
+  nns_edge_aitt_h handle;
+
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret_str = nns_edge_aitt_get_option (handle, "custom-broker");
+  EXPECT_STREQ (ret_str, "false");
+
+  ret_str = nns_edge_aitt_get_option (NULL, "custom-broker");
+  EXPECT_STREQ (ret_str, NULL);
+
+  ret_str = nns_edge_aitt_get_option (handle, NULL);
+  EXPECT_STREQ (ret_str, NULL);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+}
+
+/**
+ * @brief get AITT option with invalid key.
+ */
+TEST(edgeAitt, getOptionInvalidkey_n)
+{
+  int ret = -1;
+  const char *ret_str = NULL;
+  nns_edge_aitt_h handle;
+
+  ret = nns_edge_aitt_create (&handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+
+  ret_str = nns_edge_aitt_get_option (handle, "invalid_key");
+  EXPECT_STREQ (ret_str, NULL);
+
+  ret = nns_edge_aitt_close (handle);
+  EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
+}
+
 /**
  * @brief Main gtest
  */