From: gichan2-jang Date: Wed, 13 Sep 2023 08:07:09 +0000 (+0900) Subject: [AITT] set/get option for AITT X-Git-Tag: accepted/tizen/unified/20230915.160553~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a00357febda637f6228bbdb1a5f4633e12db2a3d;p=platform%2Fupstream%2Fnnstreamer-edge.git [AITT] set/get option for AITT - Add set/get option of AITT. - Add releated unittests. Signed-off-by: gichan2-jang create aitt handle with edge handle Signed-off-by: gichan2-jang --- diff --git a/src/libnnstreamer-edge/nnstreamer-edge-aitt.c b/src/libnnstreamer-edge/nnstreamer-edge-aitt.c index fc601b5..7ba4598 100644 --- a/src/libnnstreamer-edge/nnstreamer-edge-aitt.c +++ b/src/libnnstreamer-edge/nnstreamer-edge-aitt.c @@ -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; +} diff --git a/src/libnnstreamer-edge/nnstreamer-edge-aitt.h b/src/libnnstreamer-edge/nnstreamer-edge-aitt.h index 3b2a341..e1a4f79 100644 --- a/src/libnnstreamer-edge/nnstreamer-edge-aitt.h +++ b/src/libnnstreamer-edge/nnstreamer-edge-aitt.h @@ -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 diff --git a/src/libnnstreamer-edge/nnstreamer-edge-internal.c b/src/libnnstreamer-edge/nnstreamer-edge-internal.c index c83b84e..867ee86 100644 --- a/src/libnnstreamer-edge/nnstreamer-edge-internal.c +++ b/src/libnnstreamer-edge/nnstreamer-edge-internal.c @@ -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); } diff --git a/tests/unittest_nnstreamer-edge-aitt.cc b/tests/unittest_nnstreamer-edge-aitt.cc index a8cbcc9..6e0f4dc 100644 --- a/tests/unittest_nnstreamer-edge-aitt.cc +++ b/tests/unittest_nnstreamer-edge-aitt.cc @@ -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 */