From ccb31efe631b47f7c778d5869b542748b6e33f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 4 Sep 2014 15:46:20 -0400 Subject: [PATCH] libfreerdp-primitives: migrate tests to ctest --- libfreerdp/primitives/CMakeLists.txt | 2 +- libfreerdp/primitives/test/.gitignore | 1 + libfreerdp/primitives/test/CMakeLists.txt | 178 ++----- ..._16to32bpp.c => TestPrimitives16to32bpp.c} | 25 +- .../test/{test_add.c => TestPrimitivesAdd.c} | 22 + ..._alphaComp.c => TestPrimitivesAlphaComp.c} | 22 + .../{test_andor.c => TestPrimitivesAndOr.c} | 35 ++ .../{test_colors.c => TestPrimitivesColors.c} | 35 ++ .../{test_copy.c => TestPrimitivesCopy.c} | 22 + .../test/{test_set.c => TestPrimitivesSet.c} | 48 ++ .../{test_shift.c => TestPrimitivesShift.c} | 61 +++ .../{test_sign.c => TestPrimitivesSign.c} | 22 + .../{test_YCoCg.c => TestPrimitivesYCoCg.c} | 23 +- libfreerdp/primitives/test/prim_test.c | 488 ++---------------- libfreerdp/primitives/test/prim_test.h | 23 +- 15 files changed, 390 insertions(+), 617 deletions(-) rename libfreerdp/primitives/test/{test_16to32bpp.c => TestPrimitives16to32bpp.c} (94%) rename libfreerdp/primitives/test/{test_add.c => TestPrimitivesAdd.c} (92%) rename libfreerdp/primitives/test/{test_alphaComp.c => TestPrimitivesAlphaComp.c} (95%) rename libfreerdp/primitives/test/{test_andor.c => TestPrimitivesAndOr.c} (92%) rename libfreerdp/primitives/test/{test_colors.c => TestPrimitivesColors.c} (92%) rename libfreerdp/primitives/test/{test_copy.c => TestPrimitivesCopy.c} (89%) rename libfreerdp/primitives/test/{test_set.c => TestPrimitivesSet.c} (92%) rename libfreerdp/primitives/test/{test_shift.c => TestPrimitivesShift.c} (88%) rename libfreerdp/primitives/test/{test_sign.c => TestPrimitivesSign.c} (90%) rename libfreerdp/primitives/test/{test_YCoCg.c => TestPrimitivesYCoCg.c} (91%) diff --git a/libfreerdp/primitives/CMakeLists.txt b/libfreerdp/primitives/CMakeLists.txt index f544b350e..9bc898c18 100644 --- a/libfreerdp/primitives/CMakeLists.txt +++ b/libfreerdp/primitives/CMakeLists.txt @@ -100,6 +100,6 @@ endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") if(BUILD_TESTING AND ((NOT WIN32) AND (NOT APPLE))) -# add_subdirectory(test) + add_subdirectory(test) endif() diff --git a/libfreerdp/primitives/test/.gitignore b/libfreerdp/primitives/test/.gitignore index 082fee1c1..f25c3eed1 100644 --- a/libfreerdp/primitives/test/.gitignore +++ b/libfreerdp/primitives/test/.gitignore @@ -1,2 +1,3 @@ prim_test +TestPrimitives.c diff --git a/libfreerdp/primitives/test/CMakeLists.txt b/libfreerdp/primitives/test/CMakeLists.txt index 972cee3b8..c5fe100c8 100644 --- a/libfreerdp/primitives/test/CMakeLists.txt +++ b/libfreerdp/primitives/test/CMakeLists.txt @@ -1,155 +1,49 @@ -# FreeRDP: A Remote Desktop Protocol Client -# primitives test makefile builder -# vi:ts=4 sw=4: -# -# (c) Copyright 2012 Hewlett-Packard Development Company, L.P. -# 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. -# -# TODO: Integrate this into the testing framework, in some form. -# Right now this produces a standalone test that covers both functionality -# and performance of the primitives library entrypoints. +set(MODULE_NAME "TestPrimitives") +set(MODULE_PREFIX "TEST_FREERDP_PRIMITIVES") -cmake_minimum_required(VERSION 2.8) -set(MODULE_NAME "prim_test") -set(MODULE_PREFIX "PRIMITIVES_LIBRARY_TEST") +set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) -set(PRIMITIVE_TEST_CFILES +set(${MODULE_PREFIX}_TESTS + TestPrimitives16to32bpp.c + TestPrimitivesAdd.c + TestPrimitivesAlphaComp.c + TestPrimitivesAndOr.c + TestPrimitivesColors.c + TestPrimitivesCopy.c + TestPrimitivesSet.c + TestPrimitivesShift.c + TestPrimitivesSign.c + TestPrimitivesYCoCg.c) + +create_test_sourcelist(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_DRIVER} + ${${MODULE_PREFIX}_TESTS}) + +set(${MODULE_PREFIX}_EXTRA_SRCS prim_test.c - test_16to32bpp.c - test_add.c - test_alphaComp.c - test_andor.c - test_colors.c - test_copy.c - test_set.c - test_shift.c - test_sign.c - test_YCoCg.c - ../prim_16to32bpp.c - ../prim_add.c - ../prim_andor.c - ../prim_alphaComp.c - ../prim_colors.c - ../prim_copy.c - ../prim_set.c - ../prim_shift.c - ../prim_sign.c - ../prim_YCoCg.c - ../prim_16to32bpp_opt.c - ../prim_add_opt.c - ../prim_alphaComp_opt.c - ../prim_andor_opt.c - ../prim_colors_opt.c - ../prim_set_opt.c - ../prim_shift_opt.c - ../prim_sign_opt.c - ../prim_YCoCg_opt.c - ../primitives.c - ) - -set(PRIMITIVE_TEST_HEADERS - measure.h prim_test.h - ../prim_internal.h -) + measure.h) -set(PRIMITIVE_TEST_SRCS - ${PRIMITIVE_TEST_CFILES} - ${PRIMITIVE_TEST_HEADERS} - ) +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_EXTRA_SRCS}) -include_directories(. ../../.. ../../../include ../../../winpr/include) -add_definitions(-DPRIM_STATIC=auto -DALL_PRIMITIVES_VERSIONS -DHAVE_CONFIG_H) +set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS + MONOLITHIC ${MONOLITHIC_BUILD} + MODULE freerdp + MODULES freerdp-primitives) + +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) -# If these haven't been set by the caller, set them now to defaults. -if(NOT DEFINED WITH_IPP) - set(WITH_IPP FALSE) -endif() -if(NOT DEFINED WITH_SSE2) - if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") - set(WITH_SSE2 FALSE) - else() - set(WITH_SSE2 TRUE) - endif() -endif() -if(NOT DEFINED WITH_NEON) - if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") - set(WITH_NEON TRUE) - else() - set(WITH_NEON FALSE) - endif() -endif() +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) -if(WITH_SSE2) - if(CMAKE_COMPILER_IS_GNUCC) - set(OPTFLAGS "${OPTFLAGS} -msse2 -mssse3 -O2 -Wdeclaration-after-statement") - endif() +add_definitions(-DPRIM_STATIC=auto -DALL_PRIMITIVES_VERSIONS) - if(MSVC) - set(OPTFLAGS "${OPTFLAGS} /arch:SSE2") - endif() -elseif(WITH_NEON) - if(CMAKE_COMPILER_IS_GNUCC) - set(OPTFLAGS "${OPTFLAGS} -mfpu=neon -mfloat-abi=${ARM_FP_ABI} -O2") - endif() - # TODO: Add MSVC equivalent -endif() +set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") -add_executable(prim_test ${PRIMITIVE_TEST_SRCS}) - -if(WITH_IPP) - if(NOT DEFINED IPP_FOUND) - include(../../../cmake/FindIPP.cmake) - endif() - - # IPP PATH debugging messages - message(IPP_FOUND=${IPP_FOUND}) - message(IPP_VERSION_STR=${IPP_VERSION_STR}) - message(IPP_VERSION_MAJOR=${IPP_VERSION_MAJOR}) - message(IPP_VERSION_MINOR=${IPP_VERSION_MINOR}) - message(IPP_VERSION_BUILD=${IPP_VERSION_BUILD}) - message(IPP_ROOT_DIR=${IPP_ROOT_DIR}) - message(IPP_INCLUDE_DIRS=${IPP_INCLUDE_DIRS}) - message(IPP_LIBRARY_DIRS=${IPP_LIBRARY_DIRS}) - message(IPP_LIBRARIES=${IPP_LIBRARIES}) - message(IPP_COMPILER_LIBRARY_DIRS=${IPP_COMPILER_LIBRARY_DIRS}) - message(IPP_COMPILER_LIBRARIES=${IPP_COMPILER_LIBRARIES}) - message(IPP_LIBRARY_LIST=${IPP_LIBRARY_LIST}) - message(IPP_LIB_PREFIX=${IPP_LIB_PREFIX}) - message(IPP_LIB_SUFFIX=${IPP_LIB_SUFFIX}) - message(IPP_PREFIX=${IPP_PREFIX}) - message(IPP_SUFFIX=${IPP_SUFFIX}) - message(IPPCORE=${IPPCORE}) - message(IPPS=${IPPS}) - message(IPPI=${IPPI}) - message(IPPCC=${IPPCC}) - message(IPPCV=${IPPCV}) - message(IPPVM=${IPPVM}) - - if(CMAKE_COMPILER_IS_GNUCC) - foreach(INCLDIR ${IPP_INCLUDE_DIRS}) - set(OPTFLAGS "${OPTFLAGS} -I${INCLDIR}") - endforeach(INCLDIR) - endif() - target_link_libraries(prim_test ${IPP_LIBRARY_LIST}) -endif() - -set_property(SOURCE ${PRIMITIVE_TEST_CFILES} PROPERTY COMPILE_FLAGS ${OPTFLAGS}) - -find_library(WINPR_SYSINFO NAMES winpr-sysinfo HINTS ../../../winpr/libwinpr/sysinfo) -target_link_libraries(prim_test rt ${WINPR_SYSINFO}) - -if(NOT TESTING_OUTPUT_DIRECTORY) - set(TESTING_OUTPUT_DIRECTORY .) -endif() -add_test(prim_test ${TESTING_OUTPUT_DIRECTORY}/prim_test functionality) +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 "FreeRDP/Test") + diff --git a/libfreerdp/primitives/test/test_16to32bpp.c b/libfreerdp/primitives/test/TestPrimitives16to32bpp.c similarity index 94% rename from libfreerdp/primitives/test/test_16to32bpp.c rename to libfreerdp/primitives/test/TestPrimitives16to32bpp.c index dc0c60317..03a070e40 100644 --- a/libfreerdp/primitives/test/test_16to32bpp.c +++ b/libfreerdp/primitives/test/TestPrimitives16to32bpp.c @@ -28,6 +28,8 @@ static const int RGB_TRIAL_ITERATIONS = 1000; static const float TEST_TIME = 4.0; +extern BOOL g_TestPrimitivesPerformance; + extern pstatus_t general_RGB565ToARGB_16u32u_C3C4( const UINT16* pSrc, INT32 srcStep, UINT32* pDst, INT32 dstStep, @@ -134,7 +136,7 @@ static BOOL try_16To32( /* ------------------------------------------------------------------------- */ int test_RGB565ToARGB_16u32u_C3C4_func(void) { - INT16 ALIGN(data16[4096+3]); + UINT16 ALIGN(data16[4096+3]); BOOL success; success = TRUE; @@ -176,7 +178,6 @@ int test_RGB565ToARGB_16u32u_C3C4_speed(void) { UINT16 ALIGN(src[4096]); UINT32 ALIGN(dst[4096]); - int i; int size_array[] = { 64 }; get_random_data(src, sizeof(src)); @@ -186,3 +187,23 @@ int test_RGB565ToARGB_16u32u_C3C4_speed(void) size_array, 1, RGB_TRIAL_ITERATIONS, TEST_TIME); return SUCCESS; } + +int TestPrimitives16to32bpp(int argc, char* argv[]) +{ + int status; + + status = test_RGB565ToARGB_16u32u_C3C4_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_RGB565ToARGB_16u32u_C3C4_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/test_add.c b/libfreerdp/primitives/test/TestPrimitivesAdd.c similarity index 92% rename from libfreerdp/primitives/test/test_add.c rename to libfreerdp/primitives/test/TestPrimitivesAdd.c index 453e2a7de..08ab41ff4 100644 --- a/libfreerdp/primitives/test/test_add.c +++ b/libfreerdp/primitives/test/TestPrimitivesAdd.c @@ -23,6 +23,8 @@ static const int ADD16S_PRETEST_ITERATIONS = 300000*64; static const int TEST_TIME = 2.0; // seconds +extern BOOL g_TestPrimitivesPerformance; + extern pstatus_t general_add_16s( const INT16 *pSrc1, const INT16 *pSrc2, INT16 *pDst, int len); extern pstatus_t sse3_add_16s( @@ -112,3 +114,23 @@ int test_add16s_speed(void) test_sizes, NUM_TEST_SIZES, ADD16S_PRETEST_ITERATIONS, TEST_TIME); return SUCCESS; } + +int TestPrimitivesAdd(int argc, char* argv[]) +{ + int status; + + status = test_add16s_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_add16s_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/test_alphaComp.c b/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c similarity index 95% rename from libfreerdp/primitives/test/test_alphaComp.c rename to libfreerdp/primitives/test/TestPrimitivesAlphaComp.c index c3b5e9ca1..18332dcb5 100644 --- a/libfreerdp/primitives/test/test_alphaComp.c +++ b/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c @@ -22,6 +22,8 @@ static const int ALPHA_PRETEST_ITERATIONS = 5000000; static const float TEST_TIME = 5.0; +extern BOOL g_TestPrimitivesPerformance; + static const int block_size[] = { 4, 64, 256 }; #define NUM_BLOCK_SIZES (sizeof(block_size)/sizeof(int)) #define MAX_BLOCK_SIZE 256 @@ -233,3 +235,23 @@ int test_alphaComp_speed(void) return SUCCESS; } + +int TestPrimitivesAlphaComp(int argc, char* argv[]) +{ + int status; + + status = test_alphaComp_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_alphaComp_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/test_andor.c b/libfreerdp/primitives/test/TestPrimitivesAndOr.c similarity index 92% rename from libfreerdp/primitives/test/test_andor.c rename to libfreerdp/primitives/test/TestPrimitivesAndOr.c index d82991408..24d73d43a 100644 --- a/libfreerdp/primitives/test/test_andor.c +++ b/libfreerdp/primitives/test/TestPrimitivesAndOr.c @@ -23,6 +23,8 @@ static const int ANDOR_PRETEST_ITERATIONS = 100000; static const int TEST_TIME = 2.0; // seconds +extern BOOL g_TestPrimitivesPerformance; + extern pstatus_t general_andC_32u(const UINT32 *pSrc, UINT32 val, UINT32 *pDst, int len); extern pstatus_t sse3_andC_32u(const UINT32 *pSrc, UINT32 val, @@ -185,3 +187,36 @@ int test_or_32u_speed(void) test_sizes, NUM_TEST_SIZES, ANDOR_PRETEST_ITERATIONS, TEST_TIME); return SUCCESS; } + +int TestPrimitivesAndOr(int argc, char* argv[]) +{ + int status; + + status = test_and_32u_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_and_32u_speed(); + + if (status != SUCCESS) + return 1; + } + + status = test_or_32u_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_or_32u_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/test_colors.c b/libfreerdp/primitives/test/TestPrimitivesColors.c similarity index 92% rename from libfreerdp/primitives/test/test_colors.c rename to libfreerdp/primitives/test/TestPrimitivesColors.c index 628cb5d5e..717328246 100644 --- a/libfreerdp/primitives/test/test_colors.c +++ b/libfreerdp/primitives/test/TestPrimitivesColors.c @@ -23,6 +23,8 @@ static const int RGB_TRIAL_ITERATIONS = 1000; static const int YCBCR_TRIAL_ITERATIONS = 1000; static const float TEST_TIME = 4.0; +extern BOOL g_TestPrimitivesPerformance; + extern pstatus_t general_RGBToRGB_16s8u_P3AC4R(const INT16 *pSrc[3], int srcStep, BYTE *pDst, int dstStep, const prim_size_t *roi); extern pstatus_t sse2_RGBToRGB_16s8u_P3AC4R(const INT16 *pSrc[3], @@ -241,3 +243,36 @@ int test_yCbCrToRGB_16s16s_P3P3_speed(void) size_array, 1, YCBCR_TRIAL_ITERATIONS, TEST_TIME); return SUCCESS; } + +int TestPrimitivesColors(int argc, char* argv[]) +{ + int status; + + status = test_RGBToRGB_16s8u_P3AC4R_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_RGBToRGB_16s8u_P3AC4R_speed(); + + if (status != SUCCESS) + return 1; + } + + status = test_yCbCrToRGB_16s16s_P3P3_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_yCbCrToRGB_16s16s_P3P3_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/test_copy.c b/libfreerdp/primitives/test/TestPrimitivesCopy.c similarity index 89% rename from libfreerdp/primitives/test/test_copy.c rename to libfreerdp/primitives/test/TestPrimitivesCopy.c index 13b4f57f2..189969d7c 100644 --- a/libfreerdp/primitives/test/test_copy.c +++ b/libfreerdp/primitives/test/TestPrimitivesCopy.c @@ -26,6 +26,8 @@ static const int TEST_TIME = 1.0; // seconds extern pstatus_t sse3_copy_8u(const BYTE *pSrc, BYTE *pDst, int len); #endif +extern BOOL g_TestPrimitivesPerformance; + /* ------------------------------------------------------------------------- */ int test_copy8u_func(void) { @@ -84,3 +86,23 @@ int test_copy8u_speed(void) test_sizes, NUM_TEST_SIZES, MEMCPY_PRETEST_ITERATIONS, TEST_TIME); return SUCCESS; } + +int TestPrimitivesCopy(int argc, char* argv[]) +{ + int status; + + status = test_copy8u_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_copy8u_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/test_set.c b/libfreerdp/primitives/test/TestPrimitivesSet.c similarity index 92% rename from libfreerdp/primitives/test/test_set.c rename to libfreerdp/primitives/test/TestPrimitivesSet.c index 32d22c71d..3d689eeff 100644 --- a/libfreerdp/primitives/test/test_set.c +++ b/libfreerdp/primitives/test/TestPrimitivesSet.c @@ -23,6 +23,8 @@ static const int MEMSET8_PRETEST_ITERATIONS = 100000000; static const int MEMSET32_PRETEST_ITERATIONS = 40000000; static const float TEST_TIME = 1.0; +extern BOOL g_TestPrimitivesPerformance; + extern pstatus_t general_set_8u(BYTE val, BYTE *pDst, int len); extern pstatus_t sse2_set_8u(BYTE val, BYTE *pDst, int len); extern pstatus_t general_set_32s(INT32 val, INT32 *pDst, int len); @@ -303,3 +305,49 @@ int test_set32s_speed(void) #endif return SUCCESS; } + +int TestPrimitivesSet(int argc, char* argv[]) +{ + int status; + + status = test_set8u_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_set8u_speed(); + + if (status != SUCCESS) + return 1; + } + + status = test_set32s_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_set32s_speed(); + + if (status != SUCCESS) + return 1; + } + + status = test_set32u_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_set32u_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/test_shift.c b/libfreerdp/primitives/test/TestPrimitivesShift.c similarity index 88% rename from libfreerdp/primitives/test/test_shift.c rename to libfreerdp/primitives/test/TestPrimitivesShift.c index 588187a4b..693c12b34 100644 --- a/libfreerdp/primitives/test/test_shift.c +++ b/libfreerdp/primitives/test/TestPrimitivesShift.c @@ -23,6 +23,8 @@ static const int SHIFT_PRETEST_ITERATIONS = 50000; static const float TEST_TIME = 1.0; +extern BOOL g_TestPrimitivesPerformance; + extern pstatus_t general_lShiftC_16s( const INT16 *pSrc, int val, INT16 *pDst, int len); extern pstatus_t general_rShiftC_16s( @@ -187,3 +189,62 @@ int test_rShift_16u_speed(void) test_sizes, NUM_TEST_SIZES, SHIFT_PRETEST_ITERATIONS, TEST_TIME); return SUCCESS; } + +int TestPrimitivesShift(int argc, char* argv[]) +{ + int status; + + status = test_lShift_16s_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_lShift_16s_speed(); + + if (status != SUCCESS) + return 1; + } + + status = test_lShift_16u_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_lShift_16u_speed(); + + if (status != SUCCESS) + return 1; + } + + status = test_rShift_16s_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_rShift_16s_speed(); + + if (status != SUCCESS) + return 1; + } + + status = test_rShift_16u_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_rShift_16u_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/test_sign.c b/libfreerdp/primitives/test/TestPrimitivesSign.c similarity index 90% rename from libfreerdp/primitives/test/test_sign.c rename to libfreerdp/primitives/test/TestPrimitivesSign.c index beb22ee1d..0d06d64bc 100644 --- a/libfreerdp/primitives/test/test_sign.c +++ b/libfreerdp/primitives/test/TestPrimitivesSign.c @@ -22,6 +22,8 @@ static const int SIGN_PRETEST_ITERATIONS = 100000; static const float TEST_TIME = 1.0; +extern BOOL g_TestPrimitivesPerformance; + extern pstatus_t general_sign_16s(const INT16 *pSrc, INT16 *pDst, int len); #ifdef WITH_SSE2 extern pstatus_t ssse3_sign_16s(const INT16 *pSrc, INT16 *pDst, int len); @@ -101,3 +103,23 @@ int test_sign16s_speed(void) test_sizes, NUM_TEST_SIZES, SIGN_PRETEST_ITERATIONS, TEST_TIME); return SUCCESS; } + +int TestPrimitivesSign(int argc, char* argv[]) +{ + int status; + + status = test_sign16s_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_sign16s_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/test_YCoCg.c b/libfreerdp/primitives/test/TestPrimitivesYCoCg.c similarity index 91% rename from libfreerdp/primitives/test/test_YCoCg.c rename to libfreerdp/primitives/test/TestPrimitivesYCoCg.c index f09acd5de..d6f4d4289 100644 --- a/libfreerdp/primitives/test/test_YCoCg.c +++ b/libfreerdp/primitives/test/TestPrimitivesYCoCg.c @@ -26,6 +26,8 @@ static const int YCOCG_TRIAL_ITERATIONS = 20000; static const float TEST_TIME = 4.0; +extern BOOL g_TestPrimitivesPerformance; + extern pstatus_t general_YCoCgRToRGB_8u_AC4R(const BYTE *pSrc, INT32 srcStep, BYTE *pDst, INT32 dstStep, UINT32 width, UINT32 height, UINT8 shift, BOOL withAlpha, BOOL invert); @@ -97,7 +99,6 @@ int test_YCoCgRToRGB_8u_AC4R_speed(void) { INT32 ALIGN(in[4096]); INT32 ALIGN(out[4096]); - int i; int size_array[] = { 64 }; get_random_data(in, sizeof(in)); @@ -107,3 +108,23 @@ int test_YCoCgRToRGB_8u_AC4R_speed(void) size_array, 1, YCOCG_TRIAL_ITERATIONS, TEST_TIME); return SUCCESS; } + +int TestPrimitivesYCoCg(int argc, char* argv[]) +{ + int status; + + status = test_YCoCgRToRGB_8u_AC4R_func(); + + if (status != SUCCESS) + return 1; + + if (g_TestPrimitivesPerformance) + { + status = test_YCoCgRToRGB_8u_AC4R_speed(); + + if (status != SUCCESS) + return 1; + } + + return 0; +} diff --git a/libfreerdp/primitives/test/prim_test.c b/libfreerdp/primitives/test/prim_test.c index e9824a181..a19b5f64b 100644 --- a/libfreerdp/primitives/test/prim_test.c +++ b/libfreerdp/primitives/test/prim_test.c @@ -18,108 +18,22 @@ #include "prim_test.h" +#include #include #include -#include -#include + #include +#include #ifdef HAVE_UNISTD_H #include #endif -#include -#include - +BOOL g_TestPrimitivesPerformance = FALSE; int test_sizes[] = { 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 }; -int Quiet = 0; - - /* ------------------------------------------------------------------------- */ -typedef struct -{ - UINT32 flag; - const char *str; -} flagpair_t; - -static const flagpair_t flags[] = -{ -#ifdef _M_IX86_AMD64 - { PF_MMX_INSTRUCTIONS_AVAILABLE, "MMX" }, - { PF_3DNOW_INSTRUCTIONS_AVAILABLE, "3DNow" }, - { PF_SSE_INSTRUCTIONS_AVAILABLE, "SSE" }, - { PF_SSE2_INSTRUCTIONS_AVAILABLE, "SSE2" }, - { PF_SSE3_INSTRUCTIONS_AVAILABLE, "SSE3" }, -#elif defined(_M_ARM) - { PF_ARM_VFP3, "VFP3" }, - { PF_ARM_INTEL_WMMX, "IWMMXT" }, - { PF_ARM_NEON_INSTRUCTIONS_AVAILABLE, "NEON" }, -#endif -}; - -static const flagpair_t flags_extended[] = -{ -#ifdef _M_IX86_AMD64 - { PF_EX_3DNOW_PREFETCH, "3DNow-PF" }, - { PF_EX_SSSE3, "SSSE3" }, - { PF_EX_SSE41, "SSE4.1" }, - { PF_EX_SSE42, "SSE4.2" }, - { PF_EX_AVX, "AVX" }, - { PF_EX_FMA, "FMA" }, - { PF_EX_AVX_AES, "AVX-AES" }, - { PF_EX_AVX2, "AVX2" }, -#elif defined(_M_ARM) - { PF_EX_ARM_VFP1, "VFP1"}, - { PF_EX_ARM_VFP4, "VFP4" }, -#endif -}; - -void primitives_flags_str(char* str, size_t len) -{ - int i; - - *str = '\0'; - --len; /* for the '/0' */ - - for (i = 0; i < sizeof(flags) / sizeof(flagpair_t); ++i) - { - if (IsProcessorFeaturePresent(flags[i].flag)) - { - int slen = strlen(flags[i].str) + 1; - - if (len < slen) - break; - - if (*str != '\0') - strcat(str, " "); - - strcat(str, flags[i].str); - len -= slen; - } - } - for (i = 0; i < sizeof(flags_extended) / sizeof(flagpair_t); ++i) - { - if (IsProcessorFeaturePresentEx(flags_extended[i].flag)) - { - int slen = strlen(flags_extended[i].str) + 1; - - if (len < slen) - break; - - if (*str != '\0') - strcat(str, " "); - - strcat(str, flags_extended[i].str); - len -= slen; - } - } -} - -/* ------------------------------------------------------------------------- */ -static void get_random_data_lrand( - void *buffer, - size_t size) +static void get_random_data_lrand(void *buffer, size_t size) { static int seeded = 0; long int *ptr = (long int *) buffer; @@ -145,11 +59,9 @@ static void get_random_data_lrand( } /* ------------------------------------------------------------------------- */ -void get_random_data( - void *buffer, - size_t size) +void get_random_data(void *buffer, size_t size) { -#ifdef linux +#ifdef __linux__ size_t offset = 0; int fd = open("/dev/urandom", O_RDONLY); if (fd < 0) @@ -171,373 +83,39 @@ void get_random_data( } /* ------------------------------------------------------------------------- */ -float _delta_time( - const struct timespec *t0, - const struct timespec *t1) +float _delta_time(const struct timespec *t0, const struct timespec *t1) { - INT64 secs = (INT64) (t1->tv_sec) - (INT64) (t0->tv_sec); - long nsecs = t1->tv_nsec - t0->tv_nsec; + INT64 secs = (INT64) (t1->tv_sec) - (INT64) (t0->tv_sec); + long nsecs = t1->tv_nsec - t0->tv_nsec; double retval; - if (nsecs < 0) + if (nsecs < 0) { - --secs; - nsecs += 1000000000; - } - retval = (double) secs + (double) nsecs / (double) 1000000000.0; - return (retval < 0.0) ? 0.0 : (float) retval; + --secs; + nsecs += 1000000000; + } + + retval = (double) secs + (double) nsecs / (double) 1000000000.0; + return (retval < 0.0) ? 0.0 : (float) retval; } /* ------------------------------------------------------------------------- */ -void _floatprint( - float t, - char *output) +void _floatprint(float t, char *output) { - /* I don't want to link against -lm, so avoid log,exp,... */ - float f = 10.0; + /* I don't want to link against -lm, so avoid log,exp,... */ + float f = 10.0; int i; - while (t > f) f *= 10.0; - f /= 1000.0; - i = ((int) (t/f+0.5)) * (int) f; - if (t < 0.0) sprintf(output, "%f", t); - else if (i == 0) sprintf(output, "%d", (int) (t+0.5)); - else if (t < 1e+3) sprintf(output, "%3d", i); - else if (t < 1e+6) sprintf(output, "%3d,%03d", - i/1000, i % 1000); - else if (t < 1e+9) sprintf(output, "%3d,%03d,000", - i/1000000, (i % 1000000) / 1000); - else if (t < 1e+12) sprintf(output, "%3d,%03d,000,000", - i/1000000000, (i % 1000000000) / 1000000); - else sprintf(output, "%f", t); -} - -/* ------------------------------------------------------------------------- */ -/* Specific areas to test: */ -#define TEST_COPY8 (1<<0) -#define TEST_SET8 (1<<1) -#define TEST_SET32S (1<<2) -#define TEST_SET32U (1<<3) -#define TEST_SIGN16S (1<<4) -#define TEST_ADD16S (1<<5) -#define TEST_LSHIFT16S (1<<6) -#define TEST_LSHIFT16U (1<<7) -#define TEST_RSHIFT16S (1<<8) -#define TEST_RSHIFT16U (1<<9) -#define TEST_RGB (1<<10) -#define TEST_ALPHA (1<<11) -#define TEST_AND (1<<12) -#define TEST_OR (1<<13) -#define TEST_YCOCG (1<<14) -#define TEST_16TO32 (1<<15) - -/* Specific types of testing: */ -#define TEST_FUNCTIONALITY (1<<0) -#define TEST_PERFORMANCE (1<<1) - -/* ------------------------------------------------------------------------- */ - -typedef struct -{ - const char *testStr; - UINT32 bits; -} test_t; - -static const test_t testList[] = -{ - { "all", 0xFFFFFFFFU }, - { "copy", TEST_COPY8 }, - { "copy8", TEST_COPY8 }, - { "set", TEST_SET8|TEST_SET32S|TEST_SET32U }, - { "set8", TEST_SET8 }, - { "set32", TEST_SET32S|TEST_SET32U }, - { "set32s", TEST_SET32S }, - { "set32u", TEST_SET32U }, - { "sign", TEST_SIGN16S }, - { "sign16s", TEST_SIGN16S }, - { "add", TEST_ADD16S }, - { "add16s", TEST_ADD16S }, - { "lshift", TEST_LSHIFT16S|TEST_LSHIFT16U }, - { "rshift", TEST_RSHIFT16S|TEST_RSHIFT16U }, - { "shift", TEST_LSHIFT16S|TEST_LSHIFT16U|TEST_RSHIFT16S|TEST_RSHIFT16U }, - { "lshift16s", TEST_LSHIFT16S }, - { "lshift16u", TEST_LSHIFT16U }, - { "rshift16s", TEST_RSHIFT16S }, - { "rshift16u", TEST_RSHIFT16U }, - { "rgb", TEST_RGB }, - { "color", TEST_RGB }, - { "colors", TEST_RGB }, - { "ycocg", TEST_YCOCG }, - { "alpha", TEST_ALPHA }, - { "and", TEST_AND }, - { "or", TEST_OR }, - { "16to32", TEST_16TO32 } -}; - -#define NUMTESTS (sizeof(testList)/sizeof(test_t)) - -static const test_t testTypeList[] = -{ - { "functionality", TEST_FUNCTIONALITY }, - { "performance", TEST_PERFORMANCE }, -}; - -#define NUMTESTTYPES (sizeof(testTypeList)/sizeof(test_t)) - -int main(int argc, char** argv) -{ - int i; - char hints[1024]; - UINT32 testSet = 0; - UINT32 testTypes = 0; - int results = SUCCESS; - - /* Parse command line for the test set. */ - - for (i = 1; i < argc; ++i) - { - int j; - BOOL found = 0; - - for (j=0; j f) f *= 10.0; + f /= 1000.0; + i = ((int) (t/f+0.5)) * (int) f; + if (t < 0.0) sprintf(output, "%f", t); + else if (i == 0) sprintf(output, "%d", (int) (t+0.5)); + else if (t < 1e+3) sprintf(output, "%3d", i); + else if (t < 1e+6) sprintf(output, "%3d,%03d", + i/1000, i % 1000); + else if (t < 1e+9) sprintf(output, "%3d,%03d,000", + i/1000000, (i % 1000000) / 1000); + else if (t < 1e+12) sprintf(output, "%3d,%03d,000,000", + i/1000000000, (i % 1000000000) / 1000000); + else sprintf(output, "%f", t); } diff --git a/libfreerdp/primitives/test/prim_test.h b/libfreerdp/primitives/test/prim_test.h index e336e3eb5..42f8777c9 100644 --- a/libfreerdp/primitives/test/prim_test.h +++ b/libfreerdp/primitives/test/prim_test.h @@ -20,31 +20,22 @@ #ifndef __PRIMTEST_H_INCLUDED__ #define __PRIMTEST_H_INCLUDED__ -#include -#include +#include +#include #include - -#include -#include -#include +#include #include -#include + +#include "measure.h" #ifdef WITH_IPP #include #include #endif -#define BLOCK_ALIGNMENT 16 -#ifdef __GNUC__ -#define ALIGN(x) x __attribute((aligned(BLOCK_ALIGNMENT))) -#define POSSIBLY_UNUSED(x) x __attribute((unused)) -#else -/* TODO: Someone needs to finish this for non-GNU C */ -#define ALIGN(x) x -#define POSSIBLY_UNUSED(x) x -#endif +#define ALIGN(x) x DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) + #define ABS(_x_) ((_x_) < 0 ? (-(_x_)) : (_x_)) #define MAX_TEST_SIZE 4096