diff options
Diffstat (limited to 'TC')
-rwxr-xr-x | TC/_export_env.sh | 8 | ||||
-rwxr-xr-x | TC/_export_target_env.sh | 7 | ||||
-rwxr-xr-x | TC/build.sh | 16 | ||||
-rwxr-xr-x | TC/clean.sh | 11 | ||||
-rwxr-xr-x | TC/config.default | 3 | ||||
-rwxr-xr-x | TC/execute.sh | 15 | ||||
-rwxr-xr-x | TC/testcase/Makefile | 25 | ||||
-rwxr-xr-x | TC/testcase/sample.jpg | bin | 0 -> 38184 bytes | |||
-rwxr-xr-x | TC/testcase/tslist | 3 | ||||
-rwxr-xr-x | TC/testcase/utc_image_util_jpeg.c | 469 | ||||
-rwxr-xr-x | TC/testcase/utc_media_image_util_basic.c | 543 | ||||
-rwxr-xr-x | TC/tet_scen | 7 | ||||
-rwxr-xr-x | TC/tetbuild.cfg | 5 | ||||
-rwxr-xr-x | TC/tetclean.cfg | 5 | ||||
-rwxr-xr-x | TC/tetexec.cfg | 5 |
15 files changed, 1122 insertions, 0 deletions
diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..72a11ec --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh new file mode 100755 index 0000000..5ddaa53 --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,7 @@ +#!/bin/sh +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..72aad6c --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/clean.sh b/TC/clean.sh new file mode 100755 index 0000000..29743e0 --- /dev/null +++ b/TC/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +RESULT_DIR=results + +tcc -c -p ./ # executing tcc, with clean option (-c) +rm -r $RESULT_DIR +rm -r tet_tmp_dir +rm testcase/tet_captured diff --git a/TC/config.default b/TC/config.default new file mode 100755 index 0000000..12ac1e2 --- /dev/null +++ b/TC/config.default @@ -0,0 +1,3 @@ +CAPI_PROJECT_ROOT=/home/abyss/capi +TET_INSTALL_HOST_PATH=/home/abyss/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/TETware diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..a4f6095 --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. ./_export_target_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile new file mode 100755 index 0000000..fbb2cbe --- /dev/null +++ b/TC/testcase/Makefile @@ -0,0 +1,25 @@ +CC ?= gcc + +C_FILES = $(shell ls *.c) + +PKGS = capi-media-image-util dlog glib-2.0 + +LDFLAGS = `pkg-config --libs $(PKGS)` +LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s + +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -I$(TET_ROOT)/inc/tet3 +CFLAGS += -Wall + +#TARGETS = $(C_FILES:%.c=tc-%) +TCS := $(shell ls -1 *.c | cut -d. -f1) + +all: $(TCS) + +%: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TCS) diff --git a/TC/testcase/sample.jpg b/TC/testcase/sample.jpg Binary files differnew file mode 100755 index 0000000..7222371 --- /dev/null +++ b/TC/testcase/sample.jpg diff --git a/TC/testcase/tslist b/TC/testcase/tslist new file mode 100755 index 0000000..becb7ea --- /dev/null +++ b/TC/testcase/tslist @@ -0,0 +1,3 @@ +/testcase/utc_image_util_jpeg +/testcase/utc_media_image_util_basic + diff --git a/TC/testcase/utc_image_util_jpeg.c b/TC/testcase/utc_image_util_jpeg.c new file mode 100755 index 0000000..9b692c5 --- /dev/null +++ b/TC/testcase/utc_image_util_jpeg.c @@ -0,0 +1,469 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <stdio.h> +#include <tet_api.h> +#include <image_util.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +#define SAMPLE_JPEG "sample.jpg" +#define WRONG_PATH "" +#define OUTPUT_JPEG "test_output.jpg" + +image_util_colorspace_e SUPPORTED_COLORSPACE; +image_util_colorspace_e NOT_SUPPORTED_COLORSPACE; +image_util_colorspace_e FIRST_COLORSPACE; +image_util_colorspace_e LAST_COLORSPACE; + +/** + * @brief Global struct for raw image data + */ +struct{ + unsigned char *buffer; + int size; + int w; + int h; +}raw_image = {NULL, 0, 0, 0}; + + +/** + * @brief Global struct for jpeg image + */ +struct{ + unsigned char *buffer; + int size; +}jpeg_image = {NULL, 0}; + + +#define API_NAME_IMAGE_UTIL_DECODE_JPEG "image_util_decode_jpeg" +#define API_NAME_IMAGE_UTIL_ENCODE_JPEG "image_util_encode_jpeg" +#define API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY "image_util_decode_jpeg_from_memory" +#define API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY "image_util_encode_jpeg_to_memory" + +static void utc_image_util_decode_jpeg_n_1(void); +static void utc_image_util_decode_jpeg_n_2(void); +static void utc_image_util_decode_jpeg_n_3(void); +static void utc_image_util_decode_jpeg_n_4(void); +static void utc_image_util_decode_jpeg_n_5(void); +static void utc_image_util_decode_jpeg_p(void); +static void utc_image_util_decode_jpeg_from_memory_n_1(void); +static void utc_image_util_decode_jpeg_from_memory_n_2(void); +static void utc_image_util_decode_jpeg_from_memory_n_3(void); +static void utc_image_util_decode_jpeg_from_memory_n_4(void); +static void utc_image_util_decode_jpeg_from_memory_p(void); +static void utc_image_util_encode_jpeg_n_1(void); +static void utc_image_util_encode_jpeg_n_2(void); +static void utc_image_util_encode_jpeg_n_3(void); +static void utc_image_util_encode_jpeg_n_4(void); +static void utc_image_util_encode_jpeg_n_5(void); +static void utc_image_util_encode_jpeg_p(void); +static void utc_image_util_encode_jpeg_to_memory_n_1(void); +static void utc_image_util_encode_jpeg_to_memory_n_2(void); +static void utc_image_util_encode_jpeg_to_memory_n_3(void); +static void utc_image_util_encode_jpeg_to_memory_n_4(void); +static void utc_image_util_encode_jpeg_to_memory_p(void); + +enum +{ + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { +/** + * image_util_decode_jpeg + */ + { utc_image_util_decode_jpeg_n_1, 1 }, + { utc_image_util_decode_jpeg_n_2, 2 }, + { utc_image_util_decode_jpeg_n_3, 3 }, + { utc_image_util_decode_jpeg_n_4, 4 }, + { utc_image_util_decode_jpeg_n_5, 5 }, + { utc_image_util_decode_jpeg_p, 6}, + +/** + * image_util_encode_jpeg + */ + { utc_image_util_encode_jpeg_n_1, 7 }, + { utc_image_util_encode_jpeg_n_2, 8 }, + { utc_image_util_encode_jpeg_n_3, 9 }, + { utc_image_util_encode_jpeg_n_4, 10 }, + { utc_image_util_encode_jpeg_n_5, 11 }, + { utc_image_util_encode_jpeg_p, 12}, + +/** + * image_util_encode_jpeg_to_memory + */ + { utc_image_util_encode_jpeg_to_memory_n_1, 13 }, + { utc_image_util_encode_jpeg_to_memory_n_2, 14 }, + { utc_image_util_encode_jpeg_to_memory_n_3, 15 }, + { utc_image_util_encode_jpeg_to_memory_n_4, 16 }, + { utc_image_util_encode_jpeg_to_memory_p, 17 }, + +/** + * image_util_decode_jpeg_from_memory + */ + { utc_image_util_decode_jpeg_from_memory_n_1, 18 }, + { utc_image_util_decode_jpeg_from_memory_n_2, 19 }, + { utc_image_util_decode_jpeg_from_memory_n_3, 20 },// SIGSEGV from api + { utc_image_util_decode_jpeg_from_memory_n_4, 21 }, + { utc_image_util_decode_jpeg_from_memory_p, 22 }, // SIGSEGV from api + { NULL, 0 }, +}; + +/** + * @brief Callback to find first supported colorspace + */ +static bool find_first_supported_colorspace_cb( image_util_colorspace_e colorspace, void * user_data) +{ + *(int*)user_data = colorspace; + return false; +} + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + // set first not supportes colorspace + image_util_foreach_supported_jpeg_colorspace( find_first_supported_colorspace_cb , (void*)(&SUPPORTED_COLORSPACE) ); + + // set oher colorspaces + NOT_SUPPORTED_COLORSPACE = IMAGE_UTIL_COLORSPACE_YUV422; //TODO: FIND NOT SUPPORTED FORMAT + FIRST_COLORSPACE = IMAGE_UTIL_COLORSPACE_YV12; + LAST_COLORSPACE = IMAGE_UTIL_COLORSPACE_BGRX8888; + + // prepare buffers for raw and jpeg images + if(image_util_decode_jpeg(SAMPLE_JPEG, SUPPORTED_COLORSPACE, &raw_image.buffer, &raw_image.w, &raw_image.h, &raw_image.size) == IMAGE_UTIL_ERROR_NONE){ + tet_printf("\n raw_image initialization OK"); + if(image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, &jpeg_image.buffer, &jpeg_image.size) == IMAGE_UTIL_ERROR_NONE) + tet_printf("\n jpeg_image initialization OK"); + else + tet_printf("\n jpeg_image initialization FAILED"); + } + else + tet_printf("\n raw_image initialization FAILED"); +} + +static void cleanup(void) +{ + /* end of TC */ + free(raw_image.buffer); + free(jpeg_image.buffer); + tet_printf("\n TC end"); +} + +/** + * @brief Negative test case of image_util_decode_jpeg(). Invalid path or image_buffer parameters; + */ +static void utc_image_util_decode_jpeg_n_1(void) +{ + int r; + int w, h; + int size; + + r = image_util_decode_jpeg(NULL, SUPPORTED_COLORSPACE, NULL, &w, &h, &size); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_decode_jpeg(). Parameter colorspace over the range. + */ +static void utc_image_util_decode_jpeg_n_2(void) +{ + int r; + int w, h; + int size; + unsigned char *buffer = NULL; + + r = image_util_decode_jpeg(SAMPLE_JPEG, LAST_COLORSPACE + 1, &buffer, &w, &h, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_decode_jpeg(). Parameter colorspace below the range. + */ +static void utc_image_util_decode_jpeg_n_3(void) +{ + int r; + int w, h; + int size; + unsigned char *buffer = NULL; + + r = image_util_decode_jpeg(SAMPLE_JPEG, FIRST_COLORSPACE - 1, &buffer, &w, &h, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_decode_jpeg(). Not supported format. + */ +static void utc_image_util_decode_jpeg_n_4(void) +{ + int r; + int w, h; + int size; + unsigned char *buffer = NULL; + + r = image_util_decode_jpeg(SAMPLE_JPEG, NOT_SUPPORTED_COLORSPACE, &buffer, &w, &h, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT); +} + +/** + * @brief Negative test case of image_util_decode_jpeg(). Wrong image file path. (Incomplete documentation!) + */ +static void utc_image_util_decode_jpeg_n_5(void) +{ + int r; + int w, h; + int size; + unsigned char *buffer = NULL; + + r = image_util_decode_jpeg(WRONG_PATH, SUPPORTED_COLORSPACE, &buffer, &w, &h, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_NO_SUCH_FILE); +} + + +/** + * @brief Positive test case of image_util_decode_jpeg(). Al parameters OK, Success expected. + */ +static void utc_image_util_decode_jpeg_p(void) +{ + int r; + unsigned char *buffer = NULL; + int w, h; + int size; + + r = image_util_decode_jpeg(SAMPLE_JPEG, SUPPORTED_COLORSPACE, &buffer, &w, &h, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_NONE); +} + + +/** + * @brief Negative test case of image_util_decode_jpeg_from_memory(). Invalid jpeg_buffer or image_buffer parameters; + */ +static void utc_image_util_decode_jpeg_from_memory_n_1(void) +{ + int r; + int w, h; + int size; + + r = image_util_decode_jpeg_from_memory(NULL, jpeg_image.size, SUPPORTED_COLORSPACE, NULL, &w, &h, &size); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_decode_jpeg_from_memory(). Parameter colorspace below the range. + */ +static void utc_image_util_decode_jpeg_from_memory_n_2(void) +{ + int r; + unsigned char *buffer = NULL; + int w, h; + int size; + + r = image_util_decode_jpeg_from_memory(jpeg_image.buffer, jpeg_image.size, FIRST_COLORSPACE -1, &buffer, &w, &h, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_decode_jpeg_from_memory(). Parameter colorspace over the range. + */ +static void utc_image_util_decode_jpeg_from_memory_n_3(void) +{ + int r; + unsigned char *buffer = NULL; + int w, h; + int size; + + r = image_util_decode_jpeg_from_memory(jpeg_image.buffer, jpeg_image.size, LAST_COLORSPACE + 1, &buffer, &w, &h, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_decode_jpeg_from_memory(). Not supported format. + */ +static void utc_image_util_decode_jpeg_from_memory_n_4(void) +{ + int r; + unsigned char *buffer = NULL; + int w, h; + int size; + + r = image_util_decode_jpeg_from_memory(jpeg_image.buffer, jpeg_image.size, NOT_SUPPORTED_COLORSPACE, &buffer, &w, &h, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT); +} + + +/** + * @brief Positive test image_util_decode_jpeg_from_memory(). Al parameters OK, Success expected. + */ +static void utc_image_util_decode_jpeg_from_memory_p(void) +{ + int r; + unsigned char *buffer = NULL; + int w, h; + int size; + + r = image_util_decode_jpeg_from_memory(jpeg_image.buffer, jpeg_image.size, SUPPORTED_COLORSPACE, &buffer, &w, &h, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_NONE); +} +/** + * @brief Negative test case of image_util_encode_jpeg(). Invalid path or buffer parameters; + */ +static void utc_image_util_encode_jpeg_n_1(void) +{ + int r; + + r = image_util_encode_jpeg(NULL, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, NULL); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_encode_jpeg(). Parameter colorspace over the range. + */ +static void utc_image_util_encode_jpeg_n_2(void) +{ + int r; + + r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , LAST_COLORSPACE + 1, 100, OUTPUT_JPEG); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} +/** + * @brief Negative test case of image_util_encode_jpeg(). Parameter colorspace below the range. + */ +static void utc_image_util_encode_jpeg_n_3(void) +{ + int r; + + r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , FIRST_COLORSPACE -1, 100, OUTPUT_JPEG); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_encode_jpeg(). Not supported format. + */ +static void utc_image_util_encode_jpeg_n_4(void) +{ + int r; + + r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , NOT_SUPPORTED_COLORSPACE, 100, OUTPUT_JPEG); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT); +} + + +/** + * @brief Negative test case of image_util_encode_jpeg(). Wrong image file path. + */ +static void utc_image_util_encode_jpeg_n_5(void) +{ + int r; + + r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, WRONG_PATH); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_NO_SUCH_FILE); +} + + +/** + * @brief Positive test case of image_util_encode_jpeg(). Al parameters OK, Success expected. + */ +static void utc_image_util_encode_jpeg_p(void) +{ + int r; + + r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, OUTPUT_JPEG); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_NONE); +} + +/** + * @brief Negative test case of image_util_encode_jpeg_to_memory(). Invalid path or image_buffer or jpeg_buffer parameters; + */ +static void utc_image_util_encode_jpeg_to_memory_n_1(void) +{ + int r; + int size; + + r = image_util_encode_jpeg_to_memory(NULL, 5 , 5 , SUPPORTED_COLORSPACE, 100, NULL, &size); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_encode_jpeg_to_memory(). Parameter colorspace over the range. + */ +static void utc_image_util_encode_jpeg_to_memory_n_2(void) +{ + int r; + unsigned char *buffer = NULL; + int size; + + r = image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , FIRST_COLORSPACE - 1, 100, &buffer, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_encode_jpeg_to_memory(). Parameter colorspace below the range. + */ +static void utc_image_util_encode_jpeg_to_memory_n_3(void) +{ + int r; + unsigned char *buffer = NULL; + int size; + + r = image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , LAST_COLORSPACE + 1, 100, &buffer, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER); +} + +/** + * @brief Negative test case of image_util_encode_jpeg_to_memory(). Not supported format. + */ +static void utc_image_util_encode_jpeg_to_memory_n_4(void) +{ + int r; + unsigned char *buffer = NULL; + int size; + + r = image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , NOT_SUPPORTED_COLORSPACE, 100, &buffer, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT); +} + +/** + * @brief Positive test case of image_util_encode_jpeg_to_memory(). Al parameters OK, Success expected. + */ +static void utc_image_util_encode_jpeg_to_memory_p(void) +{ + int r; + unsigned char *buffer = NULL; + int size; + + r = image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, &buffer, &size); + free(buffer); + dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_NONE); +} diff --git a/TC/testcase/utc_media_image_util_basic.c b/TC/testcase/utc_media_image_util_basic.c new file mode 100755 index 0000000..cfaf7aa --- /dev/null +++ b/TC/testcase/utc_media_image_util_basic.c @@ -0,0 +1,543 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <stdio.h> +#include <tet_api.h> +#include <image_util.h> + + + +#define API_NAME_IMAGEUTIL_COLORSPACE "image_util_colorspace" +#define API_NAME_IMAGEUTIL_COLOR_CONVERT "image_util_color_convert" +#define API_NAME_IMAGEUTIL_BUFFER_SIZE "image_util_buffer_size" +#define API_NAME_IMAGEUTIL_TRANSFORM "image_util_color_transform" + +#define SAMPLE_FILENAME "./sample.jpg" + +#define LAST_COLORSPACE IMAGE_UTIL_COLORSPACE_BGRX8888 + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +//Retrieves all supported JPEG encoding/decoding colorspace by invoking a callback function once for each one. +static void utc_image_util_supported_jpeg_colorspace_p(void); // how many colorspaces are available +static void utc_image_util_supported_jpeg_colorspace_2_p(void); // does ,,foreach'' return pass? +static void utc_image_util_supported_jpeg_colorspace_3_p(void); // does ,,foreach'' return pass for all cases? + +//Convert the image's colorspace. +static void utc_image_util_convert_colorspace_p(void); +static void utc_image_util_convert_colorspace_1_n(void); +static void utc_image_util_convert_colorspace_2_n(void); + +//Calculates the size of image buffer for the specified resolution and colorspace. +static void utc_image_util_calculate_bufsize_result_p(void); +static void utc_image_util_calculate_bufsize_result_1_n(void); +static void utc_image_util_calculate_bufsize_result_2_n(void); +static void utc_image_util_calculate_bufsize_result_3_n(void); +static void utc_image_util_calculate_bufsize_result_4_p(void); +static void utc_image_util_calculate_bufsize_result_5_p(void); + + +//Transforms the image to with the specified destination width and height and angle in degrees. +static void utc_image_util_file_rotate_p(void); +static void utc_image_util_file_rotate_2_p(void); +static void utc_image_util_file_rotate_3_p(void); + + + + +static bool jpeg_colorspace_cb( image_util_colorspace_e colorspace, void * user_data); +static bool jpeg_colorspace_quit_cb( image_util_colorspace_e colorspace, void * user_data); +static bool jpeg_colorspace_size_cb( image_util_colorspace_e colorspace, void * user_data); + + +//available transforms +#define AT_COUTN 4 +const int avail_trans[AT_COUTN] = +{ + IMAGE_UTIL_COLORSPACE_YV12, + IMAGE_UTIL_COLORSPACE_I420, + IMAGE_UTIL_COLORSPACE_NV12, + IMAGE_UTIL_COLORSPACE_RGB888, +}; + + + +enum +{ + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + + + + +struct tet_testlist tet_testlist[] = { + { utc_image_util_supported_jpeg_colorspace_p, 1}, + { utc_image_util_supported_jpeg_colorspace_2_p, 2}, + { utc_image_util_supported_jpeg_colorspace_3_p, 3}, + { utc_image_util_calculate_bufsize_result_p, 4}, + { utc_image_util_calculate_bufsize_result_1_n, 5}, + { utc_image_util_calculate_bufsize_result_2_n, 6}, + { utc_image_util_calculate_bufsize_result_3_n, 7}, + { utc_image_util_calculate_bufsize_result_4_p, 8}, + { utc_image_util_calculate_bufsize_result_5_p, 9}, + { utc_image_util_convert_colorspace_p, 10}, + { utc_image_util_convert_colorspace_1_n, 11}, + { utc_image_util_convert_colorspace_2_n, 12}, + { utc_image_util_file_rotate_p, 13}, + { utc_image_util_file_rotate_2_p, 14}, + { utc_image_util_file_rotate_3_p, 15}, + { NULL, 0}, +}; + + +static void startup(void) +{ + // TC start +} + +static void cleanup(void) +{ + // TC end +} + + + +static bool jpeg_colorspace_cb( image_util_colorspace_e colorspace, void * user_data) +{ + return true; +} + + +static bool jpeg_colorspace_quit_cb( image_util_colorspace_e colorspace, void * user_data) +{ + int last = *((int*)user_data); + return (int)colorspace == last ? false : true; +} + + + +static bool jpeg_colorspace_size_cb( image_util_colorspace_e colorspace, void * user_data) +{ + int * result = (int*)user_data; + + const int W = 480, H = 320; // these values are taken from test file - sample.jpg + int width = 0, height = 0; + int size_decode = 0; + unsigned int size_calc = 0; + unsigned char * img_buf = 0; + + // load jpeg sample file + image_util_decode_jpeg( SAMPLE_FILENAME, colorspace, &img_buf, &width, &height, &size_decode ); + + // prepare buffers + image_util_calculate_buffer_size( W, H, colorspace, &size_calc ); + + free( img_buf ); + + *result = (size_decode == size_calc); + + // if false then callbacks stop + return *result; +} + + + + + +/** + * @brief how many colorspaces are available + */ +static void utc_image_util_supported_jpeg_colorspace_p(void) +{ + int pointer = 0; + int ret = image_util_foreach_supported_jpeg_colorspace( NULL , (void*)(&pointer) ); + dts_check_eq( API_NAME_IMAGEUTIL_COLORSPACE, ret, IMAGE_UTIL_ERROR_INVALID_PARAMETER ); +} + + + + + + + +/** + * @brief does ,,foreach'' return pass? + */ +static void utc_image_util_supported_jpeg_colorspace_2_p(void) +{ + int err = image_util_foreach_supported_jpeg_colorspace( jpeg_colorspace_cb , (void*)NULL ); + dts_check_eq( API_NAME_IMAGEUTIL_COLORSPACE, err, IMAGE_UTIL_ERROR_NONE ); +} + + + + + + + +/** + * @brief does ,,foreach'' return pass for all cases? + */ +static void utc_image_util_supported_jpeg_colorspace_3_p(void) +{ + int err; + char buf[100] = { '\0' }; + snprintf( buf, 100, "%s", API_NAME_IMAGEUTIL_COLORSPACE ); + + // parameter i decides when loop of callbacks should break + int i; + for( i = 0; i < LAST_COLORSPACE; ++i ) + { + err = image_util_foreach_supported_jpeg_colorspace( jpeg_colorspace_quit_cb , (void*)(&i) ); + if( err != 0 ) + { + sprintf( buf, " [error: colorspace_2_p on position %d]", i ); + break; + } + } + + dts_check_eq( buf, err, 0 ); +} + + + + + + +/** + * @brief check the buffer size calculation with correct parameters + */ +static void utc_image_util_calculate_bufsize_result_p(void) +{ + int width = 100, height = 20; + unsigned int size = 0; + + int err = image_util_calculate_buffer_size( width, height, IMAGE_UTIL_COLORSPACE_RGB888, &size ); + dts_check_eq( API_NAME_IMAGEUTIL_BUFFER_SIZE, err, 0 ); +} + + + + + +/** + * @brief check the buffer size calculation with uncorrect parameters + */ +static void utc_image_util_calculate_bufsize_result_1_n(void) +{ + int width = 100, height = 20; + unsigned int size = 0; + const int colorspace = IMAGE_UTIL_COLORSPACE_BGRX8888 + 1; // after last one + + int err = image_util_calculate_buffer_size( width, height, colorspace, &size ); + dts_check_ne( API_NAME_IMAGEUTIL_BUFFER_SIZE, err, 0 ); +} + + + + + + +/** + * @brief check the buffer size calculation with uncorrect parameters + */ +static void utc_image_util_calculate_bufsize_result_2_n(void) +{ + int width = -100, height = 20; // wrong parameter + unsigned int size = 0; + const int colorspace = IMAGE_UTIL_COLORSPACE_BGRX8888; + + int err = image_util_calculate_buffer_size( width, height, colorspace, &size ); + dts_check_ne( API_NAME_IMAGEUTIL_BUFFER_SIZE, err, 0 ); +} + + + + + + +/** + * @brief check the buffer size calculation with uncorrect parameters + */ +static void utc_image_util_calculate_bufsize_result_3_n(void) +{ + int width = 0, height = 0; // wrong parameter + unsigned int size = 0; + const int colorspace = IMAGE_UTIL_COLORSPACE_BGRX8888; + + int err = image_util_calculate_buffer_size( width, height, colorspace, &size ); + dts_check_ne( API_NAME_IMAGEUTIL_BUFFER_SIZE, err, 0 ); +} + + + + + +/** + * @brief do the buffer size calculation and check if + * this is the same like with decode_jpeg function + */ +static void utc_image_util_calculate_bufsize_result_4_p(void) +{ + const int W = 480, H = 320; // these values are taken from original file sample.jpg + int width = 0, height = 0; + int size_decode = 0; + unsigned int size_calc = 0; + unsigned char * img_buf = 0; + const image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888; + + // load jpeg sample file + image_util_decode_jpeg( SAMPLE_FILENAME, colorspace, &img_buf, &width, &height, &size_decode ); + + // prepare buffers + image_util_calculate_buffer_size( W, H, colorspace, &size_calc ); + + free( img_buf ); + + dts_check_eq( API_NAME_IMAGEUTIL_BUFFER_SIZE, (int)size_calc, size_decode ); +} + + + + +/** + * @brief do the buffer size calculation for all colorspaces + * this is similar like ..._calculate_bufsize_result_4_p + */ +static void utc_image_util_calculate_bufsize_result_5_p(void) +{ + int result = -1; + + // do the loop for all colorspaces and check bufsize there inside + image_util_foreach_supported_jpeg_colorspace( jpeg_colorspace_size_cb, (void*)(&result) ); + + // result is taken from inside the colorspace callbacks loop, + // there is compared buffor size + // result takes true or false + dts_check_eq( API_NAME_IMAGEUTIL_BUFFER_SIZE, result, 1 ); +} + + +/** + * @brief check if color conversion returns positive + */ +static void utc_image_util_convert_colorspace_p(void) +{ + int width = 0, height = 0; + unsigned int size_decode = 0; + unsigned char * img_target = 0; + unsigned char * img_source = 0; + const image_util_colorspace_e cs_target = IMAGE_UTIL_COLORSPACE_RGB888; + const image_util_colorspace_e cs_source = IMAGE_UTIL_COLORSPACE_YV12; + + // load jpeg sample file + image_util_decode_jpeg( SAMPLE_FILENAME, cs_source, &img_source, &width, &height, &size_decode ); + image_util_calculate_buffer_size(width, height, cs_target , &size_decode); + img_target = malloc( size_decode ); + + // do conversion + int ret = image_util_convert_colorspace( img_target, cs_target, + img_source, width, height, cs_source ); + free( img_target ); + free( img_source ); + + dts_check_eq( API_NAME_IMAGEUTIL_COLOR_CONVERT, ret, IMAGE_UTIL_ERROR_NONE ); +} + + + + + + +/** + * @brief check if color conversion function has the verification of input parameters + */ +static void utc_image_util_convert_colorspace_1_n(void) +{ + int width = 0, height = 0; + unsigned char * img_target = 0; // NULL pointer! + unsigned char * img_source = 0; // NULL pointer! + const image_util_colorspace_e cs_target = IMAGE_UTIL_COLORSPACE_RGB888; + const image_util_colorspace_e cs_source = IMAGE_UTIL_COLORSPACE_YV12; + + // do conversion + int ret = image_util_convert_colorspace( img_target, cs_target, + img_source, width, height, cs_source ); + + dts_check_ne( API_NAME_IMAGEUTIL_COLOR_CONVERT, ret, IMAGE_UTIL_ERROR_NONE ); +} + + + +/** + * @brief check if color conversion has verification of input parameters + */ +static void utc_image_util_convert_colorspace_2_n(void) +{ + int width = 0, height = 0; + int size_decode = 0; + unsigned char * img_target = 0; + unsigned char * img_source = 0; + const image_util_colorspace_e cs_target = IMAGE_UTIL_COLORSPACE_BGRX8888 + 1; // out of the scope! + const image_util_colorspace_e cs_source = IMAGE_UTIL_COLORSPACE_YV12; + + // load jpeg sample file + image_util_decode_jpeg( SAMPLE_FILENAME, cs_source, &img_source, &width, &height, &size_decode ); + + // do conversion + int ret = image_util_convert_colorspace( img_target, cs_target, + img_source, width, height, cs_source ); + free( img_target ); + free( img_source ); + + dts_check_ne( API_NAME_IMAGEUTIL_COLOR_CONVERT, ret, IMAGE_UTIL_ERROR_NONE ); +} + + + + +/** + * @brief Simple use of transformation + */ +static void utc_image_util_file_rotate_p(void) +{ + int width = 0, height = 0; + int size_decode = 0; + unsigned char * img_target = 0; + unsigned char * img_source = 0; + + image_util_rotation_e dest_rotation = IMAGE_UTIL_ROTATION_90; + + const image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888; + + // load jpeg sample file + image_util_decode_jpeg( SAMPLE_FILENAME, colorspace, &img_source, &width, &height, &size_decode ); + + image_util_calculate_buffer_size(width, height, colorspace , &size_decode); + + img_target = malloc( size_decode ); + + // do rotation + int ret = image_util_rotate( img_target, &width, &height, dest_rotation, + img_source, width, height, colorspace ); + + free( img_target ); + free( img_source ); + + dts_check_eq( API_NAME_IMAGEUTIL_TRANSFORM, ret, IMAGE_UTIL_ERROR_NONE ); +} + + + + + +/** + * @brief Image transformation for all rotation types + */ +static void utc_image_util_file_rotate_2_p(void) +{ + int ret = -1; + + int width = 0, height = 0; + int target_width , target_height = 0; + int size_decode = 0; + unsigned char * img_target = 0; + unsigned char * img_source = 0; + + const image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888; + + // load jpeg sample file + image_util_decode_jpeg( SAMPLE_FILENAME, colorspace, &img_source, &width, &height, &size_decode ); + image_util_calculate_buffer_size(width, height, colorspace , &size_decode); + + img_target = malloc( size_decode ); + + image_util_rotation_e rot; + for( rot = IMAGE_UTIL_ROTATION_NONE; + rot <= IMAGE_UTIL_ROTATION_FLIP_VERT; ++rot ) + { + // do rotation + ret = image_util_rotate( img_target, &target_width, &target_height, rot, + img_source, width, height, colorspace ); + + if( ret != 0 ) + break; + } + + free( img_target ); + free( img_source ); + + dts_check_eq( API_NAME_IMAGEUTIL_TRANSFORM, ret, IMAGE_UTIL_ERROR_NONE ); +} + + + + + +/** + * @brief Image transformation for all available colorspaces + */ +static void utc_image_util_file_rotate_3_p(void) +{ + int ret = -1; + + // loop uses all colorspaces for one transformation + int i; + for( i = 0; i < AT_COUTN; ++i ) + { + int width = 0, height = 0; + int size_decode = 0; + unsigned char * img_target = 0; + unsigned char * img_source_converted = 0; + unsigned char * img_source = 0; + + + // load jpeg sample file + image_util_decode_jpeg( SAMPLE_FILENAME, IMAGE_UTIL_COLORSPACE_RGB888 , &img_source, &width, &height, &size_decode ); + // convert target format + if( IMAGE_UTIL_COLORSPACE_RGB888 != avail_trans[i] ){ + image_util_calculate_buffer_size(width, height, avail_trans[i], &size_decode); + img_source_converted = malloc(size_decode); + image_util_convert_colorspace(img_source_converted , avail_trans[i] , img_source , width, height, IMAGE_UTIL_COLORSPACE_RGB888); + free(img_source); + img_source = img_source_converted; + } + + + + image_util_calculate_buffer_size(width, height, avail_trans[i] , &size_decode); + img_target = malloc( size_decode ); + + // do rotation + ret = image_util_rotate( img_target, &width, &height, IMAGE_UTIL_ROTATION_180, + img_source, width, height, avail_trans[i] ); + + free( img_target ); + free( img_source ); + + if( ret != 0 ) + break; + } + + + + dts_check_eq( API_NAME_IMAGEUTIL_TRANSFORM, ret, IMAGE_UTIL_ERROR_NONE ); +} diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100755 index 0000000..03f029a --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/testcase/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100755 index 0000000..f7eda55 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option for build operation checking +TET_BUILD_TOOL=make # build with using make command +TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build +TET_API_COMPLIANT=True # use TET API in Test Case ? +TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg new file mode 100755 index 0000000..02d7030 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option +TET_CLEAN_TOOL= make clean # clean tool +TET_CLEAN_FILE= Makefile # file for clean +TET_API_COMPLIANT=True # TET API useage +TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg new file mode 100755 index 0000000..ef3e452 --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capturing execution or not +TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional +TET_EXEC_FILE= # ex) exectool : execution file/ Optional +TET_API_COMPLIANT=True # Test case or Tool usesTET API? +TET_PASS_TC_NAME=True # showing Passed TC name ? |