#include <ml-api-service.h>
static gchar *g_TestModel;
+static gchar *g_TestModel_add;
static gchar *g_Pipeline;
static guint _get_available_port(void)
*/
void ITs_nnstreamer_ml_service_startup(void)
{
- int nRet =-1;
struct stat buf;
if ( stat(ERR_LOG, &buf) == 0)
{
FPRINTF("[Line : %d][%s] TEST SUIT start-up: ITs_nnstreamer_ml_service_startup\\n", __LINE__, API_NAMESPACE);
#endif
g_bIsFeatureMismatched = false;
- g_bFeatureMLService = false;
- g_bFeatureML = TCTCheckSystemInfoFeatureSupported(FEATURE_ML, API_NAMESPACE);
+ g_bFeatureMLService = false;
+ g_bFeatureML = TCTCheckSystemInfoFeatureSupported(FEATURE_ML, API_NAMESPACE);
g_bFeatureMLService = TCTCheckSystemInfoFeatureSupported(FEATURE_ML_SERVICE, API_NAMESPACE);
- if (g_bFeatureML && g_bFeatureMLService)
+ if (g_bFeatureML && g_bFeatureMLService)
{
- char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
- const gchar *model_file = "mobilenet_v1_1.0_224_quant.tflite";
- if ( true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE ))
+ char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
+ const gchar *model_file = "mobilenet_v1_1.0_224_quant.tflite";
+ const gchar *model_file_add = "add.tflite";
+ if ( true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE ))
{
int model_path_len = strlen(pszValue) + strlen(model_file) + 10;
g_TestModel = (gchar*)malloc(model_path_len);
snprintf(g_TestModel, model_path_len, "%s/res/res/%s", pszValue, model_file);
FPRINTF("[%s][%d][%s] %s\\n", __FILE__, __LINE__, __FUNCTION__, g_TestModel);
+
+ model_path_len = strlen(pszValue) + strlen(model_file_add) + 10;
+ g_TestModel_add = (gchar*)malloc(model_path_len);
+ snprintf(g_TestModel_add, model_path_len, "%s/res/res/%s", pszValue, model_file_add);
+ FPRINTF("[%s][%d][%s] %s\\n", __FILE__, __LINE__, __FUNCTION__, g_TestModel_add);
}
else
{
#endif
if (g_bFeatureML && g_bFeatureMLService)
- {
- g_free (g_Pipeline);
- g_free (g_TestModel);
- }
+ {
+ g_free (g_Pipeline);
+ g_free (g_TestModel);
+ g_free (g_TestModel_add);
+ }
}
/*
return 0;
}
+
+/*
+* @testcase ITc_nnstreamer_ml_service_model_register_update_description_delete_p
+* @since_tizen 7.5
+* @author SRID(shobhit.v)
+* @reviewer SRID(ankit.sr1)
+* @type auto
+* @description To verify ml service model's register, update description and model delete APIs
+* @scenario register ml service model, update description and delete model
+* @apicovered ml_service_model_register, ml_service_model_update_description and ml_service_model_delete
+* @passcase When target API and all precondition API are successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: To verify ml service model's register, update description and model delete APIs
+//& type: auto
+int ITc_nnstreamer_ml_service_model_register_update_description_delete_p(void)
+{
+ START_TEST_ML_SERVICE;
+
+ const gchar *key = "mobilenet_v1";
+ guint version;
+
+ int nRetVal = ml_service_model_delete(key, 0U);
+ if (nRetVal != ML_ERROR_NONE && nRetVal != ML_ERROR_INVALID_PARAMETER)
+ {
+ FPRINTF("[Line : %d][%s] ml_service_model_delete failed.\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ // register model
+ nRetVal = ml_service_model_register (key, g_TestModel, true, "this is mobilenet v1 tflite model", &version);
+ ML_SERVICE_FEATURE_CHECK;
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_register", NnStreamerGetError(nRetVal));
+ FPRINTF("[Line : %d][%s] version value is [%d]\\n", __LINE__, API_NAMESPACE, version);
+ if(version != 1U)
+ {
+ FPRINTF("[Line : %d][%s] version value mismatched\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ // update the model description
+ nRetVal = ml_service_model_update_description (key, version, "This is updated description for the mobilenet v1 tflite model.");
+ ML_SERVICE_FEATURE_CHECK;
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_service_model_update_description", NnStreamerGetError(nRetVal), ml_service_model_delete(key, version));
+
+ // delete the active model
+ nRetVal = ml_service_model_delete(key, version);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_delete", NnStreamerGetError(nRetVal));
+ return 0;
+}
+
+/*
+* @testcase ITc_nnstreamer_ml_service_model_get_getactivated_optionget_p
+* @since_tizen 7.5
+* @author SRID(shobhit.v)
+* @reviewer SRID(ankit.sr1)
+* @type auto
+* @description To verify ml service model's get, get activated and option get APIs
+* @scenario Register model, Get information of activated neural network models, Get models with given name and a value of key in ml-option instance
+* @apicovered ml_service_model_get_activated, ml_service_model_get and ml_option_get
+* @passcase When target API and all precondition API are successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Get information of activated neural network models, Get models with given name, Gets a value of key in ml-option instance
+//& type: auto
+int ITc_nnstreamer_ml_service_model_get_getactivated_optionget_p(void)
+{
+ START_TEST_ML_SERVICE;
+
+ const gchar *key = "mobilenet_v1";
+ gchar *getPathVal;
+ guint version;
+
+ int nRetVal = ml_service_model_delete(key, 0U);
+ if (nRetVal != ML_ERROR_NONE && nRetVal != ML_ERROR_INVALID_PARAMETER)
+ {
+ FPRINTF("[Line : %d][%s] ml_service_model_delete failed.\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+ // register model
+ nRetVal = ml_service_model_register (key, g_TestModel, true, "this is mobilenet v1 tflite model", &version);
+ ML_SERVICE_FEATURE_CHECK;
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_register", NnStreamerGetError(nRetVal));
+ FPRINTF("[Line : %d][%s] version value is [%d]\\n", __LINE__, API_NAMESPACE, version);
+ if(version != 1U)
+ {
+ FPRINTF("[Line : %d][%s] version value mismatched\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ // update the model description
+ nRetVal = ml_service_model_update_description (key, version, "This is updated description for the mobilenet v1 tflite model.");
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_service_model_update_description", NnStreamerGetError(nRetVal), ml_service_model_delete(key, 1U));
+
+ nRetVal = ml_service_model_register (key, g_TestModel_add, false, "this is temp model", &version);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_service_model_register", NnStreamerGetError(nRetVal), ml_service_model_delete(key, 1U));
+ FPRINTF("[Line : %d][%s] version value is [%d]\\n", __LINE__, API_NAMESPACE, version);
+ if(version != 2U)
+ {
+ FPRINTF("[Line : %d][%s] version value mismatched\\n", __LINE__, API_NAMESPACE);
+ ml_service_model_delete(key, 1U);
+ return 1;
+ }
+
+ // Activate the model
+ ml_option_h activated_model_info;
+ nRetVal = ml_service_model_get_activated (key, &activated_model_info);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_service_model_get_activated", NnStreamerGetError(nRetVal), ml_service_model_delete(key, 1U);ml_service_model_delete(key, 2U));
+
+ // Get the model path value
+ nRetVal = ml_option_get (activated_model_info, "path", (void **) &getPathVal);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal), ml_service_model_delete(key, 1U);ml_service_model_delete(key, 2U));
+
+ if(strcmp(g_TestModel, getPathVal) != 0)
+ {
+ FPRINTF("[Line : %d][%s] Path value mismatched, Path1: [%s] and path2: [%s] \\n", __LINE__, API_NAMESPACE, g_TestModel, getPathVal);
+ ml_option_destroy (activated_model_info);
+ ml_service_model_delete(key, 1U);
+ ml_service_model_delete(key, 2U);
+ return 1;
+ }
+
+ nRetVal = ml_option_destroy (activated_model_info);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_destroy", NnStreamerGetError(nRetVal), ml_service_model_delete(key, 1U);ml_service_model_delete(key, 2U));
+
+ ml_option_h temp_model_info;
+ nRetVal = ml_service_model_get (key, 2U, &temp_model_info);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_service_model_get", NnStreamerGetError(nRetVal), ml_service_model_delete (key, 1U); ml_service_model_delete (key, 2U));
+
+ nRetVal = ml_option_get (temp_model_info, "path", (void **) &getPathVal);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal), ml_option_destroy (temp_model_info); ml_service_model_delete (key, 1U); ml_service_model_delete (key, 2U));
+
+ if( strcmp(g_TestModel_add, getPathVal) != 0)
+ {
+ FPRINTF("[Line : %d][%s] Path value mismatched, Path1: [%s] and path2: [%s] \\n", __LINE__, API_NAMESPACE, g_TestModel_add, getPathVal);
+ ml_option_destroy (temp_model_info);
+ ml_service_model_delete (key, 1U);
+ ml_service_model_delete (key, 2U);
+ return 1;
+ }
+
+ nRetVal = ml_option_destroy (temp_model_info);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_destroy", NnStreamerGetError(nRetVal), ml_service_model_delete (key, 1U); ml_service_model_delete (key, 2U));
+
+ nRetVal = ml_service_model_delete (key, 1U);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_service_model_delete", NnStreamerGetError(nRetVal), ml_service_model_delete (key, 2U));
+
+ nRetVal = ml_service_model_delete (key, 2U);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_delete", NnStreamerGetError(nRetVal));
+
+ return 0;
+}
+
+
+/*
+* @testcase ITc_nnstreamer_ml_service_model_getall_activate_p
+* @since_tizen 7.5
+* @author SRID(shobhit.v)
+* @reviewer SRID(ankit.sr1)
+* @type auto
+* @description To verify ml service model's get list of given name's models and activate model
+* @scenario Register model, Get list of neural network models with a given name and activate given model
+* @apicovered ml_service_model_get_all and ml_service_model_activate
+* @passcase When target API and all precondition API are successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Get list of neural network models with a given name and activate given model
+//& type: auto
+int ITc_nnstreamer_ml_service_model_getall_activate_p(void)
+{
+ START_TEST_ML_SERVICE;
+
+ const gchar *key = "mobilenet_v1";
+ gchar *getPathVal;
+ guint version;
+
+ int nRetVal = ml_service_model_delete(key, 0U);
+ if (nRetVal != ML_ERROR_NONE && nRetVal != ML_ERROR_INVALID_PARAMETER)
+ {
+ FPRINTF("[Line : %d][%s] ml_service_model_delete failed.\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ // register model
+ nRetVal = ml_service_model_register (key, g_TestModel, true, "this is mobilenet v1 tflite model", &version);
+ ML_SERVICE_FEATURE_CHECK;
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_register", NnStreamerGetError(nRetVal));
+ FPRINTF("[Line : %d][%s] version value is [%d]\\n", __LINE__, API_NAMESPACE, version);
+ if(version != 1U)
+ {
+ FPRINTF("[Line : %d][%s] version value mismatched\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ // update the model description
+ nRetVal = ml_service_model_update_description (key, version, "This is updated description for the mobilenet v1 tflite model.");
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_update_description", NnStreamerGetError(nRetVal));
+
+ nRetVal = ml_service_model_register (key, g_TestModel_add, false, "this is temp model", &version);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_register", NnStreamerGetError(nRetVal));
+ FPRINTF("[Line : %d][%s] version value is [%d]\\n", __LINE__, API_NAMESPACE, version);
+ if(version != 2U)
+ {
+ FPRINTF("[Line : %d][%s] version value mismatched\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ // Activate the model
+ ml_option_h activated_model_info;
+ nRetVal = ml_service_model_get_activated (key, &activated_model_info);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_get_activated", NnStreamerGetError(nRetVal));
+
+ // Get the model path value
+ nRetVal = ml_option_get (activated_model_info, "path", (void **) &getPathVal);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal));
+ if( strcmp(g_TestModel, getPathVal) != 0)
+ {
+ FPRINTF("[Line : %d][%s] Path value mismatched, Path1: [%s] and path2: [%s] \\n", __LINE__, API_NAMESPACE, g_TestModel, getPathVal);
+ ml_option_destroy (activated_model_info);
+ return 1;
+ }
+
+ nRetVal = ml_option_destroy (activated_model_info);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_option_destroy", NnStreamerGetError(nRetVal));
+
+
+ ml_option_h temp_model_info;
+ nRetVal = ml_service_model_get (key, 2U, &temp_model_info);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_get", NnStreamerGetError(nRetVal));
+
+ nRetVal = ml_option_get (temp_model_info, "path", (void **) &getPathVal);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal));
+ if( strcmp(g_TestModel_add, getPathVal) != 0)
+ {
+ FPRINTF("[Line : %d][%s] Path value mismatched, Path1: [%s] and path2: [%s] \\n", __LINE__, API_NAMESPACE, g_TestModel_add, getPathVal);
+ nRetVal = ml_option_destroy (temp_model_info);
+ return 1;
+ }
+
+ nRetVal = ml_option_destroy (temp_model_info);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_option_destroy", NnStreamerGetError(nRetVal));
+
+ ml_option_h *info_list = NULL;
+ guint info_num;
+
+ // get all model value
+ nRetVal = ml_service_model_get_all(key, &info_list, &info_num);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_get_all", NnStreamerGetError(nRetVal));
+ if(info_num != 2U)
+ {
+ FPRINTF("[Line : %d][%s] value mismatched\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ for (guint i = 0; i < info_num; i++)
+ {
+ gchar *version_str;
+ nRetVal = ml_option_get(info_list[i], "version", (void **) &version_str);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal), ml_option_destroy (info_list[i]); g_free (info_list));
+
+ if (g_ascii_strcasecmp (version_str, "1") == 0)
+ {
+ gchar *is_active;
+ nRetVal = ml_option_get (info_list[i], "active", (void **) &is_active);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal), ml_option_destroy (info_list[i]); g_free (info_list));
+ if(*is_active != 'T')
+ {
+ FPRINTF("[Line : %d][%s] active value mismatched\\n", __LINE__, API_NAMESPACE);
+ ml_option_destroy (info_list[i]);
+ g_free(info_list);
+ return 1;
+ }
+
+ gchar *path;
+ nRetVal = ml_option_get (info_list[i], "path", (void **) &path);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal));
+
+ if( strcmp(path, g_TestModel) != 0)
+ {
+ FPRINTF("[Line : %d][%s] Path value mismatched, Path1: [%s] and path2: [%s] \\n", __LINE__, API_NAMESPACE, g_TestModel, path);
+ ml_option_destroy (info_list[i]);
+ g_free(info_list);
+ return 1;
+ }
+ }
+ else if (g_ascii_strcasecmp (version_str, "2") == 0)
+ {
+ gchar *is_active;
+ nRetVal = ml_option_get (info_list[i], "active", (void **) &is_active);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal), ml_option_destroy (info_list[i]); g_free (info_list));
+ if(*is_active != 'F')
+ {
+ FPRINTF("[Line : %d][%s] active value mismatched\\n", __LINE__, API_NAMESPACE);
+ ml_option_destroy (info_list[i]);
+ g_free(info_list);
+ return 1;
+ }
+
+ gchar *path;
+ nRetVal = ml_option_get (info_list[i], "path", (void **) &path);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal), ml_option_destroy (info_list[i]); g_free (info_list));
+
+ if( strcmp(path, g_TestModel_add) != 0)
+ {
+ FPRINTF("[Line : %d][%s] Path value mismatched, Path1: [%s] and path2: [%s] \\n", __LINE__, API_NAMESPACE, g_TestModel_add, path);
+ ml_option_destroy (info_list[i]);
+ g_free (info_list);
+ return 1;
+ }
+ }
+ else
+ {
+ FPRINTF("[Line : %d][%s] value mismatched\\n", __LINE__, API_NAMESPACE);
+ ml_option_destroy (info_list[i]);
+ g_free (info_list);
+ return 1;
+ }
+
+ nRetVal = ml_option_destroy (info_list[i]);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_destroy", NnStreamerGetError(nRetVal), g_free (info_list));
+ }
+ if (info_list != NULL)
+ {
+ g_free (info_list);
+ info_list = NULL;
+ }
+
+ nRetVal = ml_service_model_delete(key, 1U);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_delete", NnStreamerGetError(nRetVal));
+
+ nRetVal = ml_service_model_activate (key, 2U);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_activate", NnStreamerGetError(nRetVal));
+
+ nRetVal = ml_service_model_get_activated (key, &activated_model_info);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_service_model_get_activated", NnStreamerGetError(nRetVal), ml_service_model_delete (key, 2U));
+
+ nRetVal = ml_option_get (activated_model_info, "path", (gpointer *) &getPathVal);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_get", NnStreamerGetError(nRetVal), ml_option_destroy (activated_model_info); ml_service_model_delete (key, 2U));
+ if( strcmp(g_TestModel_add, getPathVal) != 0)
+ {
+ FPRINTF("[Line : %d][%s] Path value mismatched, Path1: [%s] and path2: [%s] \\n", __LINE__, API_NAMESPACE, g_TestModel_add, getPathVal);
+ ml_option_destroy (activated_model_info);
+ ml_service_model_delete (key, 2U);
+ return 1;
+ }
+
+ nRetVal = ml_option_destroy (activated_model_info);
+ PRINT_RESULT_CLEANUP(ML_ERROR_NONE, nRetVal, "ml_option_destroy", NnStreamerGetError(nRetVal), ml_service_model_delete (key, 2U));
+
+ nRetVal = ml_service_model_delete (key, 2U);
+ PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_model_delete", NnStreamerGetError(nRetVal));
+ return 0;
+}
\ No newline at end of file