libwinpr-pool: add test stubs
This commit is contained in:
parent
9a7bcbb084
commit
c048dc4cc4
@ -58,3 +58,8 @@ endif()
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
|
||||
|
2
winpr/libwinpr/pool/test/.gitignore
vendored
Normal file
2
winpr/libwinpr/pool/test/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
TestPool
|
||||
TestPool.c
|
35
winpr/libwinpr/pool/test/CMakeLists.txt
Normal file
35
winpr/libwinpr/pool/test/CMakeLists.txt
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
set(MODULE_NAME "TestPool")
|
||||
set(MODULE_PREFIX "TEST_POOL")
|
||||
|
||||
set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
|
||||
|
||||
set(${MODULE_PREFIX}_TESTS
|
||||
TestPoolIO.c
|
||||
TestPoolSynch.c
|
||||
TestPoolThread.c
|
||||
TestPoolTimer.c
|
||||
TestPoolWork.c)
|
||||
|
||||
create_test_sourcelist(${MODULE_PREFIX}_SRCS
|
||||
${${MODULE_PREFIX}_DRIVER}
|
||||
${${MODULE_PREFIX}_TESTS})
|
||||
|
||||
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||
|
||||
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
|
||||
MONOLITHIC ${MONOLITHIC_BUILD}
|
||||
MODULE winpr
|
||||
MODULES winpr-pool)
|
||||
|
||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}")
|
||||
|
||||
foreach(test ${${MODULE_PREFIX}_TESTS})
|
||||
get_filename_component(TestName ${test} NAME_WE)
|
||||
add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName})
|
||||
endforeach()
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test")
|
||||
|
9
winpr/libwinpr/pool/test/TestPoolIO.c
Normal file
9
winpr/libwinpr/pool/test/TestPoolIO.c
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/pool.h>
|
||||
|
||||
int TestPoolIO(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
9
winpr/libwinpr/pool/test/TestPoolSynch.c
Normal file
9
winpr/libwinpr/pool/test/TestPoolSynch.c
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/pool.h>
|
||||
|
||||
int TestPoolSynch(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
26
winpr/libwinpr/pool/test/TestPoolThread.c
Normal file
26
winpr/libwinpr/pool/test/TestPoolThread.c
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/pool.h>
|
||||
|
||||
/**
|
||||
* Improve Scalability With New Thread Pool APIs:
|
||||
* http://msdn.microsoft.com/en-us/magazine/cc16332.aspx
|
||||
*
|
||||
* Introduction to the Windows Threadpool:
|
||||
* http://blogs.msdn.com/b/harip/archive/2010/10/11/introduction-to-the-windows-threadpool-part-1.aspx
|
||||
* http://blogs.msdn.com/b/harip/archive/2010/10/12/introduction-to-the-windows-threadpool-part-2.aspx
|
||||
*/
|
||||
|
||||
int TestPoolThread(int argc, char* argv[])
|
||||
{
|
||||
TP_POOL* pool;
|
||||
|
||||
pool = CreateThreadpool(NULL);
|
||||
|
||||
SetThreadpoolThreadMinimum(pool, 8); /* default is 0 */
|
||||
SetThreadpoolThreadMaximum(pool, 64); /* default is 500 */
|
||||
|
||||
CloseThreadpool(pool);
|
||||
|
||||
return 0;
|
||||
}
|
9
winpr/libwinpr/pool/test/TestPoolTimer.c
Normal file
9
winpr/libwinpr/pool/test/TestPoolTimer.c
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/pool.h>
|
||||
|
||||
int TestPoolTimer(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
28
winpr/libwinpr/pool/test/TestPoolWork.c
Normal file
28
winpr/libwinpr/pool/test/TestPoolWork.c
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/pool.h>
|
||||
|
||||
void test_WorkCallback(PTP_CALLBACK_INSTANCE instance, void* context, PTP_WORK work)
|
||||
{
|
||||
printf("Hello %s", context);
|
||||
}
|
||||
|
||||
int TestPoolWork(int argc, char* argv[])
|
||||
{
|
||||
TP_WORK * work;
|
||||
|
||||
work = CreateThreadpoolWork(test_WorkCallback, "world", NULL);
|
||||
|
||||
if (!work)
|
||||
{
|
||||
printf("CreateThreadpoolWork failure\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SubmitThreadpoolWork(work);
|
||||
WaitForThreadpoolWorkCallbacks(work, FALSE);
|
||||
CloseThreadpoolWork(work);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user