Skip to content

Commit 5c6b699

Browse files
authored
Merge pull request fancycode#51 from fancycode/cmake_testsuite
Also build and run testsuite on cmake CI tests.
2 parents f5c9db8 + 184113c commit 5c6b699

File tree

6 files changed

+40
-5
lines changed

6 files changed

+40
-5
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ addons:
3030
- wine
3131

3232
before_script:
33-
- if [ ! -z "$CMAKE" ]; then cmake -DPLATFORM=$PLATFORM -D UNICODE=$UNICODE -H. -B.; fi
33+
- if [ ! -z "$CMAKE" ]; then cmake -DPLATFORM=$PLATFORM -DUNICODE=$UNICODE -DTESTSUITE=ON -H. -B.; fi
3434

3535
script:
3636
- if [ -z "$CMAKE" ]; then make PLATFORM=$PLATFORM UNICODE=$UNICODE; fi
@@ -39,3 +39,5 @@ script:
3939
- cd example/DllLoader
4040
- ../../tests/runwine.sh $PLATFORM ./DllLoader.exe
4141
- ../../tests/runwine.sh $PLATFORM ./DllLoaderLoader.exe
42+
- cd ../../tests
43+
- ./runwine.sh $PLATFORM ./TestSuite.exe

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,20 @@ else ()
4040
message (STATUS "Compile without UNICODE support")
4141
endif ()
4242

43+
option(TESTSUITE "Compile with TESTSUITE support" OFF)
44+
if (TESTSUITE)
45+
message (STATUS "Compile with TESTSUITE support")
46+
add_definitions ("-DTESTSUITE")
47+
else ()
48+
message (STATUS "Compile without TESTSUITE support")
49+
endif ()
50+
4351
add_library (MemoryModule STATIC MemoryModule.c MemoryModule.h)
4452
if (NOT MSVC)
4553
set_target_properties ("MemoryModule" PROPERTIES PREFIX "")
4654
endif ()
4755

4856
add_subdirectory (example)
57+
add_subdirectory (tests)
4958

5059
enable_language (RC)

MemoryModule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,6 @@ MemoryLoadStringEx(HMEMORYMODULE module, UINT id, LPTSTR buffer, int maxsize, WO
10281028

10291029
#ifdef TESTSUITE
10301030
#include <stdio.h>
1031-
#include <inttypes.h>
10321031

10331032
#ifndef PRIxPTR
10341033
#ifdef _WIN64
@@ -1064,7 +1063,8 @@ static const uintptr_t AlignValueUpTests[][3] = {
10641063

10651064
BOOL MemoryModuleTestsuite() {
10661065
BOOL success = TRUE;
1067-
for (size_t idx = 0; AlignValueDownTests[idx][0]; ++idx) {
1066+
size_t idx;
1067+
for (idx = 0; AlignValueDownTests[idx][0]; ++idx) {
10681068
const uintptr_t* tests = AlignValueDownTests[idx];
10691069
uintptr_t value = AlignValueDown(tests[0], tests[1]);
10701070
if (value != tests[2]) {
@@ -1073,7 +1073,7 @@ BOOL MemoryModuleTestsuite() {
10731073
success = FALSE;
10741074
}
10751075
}
1076-
for (size_t idx = 0; AlignValueDownTests[idx][0]; ++idx) {
1076+
for (idx = 0; AlignValueDownTests[idx][0]; ++idx) {
10771077
const uintptr_t* tests = AlignValueUpTests[idx];
10781078
uintptr_t value = AlignValueUp(tests[0], tests[1]);
10791079
if (value != tests[2]) {

scripts/run-appveyor.bat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if /I "%PLATFORM%" == "x64" (
1313

1414
echo.
1515
echo Preparing %CONFIGURATION% build environment for %GENERATOR%%CMAKE_GEN_SUFFIX% ...
16-
cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DPLATFORM=%PLATFORM% -DUNICODE=%UNICODE% -H. -Bbuild
16+
cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DPLATFORM=%PLATFORM% -DUNICODE=%UNICODE% -DTESTSUITE=ON -H. -Bbuild
1717
if %errorlevel% neq 0 exit /b %errorlevel%
1818

1919
echo.
@@ -26,6 +26,7 @@ echo Copying generated files ...
2626
copy /y build\example\DllLoader\%CONFIGURATION%\DllLoader.exe build\example\DllLoader\ > NUL
2727
copy /y build\example\DllLoader\%CONFIGURATION%\DllLoaderLoader.exe build\example\DllLoader\ > NUL
2828
copy /y build\example\SampleDLL\%CONFIGURATION%\SampleDLL.dll build\example\SampleDLL\ > NUL
29+
copy /y build\tests\%CONFIGURATION%\TestSuite.exe build\tests\ > NUL
2930

3031
cd build\example\DllLoader
3132

@@ -38,3 +39,10 @@ echo.
3839
echo Running DllLoaderLoader.exe ...
3940
DllLoaderLoader.exe
4041
if %errorlevel% neq 0 exit /b %errorlevel%
42+
43+
cd ..\..\tests
44+
45+
echo.
46+
echo Running TestSuite.exe ...
47+
TestSuite.exe
48+
if %errorlevel% neq 0 exit /b %errorlevel%

tests/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
set (sources_testsuite
2+
TestSuite.c
3+
)
4+
5+
if (NOT MSVC)
6+
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-static")
7+
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-static")
8+
endif ()
9+
10+
add_executable (TestSuite ${sources_testsuite})
11+
target_link_libraries ("TestSuite" "MemoryModule")
12+
if (NOT MSVC)
13+
set_target_properties ("TestSuite" PROPERTIES SUFFIX ".exe")
14+
endif ()

tests/TestSuite.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extern BOOL MemoryModuleTestsuite();
99

1010
int main(int argc, char* argv[])
1111
{
12+
UNREFERENCED_PARAMETER(argc);
13+
UNREFERENCED_PARAMETER(argv);
1214
if (!MemoryModuleTestsuite()) {
1315
return 1;
1416
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy