New upstream version 26.0.0+dfsg1
This commit is contained in:
parent
8e020cdacb
commit
240080891f
837 changed files with 41275 additions and 9196 deletions
39
test/cmocka/CMakeLists.txt
Normal file
39
test/cmocka/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
project(obs-cmocka)
|
||||
|
||||
# Fix libobs path
|
||||
macro(fixLink target_arg)
|
||||
if(APPLE AND UNIX)
|
||||
add_custom_command (TARGET ${target_arg}
|
||||
POST_BUILD COMMAND "${CMAKE_INSTALL_NAME_TOOL}"
|
||||
"-change" "@rpath/libobs.0.dylib" "@executable_path/../../libobs/libobs.0.dylib"
|
||||
"$<TARGET_FILE:${target_arg}>" VERBATIM)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(CMAKE_MACOSX_RPATH TRUE)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/" "@executable_path/")
|
||||
|
||||
find_package(CMocka CONFIG REQUIRED)
|
||||
include_directories(${CMOCKA_INCLUDE_DIR})
|
||||
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs")
|
||||
|
||||
# fix rpath on linux
|
||||
if (UNIX AND NOT APPLE)
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN";../../libobs)
|
||||
endif()
|
||||
|
||||
# Serializer test
|
||||
add_executable(test_serializer test_serializer.c)
|
||||
target_link_libraries(test_serializer ${CMOCKA_LIBRARIES} libobs)
|
||||
|
||||
add_test(test_serializer ${CMAKE_CURRENT_BINARY_DIR}/test_serializer)
|
||||
fixLink(test_serializer)
|
||||
|
||||
|
||||
# darray test
|
||||
add_executable(test_darray test_darray.c)
|
||||
target_link_libraries(test_darray ${CMOCKA_LIBRARIES} libobs)
|
||||
|
||||
add_test(test_darray ${CMAKE_CURRENT_BINARY_DIR}/test_darray)
|
||||
fixLink(test_darray)
|
||||
29
test/cmocka/test_darray.c
Normal file
29
test/cmocka/test_darray.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
|
||||
#include <util/darray.h>
|
||||
|
||||
static void array_basic_test(void **state)
|
||||
{
|
||||
DARRAY(uint8_t) testarray;
|
||||
da_init(testarray);
|
||||
|
||||
uint8_t t = 1;
|
||||
da_push_back_array(testarray, &t, sizeof(uint8_t));
|
||||
|
||||
assert_int_equal(testarray.num, 1);
|
||||
assert_memory_equal(testarray.array, &t, 1);
|
||||
|
||||
da_free(testarray);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(array_basic_test),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
31
test/cmocka/test_serializer.c
Normal file
31
test/cmocka/test_serializer.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
|
||||
#include <util/array-serializer.h>
|
||||
|
||||
static void serialize_test(void **state)
|
||||
{
|
||||
struct array_output_data output;
|
||||
struct serializer s;
|
||||
|
||||
array_output_serializer_init(&s, &output);
|
||||
|
||||
s_w8(&s, 0x01);
|
||||
s_w8(&s, 0xff);
|
||||
s_w8(&s, 0xe1);
|
||||
|
||||
assert_int_equal(output.bytes.num, 3);
|
||||
uint8_t expected[3] = {0x01, 0xff, 0xe1};
|
||||
assert_memory_equal(output.bytes.array, expected, 3);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(serialize_test),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue