Remove transform async related test code and bug fix 60/191060/2
authorhj kim <backto.kim@samsung.com>
Thu, 11 Oct 2018 06:04:12 +0000 (15:04 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 11 Oct 2018 06:05:16 +0000 (15:05 +0900)
Change-Id: If458a8f87490ce1f5a7f7a0a9c53e40b311f11e0

imgp/CMakeLists.txt
imgp/test/mm_util_imgp_testsuite.c

index 05578da424e8bb75574387bf6fab8447c9e716fe..1742287240480910e23a1351b18ee4c114b06d11 100755 (executable)
@@ -68,4 +68,4 @@ CONFIGURE_FILE(
 )
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PC_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
-#ADD_SUBDIRECTORY(test)
+ADD_SUBDIRECTORY(test)
index f19da856c86bd378a07915d5029669bc899e4428..43991f1724de1adc7daee4d1866048c13a613310 100755 (executable)
 
 #define TRANSFORM_TEST_PATH    tzplatform_mkpath(TZ_USER_CONTENT, "imgp_result")
 
-#define MAX_STRING_LEN 128
-#define IMAGE_FORMAT_LABEL_BUFFER_SIZE 4
 #define IMGP_FREE(src) { if (src != NULL) {g_free(src); src = NULL; } }
 
-mm_util_imgp_h imgp_handle = NULL;
-
-GCond g_thread_cond;
-GMutex g_thread_mutex;
-
 static gboolean _read_file(char *path, void **data, size_t *length)
 {
        FILE *fp = NULL;
@@ -125,65 +118,13 @@ static gboolean _write_file(const char *path, void *data, size_t length)
        return TRUE;
 }
 
-void _wait()
-{
-       g_mutex_lock(&g_thread_mutex);
-       fprintf(stderr, "waiting... until finishing \n");
-       g_cond_wait(&g_thread_cond, &g_thread_mutex);
-       fprintf(stderr, "<=== get signal from callback \n");
-       g_mutex_unlock(&g_thread_mutex);
-}
-
-void _signal()
-{
-       g_mutex_lock(&g_thread_mutex);
-       g_cond_signal(&g_thread_cond);
-       fprintf(stderr, "===> send signal to test proc \n");
-       g_mutex_unlock(&g_thread_mutex);
-}
-
-bool _transform_completed_cb(mm_util_color_image_h image, int error, void *user_data)
-{
-       int err = MM_UTIL_ERROR_NONE;
-       size_t size = 0;
-       char* output_file = (char *)user_data;
-       fprintf(stderr, "imgp_handle: %p\n", imgp_handle);
-
-       fprintf(stderr, "output_file: %s\n", output_file);
-
-       if (error == MM_UTIL_ERROR_NONE) {
-               fprintf(stderr, "completed\n");
-               void *dst = NULL;
-               err = mm_util_get_color_image(image, NULL, NULL, NULL, &dst, &size);
-               if (err != MM_UTIL_ERROR_NONE) {
-                       fprintf(stderr, "Error mm_util_get_color_image (%d)\n", err);
-                       goto out;
-               }
-
-               if (FALSE == _write_file(output_file, dst, size)) {
-                       fprintf(stderr, "\t[IMGP_testsuite] writing file(%s) error\n", output_file);
-                       goto out;
-               }
-               fprintf(stderr, "write success\n");
-       } else {
-               fprintf(stderr, "[Error] complete cb (%d)\n", error);
-       }
-
-out:
-       fprintf(stderr, "Destory - destroy image\n");
-
-       mm_util_destroy_color_image(image);
-       _signal();
-
-       return TRUE;
-}
-
-gboolean _get_input_data(const char *argv, const long min, const long max, unsigned int *data)
+gboolean _get_input_data(const char *argv, const unsigned long min, const unsigned long max, unsigned int *data)
 {
        if (argv == NULL || strlen(argv) == 0)
                return FALSE;
 
-       long temp = g_ascii_strtoll(argv, NULL, 10);
+       unsigned long temp = g_ascii_strtoll(argv, NULL, 10);
+
        if (temp < min || temp > max)
                return FALSE;
 
@@ -223,15 +164,12 @@ int main(int argc, char *argv[])
        unsigned int res_h = 0;
        size_t res_buffer_size = 0;
 
-       /* async mode */
-       mm_util_color_image_h orig_image = NULL;
-
        /* get arguments */
-       if (FALSE == _get_input_data(argv[4], 0, (long)UINT_MAX, &src_width)) {
+       if (FALSE == _get_input_data(argv[4], 0, UINT_MAX, &src_width)) {
                fprintf(stderr, "\t[IMGP_testsuite] wrong src_width %s\n", argv[4]);
                goto TEST_FAIL;
        }
-       if (FALSE == _get_input_data(argv[5], 0, (long)UINT_MAX, &src_height)) {
+       if (FALSE == _get_input_data(argv[5], 0, UINT_MAX, &src_height)) {
                fprintf(stderr, "\t[IMGP_testsuite] wrong src_height %s\n", argv[5]);
                goto TEST_FAIL;
        }
@@ -239,11 +177,11 @@ int main(int argc, char *argv[])
                fprintf(stderr, "\t[IMGP_testsuite] wrong src_format %s\n", argv[6]);
                goto TEST_FAIL;
        }
-       if (FALSE == _get_input_data(argv[7], 0, (long)UINT_MAX, &dst_width)) {
+       if (FALSE == _get_input_data(argv[7], 0, UINT_MAX, &dst_width)) {
                fprintf(stderr, "\t[IMGP_testsuite] wrong dst_width %s\n", argv[7]);
                goto TEST_FAIL;
        }
-       if (FALSE == _get_input_data(argv[8], 0, (long)UINT_MAX, &dst_height)) {
+       if (FALSE == _get_input_data(argv[8], 0, UINT_MAX, &dst_height)) {
                fprintf(stderr, "\t[IMGP_testsuite] wrong dst_height %s\n", argv[8]);
                goto TEST_FAIL;
        }
@@ -255,11 +193,11 @@ int main(int argc, char *argv[])
                fprintf(stderr, "\t[IMGP_testsuite] wrong rotation %s\n", argv[10]);
                goto TEST_FAIL;
        }
-       if (FALSE == _get_input_data(argv[11], 0, (long)UINT_MAX, &start_x)) {
+       if (FALSE == _get_input_data(argv[11], 0, UINT_MAX, &start_x)) {
                fprintf(stderr, "\t[IMGP_testsuite] wrong start_x %s\n", argv[11]);
                goto TEST_FAIL;
        }
-       if (FALSE == _get_input_data(argv[12], 0, (long)UINT_MAX, &start_y)) {
+       if (FALSE == _get_input_data(argv[12], 0, UINT_MAX, &start_y)) {
                fprintf(stderr, "\t[IMGP_testsuite] wrong start_y %s\n", argv[12]);
                goto TEST_FAIL;
        }
@@ -300,88 +238,6 @@ int main(int argc, char *argv[])
                }
        } else {  /* Async mode */
                fprintf(stderr, "ASYNC\n");
-
-               /* Create Transform */
-               ret = mm_util_create(&imgp_handle);
-               if (ret == MM_UTIL_ERROR_NONE) {
-                       fprintf(stderr, "Success - Create Transcode Handle [imgp_handle: %p]\n", imgp_handle);
-               } else {
-                       fprintf(stderr, "ERROR - Create Transcode Handle\n");
-                       goto TEST_FAIL;
-               }
-
-               ret = mm_util_create_color_image(&orig_image, src_width, src_height, src_format, src, src_size);
-               if (ret == MM_UTIL_ERROR_NONE) {
-                       fprintf(stderr, "Success - mm_util_create_color_image\n");
-               } else {
-                       fprintf(stderr, "ERROR - mm_util_create_color_image\n");
-                       goto TEST_FAIL;
-               }
-
-               if (strcmp(command, "convert") == 0) {
-                       ret = mm_util_set_colorspace_convert(imgp_handle, dst_format);
-                       if (ret == MM_UTIL_ERROR_NONE) {
-                               fprintf(stderr, "Success - Set colorspace Info\n");
-                       } else {
-                               fprintf(stderr, "ERROR - Set colorspace Info\n");
-                               goto TEST_FAIL;
-                       }
-               }
-
-               if (strcmp(command, "crop") == 0) {
-                       ret = mm_util_set_crop_area(imgp_handle, start_x, start_y, (start_x + dst_width), (start_y + dst_height));
-                       if (ret == MM_UTIL_ERROR_NONE) {
-                               fprintf(stderr, "Success - Set crop Info\n");
-                       } else {
-                               fprintf(stderr, "ERROR - Set crop Info\n");
-                               goto TEST_FAIL;
-                       }
-               }
-
-               if (strcmp(command, "resize") == 0) {
-                       ret = mm_util_set_resolution(imgp_handle, dst_width, dst_height);
-                       if (ret == MM_UTIL_ERROR_NONE) {
-                               fprintf(stderr, "Success - Set resolution Info\n");
-                       } else {
-                               fprintf(stderr, "ERROR - Set resolution Info\n");
-                               goto TEST_FAIL;
-                       }
-               }
-
-               if (strcmp(command, "rotate") == 0) {
-                       ret = mm_util_set_rotation(imgp_handle, rotation);
-                       if (ret == MM_UTIL_ERROR_NONE) {
-                               fprintf(stderr, "Success - Set rotation Info\n");
-                       } else {
-                               fprintf(stderr, "ERROR - Set rotation Info\n");
-                               goto TEST_FAIL;
-                       }
-               }
-
-               /* Transform */
-               ret = mm_util_transform(imgp_handle, orig_image, (mm_util_completed_callback) _transform_completed_cb, output_file);
-               if (ret == MM_UTIL_ERROR_NONE) {
-                       fprintf(stderr, "Success - Transform\n");
-               } else {
-                       fprintf(stderr, "ERROR - Transform\n");
-                       goto TEST_FAIL;
-               }
-
-               fprintf(stderr, "Wait...\n");
-               g_mutex_init(&g_thread_mutex);
-               g_cond_init(&g_thread_cond);
-               _wait();
-               g_mutex_clear(&g_thread_mutex);
-               g_cond_clear(&g_thread_cond);
-
-               ret = mm_util_destroy(imgp_handle);
-               if (ret == MM_UTIL_ERROR_NONE) {
-                       fprintf(stderr, "Success - Destroy\n");
-               } else {
-                       fprintf(stderr, "ERROR - Destroy\n");
-                       goto TEST_FAIL;
-               }
-
        }
 TEST_FAIL:
 
@@ -389,10 +245,6 @@ TEST_FAIL:
        IMGP_FREE(dst);
        IMGP_FREE(command);
        IMGP_FREE(filename);
-       if (!sync_mode) {
-               mm_util_destroy_color_image(orig_image);
-               fprintf(stderr, "destroy\n");
-       }
 
        return 0;
 }