From 2a05b233bff424a899ea7a41d6e1b3503a87ba5f Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Mon, 12 Dec 2016 20:21:39 +0900 Subject: [PATCH] [UTC][openal][ACR-827/ACR-857][Add UTC module for tizen openAL API] Change-Id: I058ee64aaca0a66642f3cc61944d3b9704a0f7e4 --- packaging/utc/core-openal-tests.spec | 73 +++++++++++++++ packaging/utc/core-openal-tests.xml | 14 +++ src/utc/openal/CMakeLists.txt | 38 ++++++++ src/utc/openal/public.list | 1 + src/utc/openal/tct-openal-core.c | 140 ++++++++++++++++++++++++++++ src/utc/openal/tct-openal-core_common_iot.h | 31 ++++++ src/utc/openal/tct-openal-core_mobile.h | 31 ++++++ src/utc/openal/tct-openal-core_tv.h | 31 ++++++ src/utc/openal/tct-openal-core_wearable.h | 31 ++++++ src/utc/openal/utc-openal.c | 76 +++++++++++++++ 10 files changed, 466 insertions(+) create mode 100755 packaging/utc/core-openal-tests.spec create mode 100755 packaging/utc/core-openal-tests.xml create mode 100755 src/utc/openal/CMakeLists.txt create mode 100755 src/utc/openal/public.list create mode 100755 src/utc/openal/tct-openal-core.c create mode 100755 src/utc/openal/tct-openal-core_common_iot.h create mode 100755 src/utc/openal/tct-openal-core_mobile.h create mode 100755 src/utc/openal/tct-openal-core_tv.h create mode 100755 src/utc/openal/tct-openal-core_wearable.h create mode 100755 src/utc/openal/utc-openal.c diff --git a/packaging/utc/core-openal-tests.spec b/packaging/utc/core-openal-tests.spec new file mode 100755 index 0000000..0b117ba --- /dev/null +++ b/packaging/utc/core-openal-tests.spec @@ -0,0 +1,73 @@ +%define MODULE_NAME openal +%define MODULE_LIBNAME openal +Name: core-%{MODULE_NAME}-tests +Summary: Core API unit TC (%{name}) +Version: 0.1 +Release: 0 +Group: Development/Tools +License: Apache License, Version 2.0, Samsung Properietary +Source0: %{name}-%{version}.tar.gz +BuildRequires: pkgconfig(%{MODULE_LIBNAME}) +BuildRequires: cmake +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-system-info) +%description +Core API unit TC (%{name}) + +%prep +%setup -q + +%build + +%define PREFIX "%{_libdir}/%{name}" + +export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed" + +%if %{?ASAN_BUILD:1}0 + %if %{?DEVICE_BUILD_TYPE_MOBILE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="mobile" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_WEARABLE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="wearable" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_TV:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="tv" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_COMMON_IOT:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="common_iot" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif +%else + %if %{?DEVICE_BUILD_TYPE_MOBILE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="mobile" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_WEARABLE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="wearable" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_TV:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="tv" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_COMMON_IOT:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="common_iot" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif +%endif + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} +mkdir -p %{buildroot}/usr/share/packages/ +cp packaging/utc/%{name}.xml %{buildroot}/usr/share/packages/ +mkdir -p %{buildroot}/usr/apps/%{name}/bin +#cp templates/external_wrapper.sh %{buildroot}/usr/apps/%{name}/bin +%post + +%postun + + +%files +/usr/apps/%{name}/* +/usr/share/packages/%{name}.xml +/usr/share/license/%{name} diff --git a/packaging/utc/core-openal-tests.xml b/packaging/utc/core-openal-tests.xml new file mode 100755 index 0000000..2412661 --- /dev/null +++ b/packaging/utc/core-openal-tests.xml @@ -0,0 +1,14 @@ + + + + test + Core API test Application + + + + + + + + + diff --git a/src/utc/openal/CMakeLists.txt b/src/utc/openal/CMakeLists.txt new file mode 100755 index 0000000..de19c4f --- /dev/null +++ b/src/utc/openal/CMakeLists.txt @@ -0,0 +1,38 @@ +SET(PKG_NAME "openal") + +SET(EXEC_NAME "tct-${PKG_NAME}-core") +SET(RPM_NAME "core-${PKG_NAME}-tests") + +SET(CAPI_LIB "openal") +SET(TC_SOURCES + utc-openal.c +) + +PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED + ${CAPI_LIB} + capi-appfw-application + capi-media-sound-manager + capi-system-info + dlog elementary +) + +INCLUDE_DIRECTORIES( + ${${CAPI_LIB}_INCLUDE_DIRS} +) + +ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.c ${TC_SOURCES} ${COMMON_FILE}) +TARGET_LINK_LIBRARIES(${EXEC_NAME} + ${${CAPI_LIB}_LIBRARIES} +) + +INSTALL(PROGRAMS ${EXEC_NAME} + DESTINATION ${BIN_DIR}/${RPM_NAME}/bin +) + +IF( DEFINED ASAN ) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -pie -g -fsanitize=address -fsanitize-recover=address -U_FORTIFY_SOURCE -fno-omit-frame-pointer") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -Wl,-fsanitize=address") +ELSE() +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIE -Wall") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -pie") +ENDIF() diff --git a/src/utc/openal/public.list b/src/utc/openal/public.list new file mode 100755 index 0000000..ca73244 --- /dev/null +++ b/src/utc/openal/public.list @@ -0,0 +1 @@ +alcOpenDeviceNew diff --git a/src/utc/openal/tct-openal-core.c b/src/utc/openal/tct-openal-core.c new file mode 100755 index 0000000..8b52d8c --- /dev/null +++ b/src/utc/openal/tct-openal-core.c @@ -0,0 +1,140 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include +#include +#include "tct_common.h" + +#ifdef MOBILE +#include "tct-openal-core_mobile.h" +#endif + +#ifdef WEARABLE +#include "tct-openal-core_wearable.h" +#endif + +#ifdef TV +#include "tct-openal-core_tv.h" +#endif + +#ifdef COMMON_IOT +#include "tct-openal-core_common_iot.h" +#endif //COMMON_IOT + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +typedef struct appdata { + Evas_Object *win; + Evas_Object *conform; + Evas_Object *label; +} appdata_s; + +static bool app_create(void *data) +{ + return true; +} + +static void app_control(app_control_h app_control, void *data) +{ + char* pszGetTCName = NULL; + int i=0, result=0, nRet=0; + nRet = app_control_get_extra_data(app_control, "testcase_name", &pszGetTCName); + if(nRet != APP_CONTROL_ERROR_NONE) + { + dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] app_control_get_extra_data returns error = %d", __FUNCTION__, __LINE__, nRet); + PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to fetch test case name: app_control_get_extra_data API call fails\\n", __FILE__, __LINE__); + PRINT_TC_RESULT("%d",1); + FREE_MEMORY_TC(pszGetTCName); + return; + } + + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName); + for ( i = 0; tc_array[i].name; i++ ) + { + if ( 0 == strncmp(pszGetTCName, tc_array[i].name, strlen(pszGetTCName)) ) + { + DUMP_UTC_ERRLOG(); + if ( tc_array[i].startup ) + { + dlog_print(DLOG_INFO, "NativeTCT", "%s : Start up", pszGetTCName); + tc_array[i].startup(); + } + + dlog_print(DLOG_INFO, "NativeTCT", "%s : Body", pszGetTCName); + result = tc_array[i].function(); + dlog_print(DLOG_INFO, "NativeTCT", "%s returns value = %d", pszGetTCName, result); + + if ( tc_array[i].cleanup ) + { + dlog_print(DLOG_INFO, "NativeTCT", "%s : Clean up", pszGetTCName); + tc_array[i].cleanup(); + } + + CLOSE_UTC_ERRLOG(); + PRINT_TC_RESULT("%d",result); + FREE_MEMORY_TC(pszGetTCName); + return; + } + } + + dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] Unable to execute %s : Unknown Test Case Name", __FUNCTION__, __LINE__, pszGetTCName); + PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to execute %s : Unknown Test Case Name\\n", __FILE__, __LINE__, pszGetTCName); + PRINT_TC_RESULT("%d",1); + FREE_MEMORY_TC(pszGetTCName); + return; +} + +static void app_terminate(void *data) +{ + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is now Terminating", __FUNCTION__, __LINE__); +} + +int main(int argc, char *argv[]) +{ + int ret = 0; + appdata_s ad = {0,}; + + ui_app_lifecycle_callback_s event_callback = {0,}; + event_callback.create = app_create; + event_callback.terminate = app_terminate; + event_callback.app_control = app_control; + + //setting gcda file location for coverage + setenv("GCOV_PREFIX","/tmp",1); + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Coverage *.gcda File location set to /tmp/home/abuild/rpmbuild/BUILD/ ", __FUNCTION__, __LINE__); + + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Main Function is Invoked", __FUNCTION__, __LINE__); + ret = ui_app_main(argc, argv, &event_callback, &ad); + if (ret != APP_ERROR_NONE) + { + dlog_print(DLOG_ERROR, "NativeTCT", "Application ui_app_main call gets failed. err = %d", ret); + PRINT_UTC_LOG("\\n[%s][Line : %d]Application ui_app_main call gets failed. err = %d\\n", __FILE__, __LINE__, ret); + PRINT_TC_RESULT("%d",1); + return ret; + } + + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is Terminated", __FUNCTION__, __LINE__); + return ret; +} diff --git a/src/utc/openal/tct-openal-core_common_iot.h b/src/utc/openal/tct-openal-core_common_iot.h new file mode 100755 index 0000000..65015f5 --- /dev/null +++ b/src/utc/openal/tct-openal-core_common_iot.h @@ -0,0 +1,31 @@ +// +// Copyright (c) 2016 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef __TCT_OPENAL_CORE_H__ +#define __TCT_OPENAL_CORE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern int utc_alcOpenDeviceNew_p(void); +extern int utc_alcOpenDeviceNew_n(void); + +testcase tc_array[] = { + {"utc_alcOpenDeviceNew_p", utc_alcOpenDeviceNew_p, NULL, NULL}, + {"utc_alcOpenDeviceNew_n", utc_alcOpenDeviceNew_n, NULL, NULL}, + {NULL, NULL} +}; + +#endif // __TCT_OPENAL_CORE_H__ diff --git a/src/utc/openal/tct-openal-core_mobile.h b/src/utc/openal/tct-openal-core_mobile.h new file mode 100755 index 0000000..65015f5 --- /dev/null +++ b/src/utc/openal/tct-openal-core_mobile.h @@ -0,0 +1,31 @@ +// +// Copyright (c) 2016 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef __TCT_OPENAL_CORE_H__ +#define __TCT_OPENAL_CORE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern int utc_alcOpenDeviceNew_p(void); +extern int utc_alcOpenDeviceNew_n(void); + +testcase tc_array[] = { + {"utc_alcOpenDeviceNew_p", utc_alcOpenDeviceNew_p, NULL, NULL}, + {"utc_alcOpenDeviceNew_n", utc_alcOpenDeviceNew_n, NULL, NULL}, + {NULL, NULL} +}; + +#endif // __TCT_OPENAL_CORE_H__ diff --git a/src/utc/openal/tct-openal-core_tv.h b/src/utc/openal/tct-openal-core_tv.h new file mode 100755 index 0000000..65015f5 --- /dev/null +++ b/src/utc/openal/tct-openal-core_tv.h @@ -0,0 +1,31 @@ +// +// Copyright (c) 2016 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef __TCT_OPENAL_CORE_H__ +#define __TCT_OPENAL_CORE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern int utc_alcOpenDeviceNew_p(void); +extern int utc_alcOpenDeviceNew_n(void); + +testcase tc_array[] = { + {"utc_alcOpenDeviceNew_p", utc_alcOpenDeviceNew_p, NULL, NULL}, + {"utc_alcOpenDeviceNew_n", utc_alcOpenDeviceNew_n, NULL, NULL}, + {NULL, NULL} +}; + +#endif // __TCT_OPENAL_CORE_H__ diff --git a/src/utc/openal/tct-openal-core_wearable.h b/src/utc/openal/tct-openal-core_wearable.h new file mode 100755 index 0000000..65015f5 --- /dev/null +++ b/src/utc/openal/tct-openal-core_wearable.h @@ -0,0 +1,31 @@ +// +// Copyright (c) 2016 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef __TCT_OPENAL_CORE_H__ +#define __TCT_OPENAL_CORE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern int utc_alcOpenDeviceNew_p(void); +extern int utc_alcOpenDeviceNew_n(void); + +testcase tc_array[] = { + {"utc_alcOpenDeviceNew_p", utc_alcOpenDeviceNew_p, NULL, NULL}, + {"utc_alcOpenDeviceNew_n", utc_alcOpenDeviceNew_n, NULL, NULL}, + {NULL, NULL} +}; + +#endif // __TCT_OPENAL_CORE_H__ diff --git a/src/utc/openal/utc-openal.c b/src/utc/openal/utc-openal.c new file mode 100755 index 0000000..73e4805 --- /dev/null +++ b/src/utc/openal/utc-openal.c @@ -0,0 +1,76 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include +#include +#include + +#include +#include "assert.h" +#include "tct_common.h" + +/** + * @testcase utc_alcOpenDeviceNew_p + * @since_tizen 3.0 + * @description Positive test case to alcOpenDeviceNew + * @scenario open openal device with proper parameters + */ +int utc_alcOpenDeviceNew_p(void) +{ + int ret; + ALCdevice *device = NULL; + ALCboolean alret = ALC_FALSE; + sound_stream_info_h stream_info; + + /* prepare sound stream information handle */ + ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &stream_info); + assert_eq(ret, SOUND_MANAGER_ERROR_NONE); + + /* check for opening device with given sound stream info handle */ + device = alcOpenDeviceNew(NULL, stream_info); + assert_neq(device, NULL); + + /* close opened device */ + alret = alcCloseDevice(device); + assert_eq(alret, ALC_TRUE); + + /* cleanup sound stream information handle */ + ret = sound_manager_destroy_stream_information(stream_info); + assert_eq(ret, SOUND_MANAGER_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_alcOpenDeviceNew_n + * @since_tizen 3.0 + * @description Negative test case to alcOpenDeviceNew, passing invalid parameter + * @scenario open openal device with invalid paremters(null stream info) + */ +int utc_alcOpenDeviceNew_n(void) +{ + ALCdevice *device; + ALenum err; + + /* try open with NULL stream info handle, return should be NULL */ + device = alcOpenDeviceNew(NULL, NULL); + assert_eq(device, NULL); + + /* error value must be invalid value */ + err = alGetError(); + assert_eq(err, ALC_INVALID_VALUE); + + return 0; +} -- 2.7.4