From: manu.tiwari Date: Sat, 14 May 2022 08:24:49 +0000 (+0530) Subject: [ITC][nnstreamer][ACR-1691] Added TCs for ml-service APIs X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e75cd788c8c8ca275e0a8fb20e81792b725085a;p=test%2Ftct%2Fnative%2Fapi.git [ITC][nnstreamer][ACR-1691] Added TCs for ml-service APIs Change-Id: I7801cbf5778bd33aa242e076259f4ae43d38804f Signed-off-by: manu.tiwari --- diff --git a/src/itc/nnstreamer/CMakeLists.txt b/src/itc/nnstreamer/CMakeLists.txt index d48ef4fe7..077249a31 100755 --- a/src/itc/nnstreamer/CMakeLists.txt +++ b/src/itc/nnstreamer/CMakeLists.txt @@ -12,6 +12,7 @@ SET(TC_SOURCES ITs-nnstreamer-switch.c ITs-nnstreamer-tensors.c ITs-nnstreamer-capi.c + ITs-nnstreamer-ml-service.c ) diff --git a/src/itc/nnstreamer/ITs-nnstreamer-common.h b/src/itc/nnstreamer/ITs-nnstreamer-common.h index e77993bb2..d6ce6a57d 100755 --- a/src/itc/nnstreamer/ITs-nnstreamer-common.h +++ b/src/itc/nnstreamer/ITs-nnstreamer-common.h @@ -37,6 +37,7 @@ bool g_bFeatureML; bool g_bFeatureMLInterference; bool g_bFeatureIsSupported; bool g_bCallbackHit; +bool g_bFeatureMLService; GMainLoop *g_pNnStreamerMainLoop; typedef struct @@ -68,6 +69,7 @@ void TensorInfoPipelineStop(ml_pipeline_h hPipelinehandle,ml_pipeline_src_h hPip #define FEATURE_ML "http://tizen.org/feature/machine_learning" #define FEATURE_ML_INTERFACE "http://tizen.org/feature/machine_learning.inference" +#define FEATURE_ML_SERVICE "http://tizen.org/feature/machine_learning.service" #define START_TEST {\ FPRINTF("[Line:%d][%s] Starting test check initialize : %s\\n", __LINE__, API_NAMESPACE, __FUNCTION__);\ @@ -89,6 +91,25 @@ void TensorInfoPipelineStop(ml_pipeline_h hPipelinehandle,ml_pipeline_src_h hPip }\ } +#define START_TEST_ML_SERVICE {\ + FPRINTF("[Line:%d][%s] Starting test check initialize : %s\\n", __LINE__, API_NAMESPACE, __FUNCTION__);\ + dlog_print(DLOG_INFO, "NativeTCT", "[Line:%d][%s] Starting test check initialize : %s", __LINE__, API_NAMESPACE, __FUNCTION__);\ +} + +#define ML_SERVICE_FEATURE_CHECK {\ + if ( !g_bFeatureML || !g_bFeatureMLService ) \ + {\ + if (nRetVal == TIZEN_ERROR_NOT_SUPPORTED){\ + FPRINTF("[Line:%d][%s] Feature is not supported \\n", __LINE__, API_NAMESPACE);\ + return 0;\ + }\ + else{\ + FPRINTF("[Line:%d][%s] Feature mismatch error \\n", __LINE__, API_NAMESPACE);\ + return 1;\ + }\ + }\ +} + #define CHECK_HANDLE_CLEANUP(Handle, API, FreeResource) {\ if ( Handle == NULL )\ {\ diff --git a/src/itc/nnstreamer/ITs-nnstreamer-ml-service.c b/src/itc/nnstreamer/ITs-nnstreamer-ml-service.c new file mode 100755 index 000000000..d1aa69aea --- /dev/null +++ b/src/itc/nnstreamer/ITs-nnstreamer-ml-service.c @@ -0,0 +1,204 @@ +// +// 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 "ITs-nnstreamer-common.h" +#include + +static gchar *g_TestModel; +static gchar *g_Pipeline; + +/** @addtogroup itc-nnstreamer +* @ingroup itc +* @{ +*/ + +//& set: nnstreamer + + +/** +* @function ITs_nnstreamer_ml_service_startup +* @description Called before each test, set the service boolean true +* @parameter NA +* @return NA +*/ +void ITs_nnstreamer_ml_service_startup(void) +{ + int nRet =-1; + struct stat buf; + if ( stat(ERR_LOG, &buf) == 0) + { + remove(ERR_LOG); + } +#if DEBUG + 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 = TCTCheckSystemInfoFeatureSupported(FEATURE_ML_SERVICE, API_NAMESPACE); + + 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 )) + { + 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); + } + else + { + FPRINTF("[%s][%d][%s] ERROR TO GET MODEL PATH\\n", __FILE__, __LINE__, __FUNCTION__); + } + + g_Pipeline = g_strdup_printf ("appsrc name=appsrc ! " + "other/tensors,num-tensors=1,dimensions=(string)1:1:1:1,types=(string)float32,framerate=(fraction)0/1,format=static ! " + "tensor_filter name=filter_h framework=tensorflow-lite model=%s ! tensor_sink name=tensor_sink", + g_TestModel); + } + return; +} + + +/** +* @function ITs_nnstreamer_ml_service_cleanup +* @description Called after each test +* @parameter NA +* @return NA +*/ +void ITs_nnstreamer_ml_service_cleanup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] TEST SUIT clean-up: ITs_nnstreamer_ml_service_cleanup\\n", __LINE__, API_NAMESPACE); +#endif + + if (g_bFeatureML && g_bFeatureMLService) + { + g_free (g_Pipeline); + g_free (g_TestModel); + } +} + +/* +* @testcase ITc_nnstreamer_ml_service_set_get_pipeline_p +* @since_tizen 7.0 +* @author SRID(shobhit.v) +* @reviewer SRID(ankit.sr1) +* @type auto +* @description Set pipeline and get pipeline +* @scenario Set pipeline and get pipeline +* @apicovered ml_service_set_pipeline and ml_service_get_pipeline +* @passcase When ml_service_set_pipeline and ml_service_get_pipeline is successful. +* @failcase If target API fails or any precondition API fails +* @precondition None +* @postcondition None +*/ +//& purpose: API to Check for set and get ml service pipeline +//& type: auto +int ITc_nnstreamer_ml_service_set_get_pipeline_p(void) +{ + START_TEST_ML_SERVICE; + + gchar *pipeline2, *get_pipeline; + const gchar *key = "ServiceName"; + int nRetVal = -1; + + nRetVal = ml_service_set_pipeline (key, g_Pipeline); + ML_SERVICE_FEATURE_CHECK; + PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_set_pipeline", NnStreamerGetError(nRetVal)); + + nRetVal = ml_service_get_pipeline (key, &get_pipeline); + ML_SERVICE_FEATURE_CHECK; + PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_get_pipeline", NnStreamerGetError(nRetVal)); + if (0 != strcmp (g_Pipeline, get_pipeline)) + { + FPRINTF("[Line : %d][%s] Set and Get pipeline value mismatch \\n", __LINE__, API_NAMESPACE); + g_free (get_pipeline); + return 1; + } + + g_free (get_pipeline); + + pipeline2 = + g_strdup_printf + ("v4l2src ! videoconvert ! videoscale ! video/x-raw,format=RGB,width=640,height=480,framerate=5/1 ! " + "mqttsink pub-topic=example/objectDetection"); + nRetVal = ml_service_set_pipeline (key, pipeline2); + PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_set_pipeline", NnStreamerGetError(nRetVal)); + + nRetVal = ml_service_get_pipeline (key, &get_pipeline); + PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_get_pipeline", NnStreamerGetError(nRetVal)); + if (0 != strcmp (pipeline2, get_pipeline)) + { + FPRINTF("[Line : %d][%s] Set and Get pipeline value mismatch for second key\\n", __LINE__, API_NAMESPACE); + g_free (pipeline2); + g_free (get_pipeline); + return 1; + } + g_free (pipeline2); + g_free (get_pipeline); + + return 0; +} + +/* +* @testcase ITc_nnstreamer_ml_service_delete_pipeline_p +* @since_tizen 7.0 +* @author SRID(shobhit.v) +* @reviewer SRID(ankit.sr1) +* @type auto +* @description Set pipeline and get pipeline +* @scenario Set pipeline and get pipeline +* @apicovered ml_service_set_pipeline, ml_service_get_pipeline and ml_service_delete_pipeline +* @passcase When ml_service_delete_pipeline is successful. +* @failcase If target API fails or any precondition API fails +* @precondition None +* @postcondition None +*/ +//& purpose: API to Check for delete pipeline ml service +//& type: auto +int ITc_nnstreamer_ml_service_delete_pipeline_p(void) +{ + START_TEST_ML_SERVICE; + + gchar *get_pipeline; + const gchar *key = "ServiceName"; + int nRetVal = -1; + + nRetVal = ml_service_set_pipeline (key, g_Pipeline); + PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_set_pipeline", NnStreamerGetError(nRetVal)); + + nRetVal = ml_service_get_pipeline (key, &get_pipeline); + PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_get_pipeline", NnStreamerGetError(nRetVal)); + if (0 != strcmp (g_Pipeline, get_pipeline)) + { + FPRINTF("[Line : %d][%s] Set and Get pipeline value mismatch for second key\\n", __LINE__, API_NAMESPACE); + g_free (get_pipeline); + return 1; + } + + nRetVal = ml_service_delete_pipeline (key); + ML_SERVICE_FEATURE_CHECK; + PRINT_RESULT(ML_ERROR_NONE, nRetVal, "ml_service_delete_pipeline", NnStreamerGetError(nRetVal)); + + nRetVal = ml_service_get_pipeline (key, &get_pipeline); + PRINT_RESULT(ML_ERROR_INVALID_PARAMETER, nRetVal, "ml_service_get_pipeline", NnStreamerGetError(nRetVal)); + + g_free (get_pipeline); + + return 0; +} diff --git a/src/itc/nnstreamer/tct-nnstreamer-native_mobile.h b/src/itc/nnstreamer/tct-nnstreamer-native_mobile.h index 473bf9b52..ecfa16eb4 100755 --- a/src/itc/nnstreamer/tct-nnstreamer-native_mobile.h +++ b/src/itc/nnstreamer/tct-nnstreamer-native_mobile.h @@ -31,6 +31,8 @@ extern void ITs_nnstreamer_pipeline_switch_startup (void); extern void ITs_nnstreamer_pipeline_switch_cleanup (void); extern void ITs_nnstreamer_capi_startup (void); extern void ITs_nnstreamer_capi_cleanup (void); +extern void ITs_nnstreamer_ml_service_startup(void); +extern void ITs_nnstreamer_ml_service_cleanup(void); extern int ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p (void); extern int ITc_nnstreamer_pipeline_ml_pipeline_get_state_p (void); @@ -79,6 +81,8 @@ extern int ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p(v extern int ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p(void); extern int ITc_nnstreamer_pipeline_ml_pipeline_src_set_event_cb_p(void); extern int ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p(void); +extern int ITc_nnstreamer_ml_service_set_get_pipeline_p(void); +extern int ITc_nnstreamer_ml_service_delete_pipeline_p(void); testcase tc_array[] = { {"ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p", ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p, ITs_nnstreamer_pipeline_startup, ITs_nnstreamer_pipeline_cleanup}, @@ -128,6 +132,8 @@ testcase tc_array[] = { {"ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p", ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p, ITs_nnstreamer_capi_startup, ITs_nnstreamer_capi_cleanup}, {"ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p", ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p, ITs_nnstreamer_capi_startup, ITs_nnstreamer_capi_cleanup}, {"ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p", ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p, ITs_nnstreamer_pipeline_startup, ITs_nnstreamer_pipeline_cleanup}, +{"ITc_nnstreamer_ml_service_set_get_pipeline_p", ITc_nnstreamer_ml_service_set_get_pipeline_p, ITs_nnstreamer_ml_service_startup, ITs_nnstreamer_ml_service_cleanup}, +{"ITc_nnstreamer_ml_service_delete_pipeline_p", ITc_nnstreamer_ml_service_delete_pipeline_p, ITs_nnstreamer_ml_service_startup, ITs_nnstreamer_ml_service_cleanup}, {NULL, NULL} }; diff --git a/src/itc/nnstreamer/tct-nnstreamer-native_tizeniot.h b/src/itc/nnstreamer/tct-nnstreamer-native_tizeniot.h index b7217dc3e..603ffe2a7 100755 --- a/src/itc/nnstreamer/tct-nnstreamer-native_tizeniot.h +++ b/src/itc/nnstreamer/tct-nnstreamer-native_tizeniot.h @@ -31,6 +31,8 @@ extern void ITs_nnstreamer_pipeline_switch_startup (void); extern void ITs_nnstreamer_pipeline_switch_cleanup (void); extern void ITs_nnstreamer_capi_startup (void); extern void ITs_nnstreamer_capi_cleanup (void); +extern void ITs_nnstreamer_ml_service_startup(void); +extern void ITs_nnstreamer_ml_service_cleanup(void); extern int ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p (void); extern int ITc_nnstreamer_pipeline_ml_pipeline_get_state_p (void); @@ -79,6 +81,8 @@ extern int ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p(v extern int ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p(void); extern int ITc_nnstreamer_pipeline_ml_pipeline_src_set_event_cb_p(void); extern int ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p(void); +extern int ITc_nnstreamer_ml_service_set_get_pipeline_p(void); +extern int ITc_nnstreamer_ml_service_delete_pipeline_p(void); testcase tc_array[] = { {"ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p", ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p, ITs_nnstreamer_pipeline_startup, ITs_nnstreamer_pipeline_cleanup}, @@ -128,6 +132,8 @@ testcase tc_array[] = { {"ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p", ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p, ITs_nnstreamer_capi_startup, ITs_nnstreamer_capi_cleanup}, {"ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p", ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p, ITs_nnstreamer_capi_startup, ITs_nnstreamer_capi_cleanup}, {"ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p", ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p, ITs_nnstreamer_pipeline_startup, ITs_nnstreamer_pipeline_cleanup}, +{"ITc_nnstreamer_ml_service_set_get_pipeline_p", ITc_nnstreamer_ml_service_set_get_pipeline_p, ITs_nnstreamer_ml_service_startup, ITs_nnstreamer_ml_service_cleanup}, +{"ITc_nnstreamer_ml_service_delete_pipeline_p", ITc_nnstreamer_ml_service_delete_pipeline_p, ITs_nnstreamer_ml_service_startup, ITs_nnstreamer_ml_service_cleanup}, {NULL, NULL} }; diff --git a/src/itc/nnstreamer/tct-nnstreamer-native_tv.h b/src/itc/nnstreamer/tct-nnstreamer-native_tv.h index 96d1f7c95..40987026a 100755 --- a/src/itc/nnstreamer/tct-nnstreamer-native_tv.h +++ b/src/itc/nnstreamer/tct-nnstreamer-native_tv.h @@ -31,6 +31,8 @@ extern void ITs_nnstreamer_pipeline_switch_startup (void); extern void ITs_nnstreamer_pipeline_switch_cleanup (void); extern void ITs_nnstreamer_capi_startup (void); extern void ITs_nnstreamer_capi_cleanup (void); +extern void ITs_nnstreamer_ml_service_startup(void); +extern void ITs_nnstreamer_ml_service_cleanup(void); extern int ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p (void); extern int ITc_nnstreamer_pipeline_ml_pipeline_get_state_p (void); @@ -78,6 +80,8 @@ extern int ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p(v extern int ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p(void); extern int ITc_nnstreamer_pipeline_ml_pipeline_src_set_event_cb_p(void); extern int ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p(void); +extern int ITc_nnstreamer_ml_service_set_get_pipeline_p(void); +extern int ITc_nnstreamer_ml_service_delete_pipeline_p(void); testcase tc_array[] = { {"ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p", ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p, ITs_nnstreamer_pipeline_startup, ITs_nnstreamer_pipeline_cleanup}, @@ -126,6 +130,8 @@ testcase tc_array[] = { {"ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p", ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p, ITs_nnstreamer_capi_startup, ITs_nnstreamer_capi_cleanup}, {"ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p", ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p, ITs_nnstreamer_capi_startup, ITs_nnstreamer_capi_cleanup}, {"ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p", ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p, ITs_nnstreamer_pipeline_startup, ITs_nnstreamer_pipeline_cleanup}, +{"ITc_nnstreamer_ml_service_set_get_pipeline_p", ITc_nnstreamer_ml_service_set_get_pipeline_p, ITs_nnstreamer_ml_service_startup, ITs_nnstreamer_ml_service_cleanup}, +{"ITc_nnstreamer_ml_service_delete_pipeline_p", ITc_nnstreamer_ml_service_delete_pipeline_p, ITs_nnstreamer_ml_service_startup, ITs_nnstreamer_ml_service_cleanup}, {NULL, NULL} }; diff --git a/src/itc/nnstreamer/tct-nnstreamer-native_wearable.h b/src/itc/nnstreamer/tct-nnstreamer-native_wearable.h index b7217dc3e..603ffe2a7 100755 --- a/src/itc/nnstreamer/tct-nnstreamer-native_wearable.h +++ b/src/itc/nnstreamer/tct-nnstreamer-native_wearable.h @@ -31,6 +31,8 @@ extern void ITs_nnstreamer_pipeline_switch_startup (void); extern void ITs_nnstreamer_pipeline_switch_cleanup (void); extern void ITs_nnstreamer_capi_startup (void); extern void ITs_nnstreamer_capi_cleanup (void); +extern void ITs_nnstreamer_ml_service_startup(void); +extern void ITs_nnstreamer_ml_service_cleanup(void); extern int ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p (void); extern int ITc_nnstreamer_pipeline_ml_pipeline_get_state_p (void); @@ -79,6 +81,8 @@ extern int ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p(v extern int ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p(void); extern int ITc_nnstreamer_pipeline_ml_pipeline_src_set_event_cb_p(void); extern int ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p(void); +extern int ITc_nnstreamer_ml_service_set_get_pipeline_p(void); +extern int ITc_nnstreamer_ml_service_delete_pipeline_p(void); testcase tc_array[] = { {"ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p", ITc_nnstreamer_pipeline_ml_pipeline_construct_destroy_p, ITs_nnstreamer_pipeline_startup, ITs_nnstreamer_pipeline_cleanup}, @@ -128,6 +132,8 @@ testcase tc_array[] = { {"ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p", ITc_nnstreamer_ml_pipeline_custom_easy_filter_register_unregister_p, ITs_nnstreamer_capi_startup, ITs_nnstreamer_capi_cleanup}, {"ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p", ITc_nnstreamer_ml_pipeline_tensor_if_custom_register_unregister_p, ITs_nnstreamer_capi_startup, ITs_nnstreamer_capi_cleanup}, {"ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p", ITc_nnstreamer_pipeline_ml_check_nnfw_availability_full_p, ITs_nnstreamer_pipeline_startup, ITs_nnstreamer_pipeline_cleanup}, +{"ITc_nnstreamer_ml_service_set_get_pipeline_p", ITc_nnstreamer_ml_service_set_get_pipeline_p, ITs_nnstreamer_ml_service_startup, ITs_nnstreamer_ml_service_cleanup}, +{"ITc_nnstreamer_ml_service_delete_pipeline_p", ITc_nnstreamer_ml_service_delete_pipeline_p, ITs_nnstreamer_ml_service_startup, ITs_nnstreamer_ml_service_cleanup}, {NULL, NULL} };