[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gitlab: run tests built for Windows using wine


Hello,

Follow attached patches to run the unit tests for Windows builds using wine.

Regards,
Anderson
From cc87ef232435b434a85d47e9396fc8bc0ab209fc Mon Sep 17 00:00:00 2001
From: Anderson Toshiyuki Sasaki <ansasaki@xxxxxxxxxx>
Date: Wed, 27 Jun 2018 11:19:36 +0200
Subject: [PATCH 1/3] gitlab: added executable exension on test binaries

This is necessary when building the tests for Windows.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@xxxxxxxxxx>
---
 cmake/Modules/AddCMockaTest.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/Modules/AddCMockaTest.cmake b/cmake/Modules/AddCMockaTest.cmake
index 3380ecdf..77325eeb 100644
--- a/cmake/Modules/AddCMockaTest.cmake
+++ b/cmake/Modules/AddCMockaTest.cmake
@@ -26,5 +26,5 @@ endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
 function (ADD_CMOCKA_TEST _testName _testSource)
     add_executable(${_testName} ${_testSource})
     target_link_libraries(${_testName} ${ARGN})
-    add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName})
+    add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName}${CMAKE_EXECUTABLE_SUFFIX})
 endfunction (ADD_CMOCKA_TEST)
-- 
2.14.3

From 01d334431f1ac19aca61832b7ae1d1a0c57c0658 Mon Sep 17 00:00:00 2001
From: Anderson Toshiyuki Sasaki <ansasaki@xxxxxxxxxx>
Date: Wed, 27 Jun 2018 13:19:21 +0200
Subject: [PATCH 2/3] gitlab: use wine to run tests built for Windows

When building in a cross-compiling environment, use wine to run the
tests.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@xxxxxxxxxx>
---
 .gitlab-ci.yml                    |  8 ++++++++
 cmake/Modules/AddCMockaTest.cmake | 11 ++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index db037e6f..54128d7f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -217,6 +217,10 @@ tumbleweed/static-analysis:
 mingw64:
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
   script:
+  - Xvfb :1 -screen 0 1024x768x16 -ac +extension GLX +render -noreset &
+  - export DISPLAY=:1
+  - wineboot
+  - sed '/\"PATH\"/ s/"$/;Z:\\\\usr\\\\x86_64-w64-mingw32\\\\sys-root\\\\mingw\\\\bin\"/' -i ~/.wine/system.reg
   - mkdir -p obj && cd obj && mingw64-cmake -DCMAKE_BUILD_TYPE=Debug
     -DWITH_SSH1=ON -DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON
     -DWITH_PCAP=ON -DWITH_TESTING=ON .. && make -j$(nproc) &&
@@ -236,6 +240,10 @@ mingw64:
 mingw32:
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
   script:
+  - Xvfb :1 -screen 0 1024x768x16 -ac +extension GLX +render -noreset &
+  - export DISPLAY=:1
+  - wineboot
+  - sed '/\"PATH\"/ s/"$/;Z:\\\\usr\\\\i686-w64-mingw32\\\\sys-root\\\\mingw\\\\bin\"/' -i ~/.wine/system.reg
   - mkdir -p obj && cd obj && mingw32-cmake -DCMAKE_BUILD_TYPE=Debug
     -DWITH_SSH1=ON -DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON
     -DWITH_PCAP=ON -DWITH_TESTING=ON .. && make -j$(nproc) &&
diff --git a/cmake/Modules/AddCMockaTest.cmake b/cmake/Modules/AddCMockaTest.cmake
index 77325eeb..fb17520f 100644
--- a/cmake/Modules/AddCMockaTest.cmake
+++ b/cmake/Modules/AddCMockaTest.cmake
@@ -23,8 +23,17 @@ if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
     set(CMAKE_EXEC_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" CACHE STRING "Address sanitizer executable linker flags")
 endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
 
+if (CMAKE_CROSSCOMPILING)
+    if (WIN32)
+        FIND_PROGRAM(WINE_EXECUTABLE
+            NAMES wine
+        )
+        set(TARGET_SYSTEM_EMULATOR ${WINE_EXECUTABLE})
+    endif()
+endif()
+
 function (ADD_CMOCKA_TEST _testName _testSource)
     add_executable(${_testName} ${_testSource})
     target_link_libraries(${_testName} ${ARGN})
-    add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName}${CMAKE_EXECUTABLE_SUFFIX})
+    add_test(${_testName} ${TARGET_SYSTEM_EMULATOR} ${CMAKE_CURRENT_BINARY_DIR}/${_testName}${CMAKE_EXECUTABLE_SUFFIX})
 endfunction (ADD_CMOCKA_TEST)
-- 
2.14.3

From 8ae0e041790847bb51cf95673964d54a9b9259cf Mon Sep 17 00:00:00 2001
From: Anderson Toshiyuki Sasaki <ansasaki@xxxxxxxxxx>
Date: Wed, 27 Jun 2018 14:43:21 +0200
Subject: [PATCH 3/3] gitlab: add MinGW libraries to wine PATH search

set WINEPATH environment variable to add the path to the MinGW libraries
when running tests using wine.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@xxxxxxxxxx>
---
 .gitlab-ci.yml | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 54128d7f..a2872bde 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -217,14 +217,13 @@ tumbleweed/static-analysis:
 mingw64:
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
   script:
-  - Xvfb :1 -screen 0 1024x768x16 -ac +extension GLX +render -noreset &
+  - Xvfb :1 -screen 0 1024x768x16 -ac +extension GLX +render -noreset -nolisten tcp &
   - export DISPLAY=:1
-  - wineboot
-  - sed '/\"PATH\"/ s/"$/;Z:\\\\usr\\\\x86_64-w64-mingw32\\\\sys-root\\\\mingw\\\\bin\"/' -i ~/.wine/system.reg
   - mkdir -p obj && cd obj && mingw64-cmake -DCMAKE_BUILD_TYPE=Debug
     -DWITH_SSH1=ON -DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON
-    -DWITH_PCAP=ON -DWITH_TESTING=ON .. && make -j$(nproc) &&
-    ctest --output-on-failure
+    -DWITH_PCAP=ON -DWITH_TESTING=ON .. && make -j$(nproc)
+  - export WINEPATH=/usr/x86_64-w64-mingw32/sys-root/mingw/bin
+  - ctest --output-on-failure
   tags:
   - shared
   except:
@@ -240,14 +239,13 @@ mingw64:
 mingw32:
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
   script:
-  - Xvfb :1 -screen 0 1024x768x16 -ac +extension GLX +render -noreset &
+  - Xvfb :1 -screen 0 1024x768x16 -ac +extension GLX +render -noreset -nolisten tcp &
   - export DISPLAY=:1
-  - wineboot
-  - sed '/\"PATH\"/ s/"$/;Z:\\\\usr\\\\i686-w64-mingw32\\\\sys-root\\\\mingw\\\\bin\"/' -i ~/.wine/system.reg
   - mkdir -p obj && cd obj && mingw32-cmake -DCMAKE_BUILD_TYPE=Debug
     -DWITH_SSH1=ON -DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON
-    -DWITH_PCAP=ON -DWITH_TESTING=ON .. && make -j$(nproc) &&
-    ctest --output-on-failure
+    -DWITH_PCAP=ON -DWITH_TESTING=ON .. && make -j$(nproc)
+  - export WINEPATH=/usr/i686-w64-mingw32/sys-root/mingw/bin
+  - ctest --output-on-failure
   tags:
   - shared
   except:
-- 
2.14.3


Follow-Ups:
Re: [PATCH] gitlab: run tests built for Windows using wineAndreas Schneider <asn@xxxxxxxxxxxxxx>
Re: [PATCH] gitlab: run tests built for Windows using wineAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org