-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unittest: add a test folder v1 #150
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6c093bb
unittest: add a test folder
audoan99 0a107fa
CMakeLists: add directory unittest to cmake
audoan99 8d4a59d
README: update for unit testing
audoan99 66b3115
Update unittest to adapt with weston 12
chienpv1 ca423b5
Create unit test for new APIs of screenshot feature
chienpv1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
############################################################################ | ||
# | ||
# Copyright (C) 2023 Advanced Driver Information Technology Joint Venture GmbH | ||
# | ||
# | ||
# 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. | ||
# | ||
############################################################################ | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) | ||
|
||
find_package(gtest REQUIRED) | ||
|
||
IF(NOT gtest_FOUND) | ||
MESSAGE(STATUS "gtest not found, disabling unit tests (BUILD_ILM_UNIT_TESTS=OFF)") | ||
SET(BUILD_ILM_UNIT_TESTS FALSE CACHE BOOL "Build unit tests for IVI LayerManagement API" FORCE) | ||
ENDIF() | ||
|
||
IF(BUILD_ILM_UNIT_TESTS) | ||
enable_testing() | ||
add_subdirectory(client) | ||
add_subdirectory(server) | ||
ENDIF() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
############################################################################ | ||
# | ||
# Copyright (C) 2023 Advanced Driver Information Technology Joint Venture GmbH | ||
# | ||
# | ||
# 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. | ||
# | ||
############################################################################ | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) | ||
cmake_policy(SET CMP0046 OLD) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warning messages when configuring of cmake. |
||
PROJECT(ilm_client_unittest) | ||
|
||
INCLUDE_DIRECTORIES( | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../ivi-layermanagement-api/ilmControl/src | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../ivi-layermanagement-api/ilmCommon/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../ivi-layermanagement-api/ilmControl/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../ivi-layermanagement-api/ilmInput/include | ||
${CMAKE_CURRENT_BINARY_DIR}/../../ivi-layermanagement-api/ilmControl | ||
${CMAKE_CURRENT_BINARY_DIR}/../../protocol | ||
${CMAKE_CURRENT_SOURCE_DIR}/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/../common | ||
${WAYLAND_CLIENT_INCLUDE_DIRS} | ||
${WESTON_INCLUDE_DIRS} | ||
${gtest_INCLUDE_DIRS} | ||
) | ||
|
||
LINK_DIRECTORIES( | ||
${WAYLAND_CLIENT_LIBRARY_DIRS} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no binaries link to libwayland-client.so, don't need to keep this link |
||
) | ||
|
||
SET(LIBS | ||
${gtest_LIBRARIES} | ||
) | ||
|
||
SET(SRC_COMMON_FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/client_api_fake.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/../common/common_fake_api.c | ||
) | ||
|
||
SET(SRC_IVI_COMMON_FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/ilm_common_unittests.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../ivi-layermanagement-api/ilmCommon/src/ilm_common.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../ivi-layermanagement-api/ilmCommon/src/ilm_common_wayland_platform.c | ||
) | ||
|
||
SET(SRC_IVI_CONTROL_FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/ilm_control_unittests.cpp | ||
) | ||
|
||
SET(SRC_IVI_INPUT_FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/ilm_input_uinttests.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../ivi-layermanagement-api/ilmInput/src/ilm_input.c | ||
) | ||
|
||
SET(GCC_SANITIZER_COMPILE_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector-all -fpermissive") | ||
IF(BUILD_CODE_COVERAGE) | ||
SET(COVERAGE_COMPILER_FLAGS "-g --coverage") | ||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}") | ||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_SANITIZER_COMPILE_FLAGS} -pthread ${COVERAGE_COMPILER_FLAGS}") | ||
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -static-libasan -static-libubsan ${COVERAGE_COMPILER_FLAGS}") | ||
ELSE() | ||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_SANITIZER_COMPILE_FLAGS} -pthread") | ||
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -static-libasan -static-libubsan") | ||
ENDIF() | ||
|
||
ADD_EXECUTABLE(unittest-ilm-common ${SRC_COMMON_FILES} ${SRC_IVI_COMMON_FILES}) | ||
TARGET_LINK_LIBRARIES(unittest-ilm-common ${LIBS}) | ||
ADD_DEPENDENCIES(unittest-ilm-common ${LIBS}) | ||
INSTALL(TARGETS unittest-ilm-common DESTINATION bin) | ||
|
||
ADD_EXECUTABLE(unittest-ilm-input ${SRC_COMMON_FILES} ${SRC_IVI_INPUT_FILES}) | ||
TARGET_LINK_LIBRARIES(unittest-ilm-input ${LIBS}) | ||
ADD_DEPENDENCIES(unittest-ilm-input ${LIBS}) | ||
INSTALL(TARGETS unittest-ilm-input DESTINATION bin) | ||
|
||
ADD_EXECUTABLE(unittest-ilm-control ${SRC_COMMON_FILES} ${SRC_IVI_CONTROL_FILES}) | ||
TARGET_LINK_LIBRARIES(unittest-ilm-control ${LIBS}) | ||
ADD_DEPENDENCIES(unittest-ilm-control ${LIBS}) | ||
INSTALL(TARGETS unittest-ilm-control DESTINATION bin) | ||
|
||
ADD_TEST(Unittest-ilm-common unittest-ilm-common) | ||
ADD_TEST(Unittest-ilm-input unittest-ilm-input) | ||
ADD_TEST(Unittest-ilm-control unittest-ilm-control) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/*************************************************************************** | ||
* | ||
* Copyright (C) 2023 Advanced Driver Information Technology Joint Venture GmbH | ||
* | ||
* | ||
* 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 CLIENT_API_FAKE | ||
#define CLIENT_API_FAKE | ||
|
||
#include "stdint.h" | ||
#include <pthread.h> | ||
#include "fff.h" | ||
#include "common_fake_api.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef void (**registerHandler) (void); | ||
typedef void *(*threadEntry) (void *); | ||
|
||
DECLARE_FAKE_VALUE_FUNC(struct wl_display *, wl_display_connect, const char *); | ||
DECLARE_FAKE_VALUE_FUNC(struct wl_event_queue *, wl_display_create_queue, struct wl_display *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_display_roundtrip, struct wl_display *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_proxy_add_listener, struct wl_proxy *, registerHandler, void *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_display_roundtrip_queue, struct wl_display *, struct wl_event_queue *); | ||
DECLARE_FAKE_VALUE_FUNC(int, pthread_create, pthread_t *, const pthread_attr_t *, threadEntry, void *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_display_flush, struct wl_display *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_display_dispatch_queue, struct wl_display *, struct wl_event_queue *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_display_dispatch_queue_pending, struct wl_display *, struct wl_event_queue *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_display_get_error, struct wl_display *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_display_get_fd, struct wl_display *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_display_prepare_read_queue, struct wl_display *, struct wl_event_queue *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_display_read_events, struct wl_display *); | ||
DECLARE_FAKE_VALUE_FUNC(uint32_t, wl_proxy_get_version, struct wl_proxy *); | ||
DECLARE_FAKE_VOID_FUNC(wl_display_disconnect, struct wl_display *); | ||
DECLARE_FAKE_VOID_FUNC(wl_event_queue_destroy, struct wl_event_queue *); | ||
DECLARE_FAKE_VOID_FUNC(wl_proxy_set_queue, struct wl_proxy *, struct wl_event_queue *); | ||
DECLARE_FAKE_VOID_FUNC(wl_proxy_destroy, struct wl_proxy *); | ||
DECLARE_FAKE_VOID_FUNC(wl_display_cancel_read, struct wl_display *); | ||
DECLARE_FAKE_VOID_FUNC(wl_list_insert, struct wl_list *, struct wl_list *); | ||
DECLARE_FAKE_VALUE_FUNC(void *, wl_array_add, struct wl_array *, size_t); | ||
DECLARE_FAKE_VALUE_FUNC_VARARG(struct wl_proxy *, wl_proxy_marshal_flags, struct wl_proxy *, uint32_t, const struct wl_interface *, uint32_t, uint32_t, ...); | ||
DECLARE_FAKE_VOID_FUNC(wl_array_init, struct wl_array *); | ||
DECLARE_FAKE_VOID_FUNC(wl_array_release, struct wl_array *); | ||
DECLARE_FAKE_VOID_FUNC(wl_list_init, struct wl_list *); | ||
DECLARE_FAKE_VOID_FUNC(wl_list_remove, struct wl_list *); | ||
DECLARE_FAKE_VALUE_FUNC(int, wl_list_length, const struct wl_list *); | ||
|
||
#define CLIENT_API_FAKE_LIST(FAKE) \ | ||
FAKE(wl_display_connect) \ | ||
FAKE(wl_display_create_queue) \ | ||
FAKE(wl_display_roundtrip) \ | ||
FAKE(wl_proxy_add_listener) \ | ||
FAKE(wl_display_roundtrip_queue) \ | ||
FAKE(pthread_create) \ | ||
FAKE(wl_display_flush) \ | ||
FAKE(wl_display_dispatch_queue) \ | ||
FAKE(wl_display_dispatch_queue_pending) \ | ||
FAKE(wl_display_get_error) \ | ||
FAKE(wl_display_get_fd) \ | ||
FAKE(wl_display_prepare_read_queue) \ | ||
FAKE(wl_display_read_events) \ | ||
FAKE(wl_proxy_get_version) \ | ||
FAKE(wl_display_disconnect) \ | ||
FAKE(wl_event_queue_destroy) \ | ||
FAKE(wl_proxy_set_queue) \ | ||
FAKE(wl_proxy_destroy) \ | ||
FAKE(wl_display_cancel_read) \ | ||
FAKE(wl_list_insert) \ | ||
FAKE(wl_array_add) \ | ||
FAKE(wl_proxy_marshal_flags) \ | ||
FAKE(wl_array_init) \ | ||
FAKE(wl_array_release) \ | ||
FAKE(wl_list_init) \ | ||
FAKE(wl_list_remove) \ | ||
FAKE(wl_list_length) \ | ||
FFF_RESET_HISTORY() | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif // CLIENT_API_FAKE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*************************************************************************** | ||
* | ||
* Copyright (C) 2023 Advanced Driver Information Technology Joint Venture GmbH | ||
* | ||
* | ||
* 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 "client_api_fake.h" | ||
#include "ilm_control_platform.h" | ||
#include "wayland-client-protocol.h" | ||
|
||
DEFINE_FFF_GLOBALS; | ||
|
||
DEFINE_FAKE_VALUE_FUNC(struct wl_display *, wl_display_connect, const char *); | ||
DEFINE_FAKE_VALUE_FUNC(struct wl_event_queue *, wl_display_create_queue, struct wl_display *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_display_roundtrip, struct wl_display *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_proxy_add_listener, struct wl_proxy *, registerHandler, void *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_display_roundtrip_queue, struct wl_display *, struct wl_event_queue *); | ||
DEFINE_FAKE_VALUE_FUNC(int, pthread_create, pthread_t *, const pthread_attr_t *, threadEntry, void *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_display_flush, struct wl_display *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_display_dispatch_queue, struct wl_display *, struct wl_event_queue *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_display_dispatch_queue_pending, struct wl_display *, struct wl_event_queue *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_display_get_error, struct wl_display *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_display_get_fd, struct wl_display *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_display_prepare_read_queue, struct wl_display *, struct wl_event_queue *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_display_read_events, struct wl_display *); | ||
DEFINE_FAKE_VOID_FUNC(wl_display_cancel_read, struct wl_display *); | ||
DEFINE_FAKE_VALUE_FUNC(uint32_t, wl_proxy_get_version, struct wl_proxy *); | ||
DEFINE_FAKE_VOID_FUNC(wl_display_disconnect, struct wl_display *); | ||
DEFINE_FAKE_VOID_FUNC(wl_event_queue_destroy, struct wl_event_queue *); | ||
DEFINE_FAKE_VOID_FUNC(wl_proxy_set_queue, struct wl_proxy *, struct wl_event_queue *); | ||
DEFINE_FAKE_VOID_FUNC(wl_proxy_destroy, struct wl_proxy *); | ||
DEFINE_FAKE_VALUE_FUNC(void *, wl_array_add, struct wl_array *, size_t); | ||
DEFINE_FAKE_VOID_FUNC(wl_list_insert, struct wl_list *, struct wl_list *); | ||
DEFINE_FAKE_VALUE_FUNC_VARARG(struct wl_proxy *, wl_proxy_marshal_flags, struct wl_proxy *, uint32_t, const struct wl_interface *, uint32_t, uint32_t, ...); | ||
DEFINE_FAKE_VOID_FUNC(wl_list_remove, struct wl_list *); | ||
DEFINE_FAKE_VOID_FUNC(wl_list_init, struct wl_list *); | ||
DEFINE_FAKE_VOID_FUNC(wl_array_init, struct wl_array *); | ||
DEFINE_FAKE_VOID_FUNC(wl_array_release, struct wl_array *); | ||
DEFINE_FAKE_VALUE_FUNC(int, wl_list_length, const struct wl_list *); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning messages when configuring of cmake.
change to: 65fa39b