[UTC][nnstreamer][ACR-1830] Add new testcases for ml-service 62/308862/4
authorgichan2-jang <gichan2.jang@samsung.com>
Tue, 2 Apr 2024 03:56:49 +0000 (12:56 +0900)
committergichan2-jang <gichan2.jang@samsung.com>
Thu, 4 Apr 2024 00:52:02 +0000 (09:52 +0900)
Add new testcases for ml-service.

Change-Id: I41c2ca4abc50ab75a7b1b9f1c720662253c046d6
Signed-off-by: gichan2-jang <gichan2.jang@samsung.com>
src/utc/nnstreamer/res/config_single_imgclf_key.conf [new file with mode: 0644]
src/utc/nnstreamer/tct-nnstreamer-core_mobile.h
src/utc/nnstreamer/tct-nnstreamer-core_tizeniot.h
src/utc/nnstreamer/tct-nnstreamer-core_tv.h
src/utc/nnstreamer/tct-nnstreamer-core_wearable.h
src/utc/nnstreamer/utc-machine-learning-service.c
src/utc/nnstreamer/utc-nnstreamer-pipeline-tensor-data.c

diff --git a/src/utc/nnstreamer/res/config_single_imgclf_key.conf b/src/utc/nnstreamer/res/config_single_imgclf_key.conf
new file mode 100644 (file)
index 0000000..53f4a1d
--- /dev/null
@@ -0,0 +1,11 @@
+{
+    "single" :
+    {
+        "key" : "test-single-imgclf"
+    },
+    "information" :
+    {
+        "threshold" : "0.5",
+        "description" : "Config file to run unittest for ml-extension."
+    }
+}
\ No newline at end of file
index 2adc163684dc845e285066986031401df33d4c2a..4a6c076c983d1d88bcfba458a84eefa937090667 100755 (executable)
@@ -141,6 +141,14 @@ extern int utc_ml_tensors_data_get_tensor_data_n (void);
 
 extern int utc_ml_tensors_data_set_tensor_data_p (void);
 extern int utc_ml_tensors_data_set_tensor_data_n (void);
+extern int utc_ml_tensors_data_clone_p (void);
+extern int utc_ml_tensors_data_clone_n1 (void);
+extern int utc_ml_tensors_data_clone_n2 (void);
+
+extern int utc_ml_tensors_data_get_info_p (void);
+extern int utc_ml_tensors_data_get_info_n1 (void);
+extern int utc_ml_tensors_data_get_info_n2 (void);
+
 extern int utc_ml_single_open_p (void);
 extern int utc_ml_single_open_n (void);
 extern int utc_ml_single_close_p (void);
@@ -386,6 +394,33 @@ extern int utc_ml_service_resource_get_n1 (void);
 extern int utc_ml_service_resource_get_n2 (void);
 extern int utc_ml_service_resource_scenario_p1 (void);
 
+extern int utc_ml_service_new_p1 (void);
+extern int utc_ml_service_new_n1 (void);
+extern int utc_ml_service_new_n2 (void);
+extern int utc_ml_service_set_event_cb_p1 (void);
+
+extern int utc_ml_service_set_event_cb_n1 (void);
+extern int utc_ml_service_get_input_information_p1 (void);
+extern int utc_ml_service_get_input_information_n1 (void);
+extern int utc_ml_service_get_input_information_n2 (void);
+extern int utc_ml_service_get_output_information_p1 (void);
+
+extern int utc_ml_service_get_output_information_n1 (void);
+extern int utc_ml_service_get_output_information_n2 (void);
+extern int utc_ml_service_set_information_p1 (void);
+extern int utc_ml_service_set_information_n1 (void);
+extern int utc_ml_service_set_information_n2 (void);
+
+extern int utc_ml_service_set_information_n3 (void);
+extern int utc_ml_service_get_information_p1 (void);
+extern int utc_ml_service_get_information_n1 (void);
+extern int utc_ml_service_get_information_n2 (void);
+extern int utc_ml_service_get_information_n3 (void);
+extern int utc_ml_service_request_p1 (void);
+
+extern int utc_ml_service_request_n1 (void);
+extern int utc_ml_service_request_n2 (void);
+
 testcase tc_array[] = {
   {"utc_ml_pipeline_construct_p", utc_ml_pipeline_construct_p, utc_nnstreamer_pipeline_startup, utc_nnstreamer_pipeline_cleanup},
   {"utc_ml_pipeline_construct_n", utc_ml_pipeline_construct_n, utc_nnstreamer_pipeline_startup, utc_nnstreamer_pipeline_cleanup},
@@ -486,6 +521,14 @@ testcase tc_array[] = {
 
   {"utc_ml_tensors_data_set_tensor_data_p", utc_ml_tensors_data_set_tensor_data_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
   {"utc_ml_tensors_data_set_tensor_data_n", utc_ml_tensors_data_set_tensor_data_n, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_p", utc_ml_tensors_data_clone_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_n1", utc_ml_tensors_data_clone_n1, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_n2", utc_ml_tensors_data_clone_n2, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+
+  {"utc_ml_tensors_data_get_info_p", utc_ml_tensors_data_get_info_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_get_info_n1", utc_ml_tensors_data_get_info_n1, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_get_info_n2", utc_ml_tensors_data_get_info_n2, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+
   {"utc_ml_single_open_p", utc_ml_single_open_p, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
   {"utc_ml_single_open_n", utc_ml_single_open_n, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
   {"utc_ml_single_close_p", utc_ml_single_close_p, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
@@ -731,6 +774,33 @@ testcase tc_array[] = {
   {"utc_ml_service_resource_get_n2", utc_ml_service_resource_get_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
   {"utc_ml_service_resource_scenario_p1", utc_ml_service_resource_scenario_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
 
+  {"utc_ml_service_new_p1", utc_ml_service_new_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_new_n1", utc_ml_service_new_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_new_n2", utc_ml_service_new_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_event_cb_p1", utc_ml_service_set_event_cb_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_set_event_cb_n1", utc_ml_service_set_event_cb_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_input_information_p1", utc_ml_service_get_input_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_input_information_n1", utc_ml_service_get_input_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_input_information_n2", utc_ml_service_get_input_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_output_information_p1", utc_ml_service_get_output_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_get_output_information_n1", utc_ml_service_get_output_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_output_information_n2", utc_ml_service_get_output_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_information_p1", utc_ml_service_set_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_information_n1", utc_ml_service_set_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_information_n2", utc_ml_service_set_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_set_information_n3", utc_ml_service_set_information_n3, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_p1", utc_ml_service_get_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_n1", utc_ml_service_get_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_n2", utc_ml_service_get_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_n3", utc_ml_service_get_information_n3, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_request_p1", utc_ml_service_request_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_request_n1", utc_ml_service_request_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_request_n2", utc_ml_service_request_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
   {NULL, NULL}
 };
 
index 2adc163684dc845e285066986031401df33d4c2a..4a6c076c983d1d88bcfba458a84eefa937090667 100755 (executable)
@@ -141,6 +141,14 @@ extern int utc_ml_tensors_data_get_tensor_data_n (void);
 
 extern int utc_ml_tensors_data_set_tensor_data_p (void);
 extern int utc_ml_tensors_data_set_tensor_data_n (void);
+extern int utc_ml_tensors_data_clone_p (void);
+extern int utc_ml_tensors_data_clone_n1 (void);
+extern int utc_ml_tensors_data_clone_n2 (void);
+
+extern int utc_ml_tensors_data_get_info_p (void);
+extern int utc_ml_tensors_data_get_info_n1 (void);
+extern int utc_ml_tensors_data_get_info_n2 (void);
+
 extern int utc_ml_single_open_p (void);
 extern int utc_ml_single_open_n (void);
 extern int utc_ml_single_close_p (void);
@@ -386,6 +394,33 @@ extern int utc_ml_service_resource_get_n1 (void);
 extern int utc_ml_service_resource_get_n2 (void);
 extern int utc_ml_service_resource_scenario_p1 (void);
 
+extern int utc_ml_service_new_p1 (void);
+extern int utc_ml_service_new_n1 (void);
+extern int utc_ml_service_new_n2 (void);
+extern int utc_ml_service_set_event_cb_p1 (void);
+
+extern int utc_ml_service_set_event_cb_n1 (void);
+extern int utc_ml_service_get_input_information_p1 (void);
+extern int utc_ml_service_get_input_information_n1 (void);
+extern int utc_ml_service_get_input_information_n2 (void);
+extern int utc_ml_service_get_output_information_p1 (void);
+
+extern int utc_ml_service_get_output_information_n1 (void);
+extern int utc_ml_service_get_output_information_n2 (void);
+extern int utc_ml_service_set_information_p1 (void);
+extern int utc_ml_service_set_information_n1 (void);
+extern int utc_ml_service_set_information_n2 (void);
+
+extern int utc_ml_service_set_information_n3 (void);
+extern int utc_ml_service_get_information_p1 (void);
+extern int utc_ml_service_get_information_n1 (void);
+extern int utc_ml_service_get_information_n2 (void);
+extern int utc_ml_service_get_information_n3 (void);
+extern int utc_ml_service_request_p1 (void);
+
+extern int utc_ml_service_request_n1 (void);
+extern int utc_ml_service_request_n2 (void);
+
 testcase tc_array[] = {
   {"utc_ml_pipeline_construct_p", utc_ml_pipeline_construct_p, utc_nnstreamer_pipeline_startup, utc_nnstreamer_pipeline_cleanup},
   {"utc_ml_pipeline_construct_n", utc_ml_pipeline_construct_n, utc_nnstreamer_pipeline_startup, utc_nnstreamer_pipeline_cleanup},
@@ -486,6 +521,14 @@ testcase tc_array[] = {
 
   {"utc_ml_tensors_data_set_tensor_data_p", utc_ml_tensors_data_set_tensor_data_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
   {"utc_ml_tensors_data_set_tensor_data_n", utc_ml_tensors_data_set_tensor_data_n, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_p", utc_ml_tensors_data_clone_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_n1", utc_ml_tensors_data_clone_n1, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_n2", utc_ml_tensors_data_clone_n2, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+
+  {"utc_ml_tensors_data_get_info_p", utc_ml_tensors_data_get_info_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_get_info_n1", utc_ml_tensors_data_get_info_n1, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_get_info_n2", utc_ml_tensors_data_get_info_n2, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+
   {"utc_ml_single_open_p", utc_ml_single_open_p, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
   {"utc_ml_single_open_n", utc_ml_single_open_n, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
   {"utc_ml_single_close_p", utc_ml_single_close_p, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
@@ -731,6 +774,33 @@ testcase tc_array[] = {
   {"utc_ml_service_resource_get_n2", utc_ml_service_resource_get_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
   {"utc_ml_service_resource_scenario_p1", utc_ml_service_resource_scenario_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
 
+  {"utc_ml_service_new_p1", utc_ml_service_new_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_new_n1", utc_ml_service_new_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_new_n2", utc_ml_service_new_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_event_cb_p1", utc_ml_service_set_event_cb_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_set_event_cb_n1", utc_ml_service_set_event_cb_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_input_information_p1", utc_ml_service_get_input_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_input_information_n1", utc_ml_service_get_input_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_input_information_n2", utc_ml_service_get_input_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_output_information_p1", utc_ml_service_get_output_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_get_output_information_n1", utc_ml_service_get_output_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_output_information_n2", utc_ml_service_get_output_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_information_p1", utc_ml_service_set_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_information_n1", utc_ml_service_set_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_information_n2", utc_ml_service_set_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_set_information_n3", utc_ml_service_set_information_n3, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_p1", utc_ml_service_get_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_n1", utc_ml_service_get_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_n2", utc_ml_service_get_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_n3", utc_ml_service_get_information_n3, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_request_p1", utc_ml_service_request_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_request_n1", utc_ml_service_request_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_request_n2", utc_ml_service_request_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
   {NULL, NULL}
 };
 
index 7bc6938e2840583677375c96b44085cf1650df44..bf04ff409fb618e64e493e9b0edf785d22f258ad 100755 (executable)
@@ -139,6 +139,14 @@ extern int utc_ml_tensors_data_get_tensor_data_n (void);
 
 extern int utc_ml_tensors_data_set_tensor_data_p (void);
 extern int utc_ml_tensors_data_set_tensor_data_n (void);
+extern int utc_ml_tensors_data_clone_p (void);
+extern int utc_ml_tensors_data_clone_n1 (void);
+extern int utc_ml_tensors_data_clone_n2 (void);
+
+extern int utc_ml_tensors_data_get_info_p (void);
+extern int utc_ml_tensors_data_get_info_n1 (void);
+extern int utc_ml_tensors_data_get_info_n2 (void);
+
 extern int utc_ml_single_open_p (void);
 extern int utc_ml_single_open_n (void);
 extern int utc_ml_single_close_p (void);
@@ -430,6 +438,15 @@ testcase tc_array[] = {
   {"utc_ml_tensors_data_set_tensor_data_p", utc_ml_tensors_data_set_tensor_data_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
   {"utc_ml_tensors_data_set_tensor_data_n", utc_ml_tensors_data_set_tensor_data_n, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
 
+  {"utc_ml_tensors_data_clone_p", utc_ml_tensors_data_clone_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_n1", utc_ml_tensors_data_clone_n1, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_n2", utc_ml_tensors_data_clone_n2, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+
+  {"utc_ml_tensors_data_get_info_p", utc_ml_tensors_data_get_info_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_get_info_n1", utc_ml_tensors_data_get_info_n1, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_get_info_n2", utc_ml_tensors_data_get_info_n2, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+
+
   {"utc_ml_single_open_p", utc_ml_single_open_p, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
   {"utc_ml_single_open_n", utc_ml_single_open_n, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
   {"utc_ml_single_close_p", utc_ml_single_close_p, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
index 2adc163684dc845e285066986031401df33d4c2a..4a6c076c983d1d88bcfba458a84eefa937090667 100755 (executable)
@@ -141,6 +141,14 @@ extern int utc_ml_tensors_data_get_tensor_data_n (void);
 
 extern int utc_ml_tensors_data_set_tensor_data_p (void);
 extern int utc_ml_tensors_data_set_tensor_data_n (void);
+extern int utc_ml_tensors_data_clone_p (void);
+extern int utc_ml_tensors_data_clone_n1 (void);
+extern int utc_ml_tensors_data_clone_n2 (void);
+
+extern int utc_ml_tensors_data_get_info_p (void);
+extern int utc_ml_tensors_data_get_info_n1 (void);
+extern int utc_ml_tensors_data_get_info_n2 (void);
+
 extern int utc_ml_single_open_p (void);
 extern int utc_ml_single_open_n (void);
 extern int utc_ml_single_close_p (void);
@@ -386,6 +394,33 @@ extern int utc_ml_service_resource_get_n1 (void);
 extern int utc_ml_service_resource_get_n2 (void);
 extern int utc_ml_service_resource_scenario_p1 (void);
 
+extern int utc_ml_service_new_p1 (void);
+extern int utc_ml_service_new_n1 (void);
+extern int utc_ml_service_new_n2 (void);
+extern int utc_ml_service_set_event_cb_p1 (void);
+
+extern int utc_ml_service_set_event_cb_n1 (void);
+extern int utc_ml_service_get_input_information_p1 (void);
+extern int utc_ml_service_get_input_information_n1 (void);
+extern int utc_ml_service_get_input_information_n2 (void);
+extern int utc_ml_service_get_output_information_p1 (void);
+
+extern int utc_ml_service_get_output_information_n1 (void);
+extern int utc_ml_service_get_output_information_n2 (void);
+extern int utc_ml_service_set_information_p1 (void);
+extern int utc_ml_service_set_information_n1 (void);
+extern int utc_ml_service_set_information_n2 (void);
+
+extern int utc_ml_service_set_information_n3 (void);
+extern int utc_ml_service_get_information_p1 (void);
+extern int utc_ml_service_get_information_n1 (void);
+extern int utc_ml_service_get_information_n2 (void);
+extern int utc_ml_service_get_information_n3 (void);
+extern int utc_ml_service_request_p1 (void);
+
+extern int utc_ml_service_request_n1 (void);
+extern int utc_ml_service_request_n2 (void);
+
 testcase tc_array[] = {
   {"utc_ml_pipeline_construct_p", utc_ml_pipeline_construct_p, utc_nnstreamer_pipeline_startup, utc_nnstreamer_pipeline_cleanup},
   {"utc_ml_pipeline_construct_n", utc_ml_pipeline_construct_n, utc_nnstreamer_pipeline_startup, utc_nnstreamer_pipeline_cleanup},
@@ -486,6 +521,14 @@ testcase tc_array[] = {
 
   {"utc_ml_tensors_data_set_tensor_data_p", utc_ml_tensors_data_set_tensor_data_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
   {"utc_ml_tensors_data_set_tensor_data_n", utc_ml_tensors_data_set_tensor_data_n, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_p", utc_ml_tensors_data_clone_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_n1", utc_ml_tensors_data_clone_n1, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_clone_n2", utc_ml_tensors_data_clone_n2, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+
+  {"utc_ml_tensors_data_get_info_p", utc_ml_tensors_data_get_info_p, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_get_info_n1", utc_ml_tensors_data_get_info_n1, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+  {"utc_ml_tensors_data_get_info_n2", utc_ml_tensors_data_get_info_n2, utc_nnstreamer_pipeline_tensor_data_startup, utc_nnstreamer_pipeline_tensor_data_cleanup},
+
   {"utc_ml_single_open_p", utc_ml_single_open_p, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
   {"utc_ml_single_open_n", utc_ml_single_open_n, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
   {"utc_ml_single_close_p", utc_ml_single_close_p, utc_nnstreamer_single_startup, utc_nnstreamer_single_cleanup},
@@ -731,6 +774,33 @@ testcase tc_array[] = {
   {"utc_ml_service_resource_get_n2", utc_ml_service_resource_get_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
   {"utc_ml_service_resource_scenario_p1", utc_ml_service_resource_scenario_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
 
+  {"utc_ml_service_new_p1", utc_ml_service_new_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_new_n1", utc_ml_service_new_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_new_n2", utc_ml_service_new_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_event_cb_p1", utc_ml_service_set_event_cb_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_set_event_cb_n1", utc_ml_service_set_event_cb_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_input_information_p1", utc_ml_service_get_input_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_input_information_n1", utc_ml_service_get_input_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_input_information_n2", utc_ml_service_get_input_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_output_information_p1", utc_ml_service_get_output_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_get_output_information_n1", utc_ml_service_get_output_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_output_information_n2", utc_ml_service_get_output_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_information_p1", utc_ml_service_set_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_information_n1", utc_ml_service_set_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_set_information_n2", utc_ml_service_set_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_set_information_n3", utc_ml_service_set_information_n3, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_p1", utc_ml_service_get_information_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_n1", utc_ml_service_get_information_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_n2", utc_ml_service_get_information_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_get_information_n3", utc_ml_service_get_information_n3, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_request_p1", utc_ml_service_request_p1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
+  {"utc_ml_service_request_n1", utc_ml_service_request_n1, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+  {"utc_ml_service_request_n2", utc_ml_service_request_n2, utc_machine_learning_service_startup, utc_machine_learning_service_cleanup},
+
   {NULL, NULL}
 };
 
index fbd53c0fc04980b16e04c66ed03d74f9f2a370be..e5f14b7b781796afaa1f1eb83541d55dcb05ce87 100644 (file)
@@ -33,6 +33,7 @@ static int status;
 static gchar *test_model;
 static gchar *test_model_add;
 static gchar *pipeline;
+static gchar *config_path;
 
 /**
  * @brief Get available port number.
@@ -74,6 +75,7 @@ void utc_machine_learning_service_startup (void)
 {
   const gchar *model_file = "mobilenet_v1_1.0_224_quant.tflite";
   const gchar *model_file_add = "add.tflite";
+  const gchar *config_file = "config_single_imgclf_key.conf";
 
        int ret = system_info_get_platform_bool(FEATURE_ML, &feature_ml);
   if (ret != SYSTEM_INFO_ERROR_NONE || !feature_ml) {
@@ -91,15 +93,20 @@ void utc_machine_learning_service_startup (void)
 
   if ( true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE ))
   {
-    int model_path_len = strlen(pszValue) + strlen(model_file) + 10;
-    test_model = (gchar*)malloc(model_path_len);
-    snprintf(test_model, model_path_len, "%s/res/res/%s", pszValue, model_file);
+    int path_len = strlen(pszValue) + strlen(model_file) + 10;
+    test_model = (gchar*)malloc(path_len);
+    snprintf(test_model, path_len, "%s/res/res/%s", pszValue, model_file);
     FPRINTF("[%s][%d][%s] %s\\n", __FILE__, __LINE__, __FUNCTION__, test_model);
 
-    model_path_len = strlen(pszValue) + strlen(model_file_add) + 10;
-    test_model_add = (gchar*)malloc(model_path_len);
-    snprintf(test_model_add, model_path_len, "%s/res/res/%s", pszValue, model_file_add);
+    path_len = strlen(pszValue) + strlen(model_file_add) + 10;
+    test_model_add = (gchar*)malloc(path_len);
+    snprintf(test_model_add, path_len, "%s/res/res/%s", pszValue, model_file_add);
     FPRINTF("[%s][%d][%s] %s\\n", __FILE__, __LINE__, __FUNCTION__, test_model_add);
+
+    path_len = strlen(pszValue) + strlen(config_file) + 10;
+    config_path = (gchar*)malloc(path_len);
+    snprintf(config_path, path_len, "%s/res/res/%s", pszValue, config_file);
+    FPRINTF("[%s][%d][%s] %s\\n", __FILE__, __LINE__, __FUNCTION__, config_path);
   }
   else
   {
@@ -126,6 +133,7 @@ void utc_machine_learning_service_cleanup (void)
   g_free (pipeline);
   g_free (test_model);
   g_free (test_model_add);
+  g_free (config_path);
 }
 
 /**
@@ -1386,3 +1394,749 @@ int utc_ml_service_resource_scenario_p1 (void)
 
   return 0;
 }
+
+/**
+ * @testcase           utc_ml_service_new_p1
+ * @since_tizen                9.0
+ * @description                Positive test case to crete machine learing service handle.
+ */
+int utc_ml_service_new_p1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  /* Test */
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_new_n1
+ * @since_tizen                9.0
+ * @description                Negative test case to crete machine learing service handle with invalid param.
+ */
+int utc_ml_service_new_n1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+
+  /* Test */
+  status = ml_service_new (NULL, &handle);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+  assert (NULL == handle);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_new_n2
+ * @since_tizen                9.0
+ * @description                Negative test case to crete machine learing service handle with invalid param.
+ */
+int utc_ml_service_new_n2 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+
+  /* Test */
+  status = ml_service_new (config_path, NULL);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  return 0;
+}
+
+/**
+ * @function           _ml_service_test_imgclf_cb
+ * @description                Event callback for machine learning service.
+ */
+static void
+_ml_service_test_imgclf_cb (ml_service_event_e event, ml_information_h event_data, void *user_data)
+{
+  guint *received = (guint *) user_data;
+
+  switch (event) {
+    case ML_SERVICE_EVENT_NEW_DATA:
+      assert_neq_no_return (NULL, event_data);
+      (*received)++;
+      break;
+    default:
+      break;
+    }
+}
+
+/**
+ * @testcase           utc_ml_service_set_event_cb_p1
+ * @since_tizen                9.0
+ * @description                Positive test case to set ml-service event callback.
+ */
+int utc_ml_service_set_event_cb_p1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_set_event_cb (handle, _ml_service_test_imgclf_cb, NULL);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_set_event_cb_n1
+ * @since_tizen                9.0
+ * @description                Negative test case to destroy machine learing service handle with invalid param.
+ */
+int utc_ml_service_set_event_cb_n1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+
+  /* Test */
+  status = ml_service_set_event_cb (NULL, _ml_service_test_imgclf_cb, NULL);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_input_information_p1
+ * @since_tizen                9.0
+ * @description                Positive test case to get input information.
+ */
+int utc_ml_service_get_input_information_p1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  ml_tensors_info_h info;
+  guint count = 0;
+  ml_tensor_type_e type;
+  ml_tensor_dimension in_dim = { 0 };
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_get_input_information (handle, NULL, &info);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_info_get_count (info, &count);
+  assert_eq (ML_ERROR_NONE, status);
+  assert_eq (1U, count);
+
+  type = ML_TENSOR_TYPE_UNKNOWN;
+  status = ml_tensors_info_get_tensor_type (info, 0, &type);
+  assert_eq (ML_ERROR_NONE, status);
+  assert_eq (ML_TENSOR_TYPE_UINT8, type);
+
+  status = ml_tensors_info_get_tensor_dimension (info, 0, in_dim);
+  assert_eq (ML_ERROR_NONE, status);
+  assert_eq (3U, in_dim[0]);
+  assert_eq (224U, in_dim[1]);
+  assert_eq (224U, in_dim[2]);
+  assert_eq (1U, in_dim[3]);
+
+  status = ml_tensors_info_destroy (info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_input_information_n1
+ * @since_tizen                9.0
+ * @description                Negative test case to get input information with invalid param.
+ */
+int utc_ml_service_get_input_information_n1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_tensors_info_h info;
+
+  /* Test */
+  status = ml_service_get_input_information (NULL, NULL, &info);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_input_information_n2
+ * @since_tizen                9.0
+ * @description                Negative test case to get input information with invalid param.
+ */
+int utc_ml_service_get_input_information_n2 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_get_input_information (handle, NULL, NULL);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_output_information_p1
+ * @since_tizen                9.0
+ * @description                Positive test case to get output information.
+ */
+int utc_ml_service_get_output_information_p1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  ml_tensors_info_h info;
+  guint count = 0;
+  ml_tensor_type_e type;
+  ml_tensor_dimension out_dim = { 0 };
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_get_output_information (handle, NULL, &info);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_info_get_count (info, &count);
+  assert_eq (ML_ERROR_NONE, status);
+  assert_eq (1U, count);
+
+  type = ML_TENSOR_TYPE_UNKNOWN;
+  status = ml_tensors_info_get_tensor_type (info, 0, &type);
+  assert_eq (ML_ERROR_NONE, status);
+  assert_eq (ML_TENSOR_TYPE_UINT8, type);
+
+  status = ml_tensors_info_get_tensor_dimension (info, 0, out_dim);
+  assert_eq (ML_ERROR_NONE, status);
+  assert_eq (1001U, out_dim[0]);
+  assert_eq (1U, out_dim[1]);
+
+  status = ml_tensors_info_destroy (info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_output_information_n1
+ * @since_tizen                9.0
+ * @description                Negative test case to get output information with invalid param.
+ */
+int utc_ml_service_get_output_information_n1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_tensors_info_h info;
+
+  /* Test */
+  status = ml_service_get_output_information (NULL, NULL, &info);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_output_information_n2
+ * @since_tizen                9.0
+ * @description                Negative test case to get output information with invalid param.
+ */
+int utc_ml_service_get_output_information_n2 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_get_output_information (handle, NULL, NULL);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_set_information_p1
+ * @since_tizen                9.0
+ * @description                Positive test case to set information.
+ */
+int utc_ml_service_set_information_p1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_set_information (handle, "test-threshold", "0.1");
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_set_information_n1
+ * @since_tizen                9.0
+ * @description                Negative test case to set information with invalid param.
+ */
+int utc_ml_service_set_information_n1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+
+  /* Test */
+  status = ml_service_set_information (NULL, "test-threshold", "0.1");
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_set_information_n2
+ * @since_tizen                9.0
+ * @description                Negative test case to set information with invalid param.
+ */
+int utc_ml_service_set_information_n2 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_set_information (handle, NULL, "0.1");
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_set_information_n3
+ * @since_tizen                9.0
+ * @description                Negative test case to set information with invalid param.
+ */
+int utc_ml_service_set_information_n3 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_set_information (handle, "test-threshold", NULL);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_information_p1
+ * @since_tizen                9.0
+ * @description                Positive test case to get information.
+ */
+int utc_ml_service_get_information_p1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  gchar *value;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_set_information (handle, "test-threshold", "0.1");
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_get_information (handle, "test-threshold", &value);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (0 == strcmp ("0.1", value));
+  g_free (value);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_information_n1
+ * @since_tizen                9.0
+ * @description                Negative test case to get information with invalid param.
+ */
+int utc_ml_service_get_information_n1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  gchar *value;
+
+  /* Test */
+  status = ml_service_get_information (NULL, "test-threshold", &value);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_information_n2
+ * @since_tizen                9.0
+ * @description                Negative test case to get information with invalid param.
+ */
+int utc_ml_service_get_information_n2 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  gchar *value;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_get_information (handle, NULL, &value);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_get_information_n3
+ * @since_tizen                9.0
+ * @description                Negative test case to get information with invalid param.
+ */
+int utc_ml_service_get_information_n3 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_get_information (handle, "test-threshold", NULL);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_request_p1
+ * @since_tizen                9.0
+ * @description                Positive test case to request machine learning service.
+ */
+int utc_ml_service_request_p1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  ml_tensors_info_h info;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+  ml_tensors_data_h input = NULL;
+  guint received = 0, tried = 0;
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  status = ml_service_set_event_cb (handle, _ml_service_test_imgclf_cb, &received);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_get_input_information (handle, NULL, &info);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_data_create (info, &input);
+  assert_eq (ML_ERROR_NONE, status);
+
+  /* Test */
+  status = ml_service_request (handle, NULL, input);
+  assert_eq (ML_ERROR_NONE, status);
+
+  do {
+    g_usleep (30000U);
+  } while (received < 1 && tried++ < 10);
+  assert (received > 0);
+
+  status = ml_tensors_info_destroy (info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_destroy (input);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_request_n1
+ * @since_tizen                9.0
+ * @description                Negative test case to request machine learning service with invalid param.
+ */
+int utc_ml_service_request_n1 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  ml_tensors_info_h info;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+  ml_tensors_data_h input = NULL;
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  status = ml_service_get_input_information (handle, NULL, &info);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_data_create (info, &input);
+  assert_eq (ML_ERROR_NONE, status);
+
+  /* Test */
+  status = ml_service_request (NULL, NULL, input);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_tensors_info_destroy (info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_destroy (input);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_service_request_n2
+ * @since_tizen                9.0
+ * @description                Negative test case to request machine learning service with invalid param.
+ */
+int utc_ml_service_request_n2 (void)
+{
+  IS_SUPPORT_ML_SERVICE_FEATURE;
+  ml_service_h handle = NULL;
+  guint version;
+  const gchar *test_name = "test-single-imgclf";
+
+  /* Clear registered model and don't care the result */
+  status = ml_service_model_delete (test_name, 0U);
+  assert (status == ML_ERROR_NONE || status == ML_ERROR_INVALID_PARAMETER);
+
+  status = ml_service_model_register (test_name, test_model, true, NULL, &version);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_new (config_path, &handle);
+  assert_eq (ML_ERROR_NONE, status);
+  assert (NULL != handle);
+
+  /* Test */
+  status = ml_service_request (handle, NULL, NULL);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_service_destroy (handle);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_service_model_delete (test_name, 0U);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
index 38bf57ffda05585f78a926bede46559f037106c0..d3e96a0ffc916a22ed70166ee3128ff05f4afdba 100644 (file)
@@ -216,3 +216,195 @@ int utc_ml_tensors_data_get_tensor_data_n (void)
 
   return 0;
 }
+
+/**
+ * @testcase           utc_ml_tensors_data_clone_p
+ * @since_tizen                9.0
+ * @description                Test utility functions - clone data.
+ */
+int utc_ml_tensors_data_clone_p (void)
+{
+  IS_SUPPORT_FEATURE;
+  int status;
+  ml_tensors_info_h info;
+  ml_tensors_data_h data;
+  ml_tensors_data_h data_out;
+  ml_tensor_dimension dim = { 5, 1, 1, 1 };
+  const int raw_data[5] = { 10, 20, 30, 40, 50 };
+  int *result = NULL;
+  size_t data_size, result_size;
+
+  status = ml_tensors_info_create (&info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_count (info, 1);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_tensor_type (info, 0, ML_TENSOR_TYPE_INT32);
+  assert_eq (ML_ERROR_NONE, status);
+  status= ml_tensors_info_set_tensor_dimension (info, 0, dim);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_get_tensor_size (info, 0, &data_size);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_create (info, &data);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_data_set_tensor_data (data, 0, (const void *) raw_data, data_size);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_data_clone (data, &data_out);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_data_get_tensor_data (data_out, 0, (void **) &result, &result_size);
+  assert_eq (ML_ERROR_NONE, status);
+  for (unsigned int i = 0; i < 5; i++)
+    assert_eq (result[i], raw_data[i]);
+
+  status = ml_tensors_info_destroy (info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_destroy (data);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_destroy (data_out);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_tensors_data_clone_n1
+ * @since_tizen                9.0
+ * @description                Test utility functions - clone data, Failure case
+ */
+int utc_ml_tensors_data_clone_n1 (void)
+{
+  IS_SUPPORT_FEATURE;
+  int status;
+  ml_tensors_info_h info;
+  ml_tensors_data_h data;
+  ml_tensor_dimension dim = { 5, 1, 1, 1 };
+
+  status = ml_tensors_info_create (&info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_count (info, 1);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_tensor_type (info, 0, ML_TENSOR_TYPE_INT32);
+  assert_eq (ML_ERROR_NONE, status);
+  status= ml_tensors_info_set_tensor_dimension (info, 0, dim);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_create (info, &data);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_data_clone (data, NULL);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_tensors_info_destroy (info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_destroy (data);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_tensors_data_clone_n2
+ * @since_tizen                9.0
+ * @description                Test utility functions - clone data, Failure case
+ */
+int utc_ml_tensors_data_clone_n2 (void)
+{
+  IS_SUPPORT_FEATURE;
+  int status;
+  ml_tensors_data_h data_out = NULL;
+
+  status = ml_tensors_data_clone (NULL, data_out);
+  assert_eq (status, ML_ERROR_INVALID_PARAMETER);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_tensors_data_get_info_p
+ * @since_tizen                9.0
+ * @description                Test utility functions - get data info
+ */
+int utc_ml_tensors_data_get_info_p (void)
+{
+  IS_SUPPORT_FEATURE;
+  int status;
+  ml_tensors_info_h in_info, out_info;
+  ml_tensors_data_h data;
+  ml_tensor_dimension dim = { 5, 1, 1, 1 };
+
+  status = ml_tensors_info_create (&in_info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_count (in_info, 1);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_tensor_type (in_info, 0, ML_TENSOR_TYPE_INT32);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_tensor_dimension (in_info, 0, dim);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_create (in_info, &data);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_data_get_info (data, &out_info);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_info_destroy (in_info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_destroy (out_info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_destroy (data);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_tensors_data_get_info_n1
+ * @since_tizen                9.0
+ * @description                Test utility functions - get data info, Failure case
+ */
+int utc_ml_tensors_data_get_info_n1 (void)
+{
+  IS_SUPPORT_FEATURE;
+  int status;
+  ml_tensors_info_h in_info;
+  ml_tensors_data_h data;
+  ml_tensor_dimension dim = { 5, 1, 1, 1 };
+
+  status = ml_tensors_info_create (&in_info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_count (in_info, 1);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_tensor_type (in_info, 0, ML_TENSOR_TYPE_INT32);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_info_set_tensor_dimension (in_info, 0, dim);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_create (in_info, &data);
+  assert_eq (ML_ERROR_NONE, status);
+
+  status = ml_tensors_data_get_info (data, NULL);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  status = ml_tensors_info_destroy (in_info);
+  assert_eq (ML_ERROR_NONE, status);
+  status = ml_tensors_data_destroy (data);
+  assert_eq (ML_ERROR_NONE, status);
+
+  return 0;
+}
+
+/**
+ * @testcase           utc_ml_tensors_data_get_info_n2
+ * @since_tizen                9.0
+ * @description                Test utility functions - get data info, Failure case
+ */
+int utc_ml_tensors_data_get_info_n2 (void)
+{
+  IS_SUPPORT_FEATURE;
+  int status;
+  ml_tensors_info_h out_info;
+
+  status = ml_tensors_data_get_info (NULL, &out_info);
+  assert_eq (ML_ERROR_INVALID_PARAMETER, status);
+
+  return 0;
+}