From 184113ca0964709cfe6544e2d5f2b9a11c1832ce Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Tue, 20 Sep 2016 22:58:17 +0200 Subject: [PATCH] Also build and run testsuite on cmake CI tests. --- .travis.yml | 4 +++- CMakeLists.txt | 9 +++++++++ MemoryModule.c | 6 +++--- scripts/run-appveyor.bat | 10 +++++++++- tests/CMakeLists.txt | 14 ++++++++++++++ tests/TestSuite.c | 2 ++ 6 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 tests/CMakeLists.txt diff --git a/.travis.yml b/.travis.yml index f9ef247..3c45d20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ addons: - wine before_script: - - if [ ! -z "$CMAKE" ]; then cmake -DPLATFORM=$PLATFORM -D UNICODE=$UNICODE -H. -B.; fi + - if [ ! -z "$CMAKE" ]; then cmake -DPLATFORM=$PLATFORM -DUNICODE=$UNICODE -DTESTSUITE=ON -H. -B.; fi script: - if [ -z "$CMAKE" ]; then make PLATFORM=$PLATFORM UNICODE=$UNICODE; fi @@ -39,3 +39,5 @@ script: - cd example/DllLoader - ../../tests/runwine.sh $PLATFORM ./DllLoader.exe - ../../tests/runwine.sh $PLATFORM ./DllLoaderLoader.exe + - cd ../../tests + - ./runwine.sh $PLATFORM ./TestSuite.exe diff --git a/CMakeLists.txt b/CMakeLists.txt index e2a3676..e3ba63c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,11 +40,20 @@ else () message (STATUS "Compile without UNICODE support") endif () +option(TESTSUITE "Compile with TESTSUITE support" OFF) +if (TESTSUITE) + message (STATUS "Compile with TESTSUITE support") + add_definitions ("-DTESTSUITE") +else () + message (STATUS "Compile without TESTSUITE support") +endif () + add_library (MemoryModule STATIC MemoryModule.c MemoryModule.h) if (NOT MSVC) set_target_properties ("MemoryModule" PROPERTIES PREFIX "") endif () add_subdirectory (example) +add_subdirectory (tests) enable_language (RC) diff --git a/MemoryModule.c b/MemoryModule.c index 13a371f..cf38388 100644 --- a/MemoryModule.c +++ b/MemoryModule.c @@ -1028,7 +1028,6 @@ MemoryLoadStringEx(HMEMORYMODULE module, UINT id, LPTSTR buffer, int maxsize, WO #ifdef TESTSUITE #include -#include #ifndef PRIxPTR #ifdef _WIN64 @@ -1064,7 +1063,8 @@ static const uintptr_t AlignValueUpTests[][3] = { BOOL MemoryModuleTestsuite() { BOOL success = TRUE; - for (size_t idx = 0; AlignValueDownTests[idx][0]; ++idx) { + size_t idx; + for (idx = 0; AlignValueDownTests[idx][0]; ++idx) { const uintptr_t* tests = AlignValueDownTests[idx]; uintptr_t value = AlignValueDown(tests[0], tests[1]); if (value != tests[2]) { @@ -1073,7 +1073,7 @@ BOOL MemoryModuleTestsuite() { success = FALSE; } } - for (size_t idx = 0; AlignValueDownTests[idx][0]; ++idx) { + for (idx = 0; AlignValueDownTests[idx][0]; ++idx) { const uintptr_t* tests = AlignValueUpTests[idx]; uintptr_t value = AlignValueUp(tests[0], tests[1]); if (value != tests[2]) { diff --git a/scripts/run-appveyor.bat b/scripts/run-appveyor.bat index 0bc2943..6662d99 100644 --- a/scripts/run-appveyor.bat +++ b/scripts/run-appveyor.bat @@ -13,7 +13,7 @@ if /I "%PLATFORM%" == "x64" ( echo. echo Preparing %CONFIGURATION% build environment for %GENERATOR%%CMAKE_GEN_SUFFIX% ... -cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DPLATFORM=%PLATFORM% -DUNICODE=%UNICODE% -H. -Bbuild +cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DPLATFORM=%PLATFORM% -DUNICODE=%UNICODE% -DTESTSUITE=ON -H. -Bbuild if %errorlevel% neq 0 exit /b %errorlevel% echo. @@ -26,6 +26,7 @@ echo Copying generated files ... copy /y build\example\DllLoader\%CONFIGURATION%\DllLoader.exe build\example\DllLoader\ > NUL copy /y build\example\DllLoader\%CONFIGURATION%\DllLoaderLoader.exe build\example\DllLoader\ > NUL copy /y build\example\SampleDLL\%CONFIGURATION%\SampleDLL.dll build\example\SampleDLL\ > NUL +copy /y build\tests\%CONFIGURATION%\TestSuite.exe build\tests\ > NUL cd build\example\DllLoader @@ -38,3 +39,10 @@ echo. echo Running DllLoaderLoader.exe ... DllLoaderLoader.exe if %errorlevel% neq 0 exit /b %errorlevel% + +cd ..\..\tests + +echo. +echo Running TestSuite.exe ... +TestSuite.exe +if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..8b1007f --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,14 @@ +set (sources_testsuite + TestSuite.c +) + +if (NOT MSVC) + set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-static") + set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-static") +endif () + +add_executable (TestSuite ${sources_testsuite}) +target_link_libraries ("TestSuite" "MemoryModule") +if (NOT MSVC) + set_target_properties ("TestSuite" PROPERTIES SUFFIX ".exe") +endif () diff --git a/tests/TestSuite.c b/tests/TestSuite.c index be3e519..f4bd325 100644 --- a/tests/TestSuite.c +++ b/tests/TestSuite.c @@ -9,6 +9,8 @@ extern BOOL MemoryModuleTestsuite(); int main(int argc, char* argv[]) { + UNREFERENCED_PARAMETER(argc); + UNREFERENCED_PARAMETER(argv); if (!MemoryModuleTestsuite()) { return 1; }