X Tutup
Skip to content

Commit bc700b5

Browse files
authored
Re-enable windows build on travis (etr#187)
1 parent ee2f258 commit bc700b5

File tree

7 files changed

+100
-75
lines changed

7 files changed

+100
-75
lines changed

.travis.yml

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,71 @@ language: cpp
22
os:
33
- linux
44
- osx
5-
- windows
65
compiler:
76
- gcc
87
- clang
98
env:
109
- DEBUG="debug" COVERAGE="coverage"
1110
- DEBUG="nodebug" COVERAGE="nocoverage"
1211
- LINKING="static"
12+
before_cache:
13+
- |-
14+
case $TRAVIS_OS_NAME in
15+
windows)
16+
# https://unix.stackexchange.com/a/137322/107554
17+
$msys2 pacman --sync --clean --noconfirm
18+
;;
19+
esac
20+
cache:
21+
directories:
22+
- $HOME/AppData/Local/Temp/chocolatey
23+
- /C/tools/msys64
1324
before_install:
14-
- ps -ef
15-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then ps -Wla | sort ; fi
1625
- eval "${MATRIX_EVAL}"
1726
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/lib"; fi
1827
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export PATH=$PATH:/usr/local/lib; fi
1928
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib; fi
2029
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib; fi
30+
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export buildshell=''; fi
2131
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install info install-info; fi
2232
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo pip install codecov; fi
2333
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo pip install gcovr; fi
2434
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install cppcheck; fi
2535
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export CFLAGS='-mtune=generic'; fi
26-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install -r --no-progress -y msys2 make; fi
27-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then PATH=$PATH:/c/tools/msys64/usr/bin/ ; fi
28-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then powershell -executionpolicy bypass "pacman -Syu --noconfirm autoconf libtool automake make autoconf-archive pkg-config mingw-w64-x86_64-libsystre" ; fi
29-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then
30-
ln -s /c/tools/msys64/usr/share/autoconf* /usr/share/ ;
31-
ln -s /c/tools/msys64/usr/share/automake* /usr/share/ ;
32-
ln -s /c/tools/msys64/usr/share/aclocal* /usr/share/ ;
33-
ln -s /c/tools/msys64/usr/share/libtool* /usr/share/ ;
34-
ln -s /c/tools/msys64/usr/share/pkgconfig /usr/share/ ;
35-
ln -s /c/tools/msys64/usr/bin/autom4te /usr/bin/ ;
36-
ln -s /c/tools/msys64/usr/bin/autoconf /usr/bin/ ;
37-
ln -s /c/tools/msys64/usr/bin/autoheader /usr/bin/ ;
38-
ln -s /c/tools/msys64/usr/bin/m4 /usr/bin/ ;
39-
40-
PATH=$PATH:/c/tools/msys64/usr/bin/ ;
41-
export SHELL=/usr/bin/sh.exe ;
42-
fi
36+
- |-
37+
case $TRAVIS_OS_NAME in
38+
windows)
39+
[[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64
40+
choco uninstall -y mingw
41+
choco upgrade --no-progress -y msys2
42+
export msys2='cmd //C RefreshEnv.cmd '
43+
export msys2+='& set MSYS=winsymlinks:nativestrict '
44+
export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
45+
export buildshell="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
46+
export msys2+=" -msys2 -c "\"\$@"\" --"
47+
$msys2 pacman --sync --noconfirm --disable-download-timeout --needed mingw-w64-x86_64-toolchain
48+
$msys2 pacman -Syu --noconfirm --disable-download-timeout autoconf libtool automake make autoconf-archive pkg-config mingw-w64-x86_64-libsystre mingw-w64-x86_64-doxygen mingw-w64-x86_64-gnutls mingw-w64-x86_64-graphviz mingw-w64-x86_64-curl
49+
export PATH=/C/tools/msys64/mingw64/bin:$PATH
50+
export MAKE=mingw32-make # so that Autotools can find it
51+
;;
52+
esac
4353
- curl https://s3.amazonaws.com/libhttpserver/libmicrohttpd_releases/libmicrohttpd-0.9.59.tar.gz -o libmicrohttpd-0.9.59.tar.gz
4454
- tar -xzf libmicrohttpd-0.9.59.tar.gz
4555
- cd libmicrohttpd-0.9.59
4656
- if [[ "$ARM_ARCH_DIR" != "" ]]; then
4757
./configure --build `./config.guess` --host $ARM_ARCH_DIR --disable-examples;
48-
elif [[ "$TRAVIS_OS_NAME" = "windows" ]]; then
49-
./configure --prefix=/usr --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --disable-examples --disable-https --enable-shared --enable-static ;
5058
else
51-
./configure --disable-examples;
59+
if [ "$TRAVIS_OS_NAME" != "windows" ]; then $buildshell ./configure --disable-examples; else $buildshell ./configure --disable-examples --enable-poll=no; fi;
5260
fi
53-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then find . -name Makefile -type f -exec sed -i "s/\${SHELL}/\/usr\/bin\/sh.exe/" "{}" + ; fi
54-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then find . -name Makefile -type f -exec sed -i "s/\$(SHELL)/\/usr\/bin\/sh.exe/" "{}" + ; fi
55-
- make
56-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then make install; else sudo make install; fi
61+
- $buildshell make
62+
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then sudo make install; else $buildshell make install; fi
5763
- cd ..
5864
- if [ "$BUILD_TYPE" = "asan" ]; then export CFLAGS='-fsanitize=address'; export CXXLAGS='-fsanitize=address'; export LDFLAGS='-fsanitize=address'; fi
5965
- if [ "$BUILD_TYPE" = "msan" ]; then export CFLAGS='-fsanitize=memory'; export CXXLAGS='-fsanitize=memory'; export LDFLAGS='-fsanitize=memory'; fi
6066
- if [ "$BUILD_TYPE" = "lsan" ]; then export CFLAGS='-fsanitize=leak'; export CXXLAGS='-fsanitize=leak'; export LDFLAGS='-fsanitize=leak'; fi
6167
- if [ "$BUILD_TYPE" = "tsan" ]; then export CFLAGS='-fsanitize=thread'; export CXXLAGS='-fsanitize=thread'; export LDFLAGS='-fsanitize=thread'; fi
6268
- if [ "$BUILD_TYPE" = "ubsan" ]; then export export CFLAGS='-fsanitize=undefined'; export CXXLAGS='-fsanitize=undefined'; export LDFLAGS='-fsanitize=undefined'; fi
6369
install:
64-
- ps -ef
6570
- if [[ "$CROSS_COMPILE" == 1 ]] ; then
6671
if [[ "$ARM_ARCH_DIR" == "aarch64-linux-gnu" ]] ; then
6772
mkdir $HOME/linker_bin ;
@@ -71,35 +76,29 @@ install:
7176
ls -al $HOME/linker_bin/ld ;
7277
fi
7378
fi
74-
- ./bootstrap
79+
- $buildshell ./bootstrap
7580
- mkdir build
7681
- cd build
77-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then
78-
../configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --disable-fastopen --disable-examples CPPFLAGS='-I/c/tools/msys64/mingw64/include/ -I/usr/include/' LDFLAGS='-L/c/tools/msys64/mingw64/lib -L/usr/lib/' ;
79-
cd .. ;
80-
find . -name Makefile -type f -exec sed -i "s/\$(SHELL)/\/usr\/bin\/sh.exe/" "{}" + ;
81-
cd build ;
82-
elif [ "$LINKING" = "static" ]; then
83-
../configure --enable-static --disable-fastopen;
82+
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export MANIFEST_TOOL='no'; fi
83+
- if [ "$LINKING" = "static" ]; then
84+
$buildshell ../configure --enable-static --disable-fastopen;
8485
elif [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ]; then
85-
../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen;
86+
$buildshell ../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen;
8687
elif [ "$DEBUG" = "debug" ]; then
87-
../configure --enable-debug --disable-shared --disable-fastopen;
88+
$buildshell ../configure --enable-debug --disable-shared --disable-fastopen;
8889
elif [ "$CROSS_COMPILE" = "1" ] && [ "$ARM_ARCH_DIR" = "aarch64-linux-gnu" ]; then
89-
../configure --disable-fastopen --build `../config.guess` --host aarch64-linux-gnu CC="gcc -B$HOME/linker_bin" CXX="g++ -B$HOME/linker_bin";
90+
$buildshell ../configure --disable-fastopen --build `../config.guess` --host aarch64-linux-gnu CC="gcc -B$HOME/linker_bin" CXX="g++ -B$HOME/linker_bin";
9091
elif [ "$CROSS_COMPILE" = "1" ] && [ "$ARM_ARCH_DIR" = "arm-linux-gnueabi" ]; then
91-
../configure --disable-fastopen --build `../config.guess` --host arm-linux-gnueabi;
92+
$buildshell ../configure --disable-fastopen --build `../config.guess` --host arm-linux-gnueabi;
9293
elif [ "$VALGRIND" = "valgrind" ]; then
93-
../configure --enable-debug --disable-fastopen --disable-valgrind-helgrind --disable-valgrind-drd --disable-valgrind-sgcheck;
94+
$buildshell ../configure --enable-debug --disable-fastopen --disable-valgrind-helgrind --disable-valgrind-drd --disable-valgrind-sgcheck;
9495
else
95-
../configure --disable-fastopen;
96+
$buildshell ../configure --disable-fastopen;
9697
fi
9798
- if [ "$CROSS_COMPILE" = "1" ] && [ "$ARM_ARCH_DIR" = "aarch64-linux-gnu" ]; then sed -i 's+/usr/bin/ld+$HOME/linker_bin/ld+g' libtool; fi
9899
- if [ "$CROSS_COMPILE" = "1" ] && [ "$ARM_ARCH_DIR" = "aarch64-linux-gnu" ]; then sed -i 's+/usr/bin/ld+$HOME/linker_bin/ld+g' Makefile; fi
99-
- make
100-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then make check TESTS= ; fi
100+
- $buildshell make
101101
script:
102-
- ps -ef
103102
- if [[ "$CROSS_COMPILE" == 1 ]]; then
104103
cd test ;
105104
if [[ "$ARM_ARCH_DIR" == "aarch64-linux-gnu" ]]; then
@@ -120,8 +119,8 @@ script:
120119
qemu-arm -L /usr/arm-linux-gnueabi/ ./.libs/threaded ;
121120
fi
122121
fi
123-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then make check ; fi
124-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then cat test/test-suite.log; fi
122+
- $buildshell make check
123+
- $buildshell cat test/test-suite.log
125124
- if [ "$VALGRIND" = "valgrind" ]; then make check-valgrind; fi;
126125
- if [ "$VALGRIND" = "valgrind" ]; then cat test/test-suite-memcheck.log; fi;
127126
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ../src/; cppcheck --error-exitcode=1 .; cd ../build; fi
@@ -144,19 +143,13 @@ script:
144143
sleep 5 && ab -n 10000000 -c 100 localhost:8080/plaintext
145144
fi
146145
after_script:
147-
- ps -ef
148-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then ps -Wla | sort ; fi
149-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then gpgconf --kill gpg-agent ; fi
150146
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then taskkill //F //PID $(ps -Wla | tr -s ' ' | grep gpg | cut -f2 -d' ') ; fi
151-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then ps -Wla | sort ; fi
152-
- echo $$
153147
after_success:
154148
- if [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then bash <(curl -s https://codecov.io/bash); fi
155149
matrix:
156150
exclude:
157151
- compiler: clang
158152
env: DEBUG="debug" COVERAGE="coverage"
159-
- os: windows
160153
include:
161154
- os: windows
162155
env: DEBUG="nodebug" COVERAGE="nocoverage" YARN_GPG=no

configure.ac

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,14 @@ AC_SUBST(LDFLAGS)
344344
AC_SUBST(EXT_LIB_PATH)
345345
AC_SUBST(EXT_LIBS)
346346

347-
AC_CONFIG_LINKS([test/test_content:test/test_content])
348-
AC_CONFIG_LINKS([test/cert.pem:test/cert.pem])
349-
AC_CONFIG_LINKS([test/key.pem:test/key.pem])
350-
AC_CONFIG_LINKS([test/test_root_ca.pem:test/test_root_ca.pem])
351-
AC_CONFIG_LINKS([test/libhttpserver.supp:test/libhttpserver.supp])
352-
AC_CONFIG_LINKS([examples/cert.pem:examples/cert.pem])
353-
AC_CONFIG_LINKS([examples/key.pem:examples/key.pem])
354-
AC_CONFIG_LINKS([examples/test_content:examples/test_content])
347+
AC_CONFIG_FILES([test/test_content:test/test_content])
348+
AC_CONFIG_FILES([test/cert.pem:test/cert.pem])
349+
AC_CONFIG_FILES([test/key.pem:test/key.pem])
350+
AC_CONFIG_FILES([test/test_root_ca.pem:test/test_root_ca.pem])
351+
AC_CONFIG_FILES([test/libhttpserver.supp:test/libhttpserver.supp])
352+
AC_CONFIG_FILES([examples/cert.pem:examples/cert.pem])
353+
AC_CONFIG_FILES([examples/key.pem:examples/key.pem])
354+
AC_CONFIG_FILES([examples/test_content:examples/test_content])
355355

356356
AC_OUTPUT(
357357
libhttpserver.pc

src/http_utils.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
#include "httpserver/http_utils.hpp"
2222

2323
#if defined(__MINGW32__) || defined(__CYGWIN32__)
24-
#define _WINDOWS
25-
#undef _WIN32_WINNT
26-
#define _WIN32_WINNT 0x600
2724
#include <winsock2.h>
2825
#include <ws2tcpip.h>
2926
#else
@@ -35,8 +32,8 @@
3532
#include <stdio.h>
3633
#include <stdlib.h>
3734
#include <string.h>
38-
#include <fstream>
3935
#include <iomanip>
36+
#include <fstream>
4037
#include <iostream>
4138
#include <sstream>
4239
#include <stdexcept>

src/httpserver/http_utils.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
#ifdef HAVE_GNUTLS
2929
#include <gnutls/gnutls.h>
3030
#endif
31+
32+
// needed to force Vista as a bare minimum to have inet_ntop (libmicro defines
33+
// this to include XP support as a lower version).
34+
#if defined(__MINGW32__) || defined(__CYGWIN32__)
35+
#define _WINDOWS
36+
#undef _WIN32_WINNT
37+
#define _WIN32_WINNT 0x600
38+
#endif
39+
3140
#include <microhttpd.h>
3241
#include <algorithm>
3342
#include <cctype>

test/integ/authentication.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
#include <ws2tcpip.h>
2727
#else
2828
#include <arpa/inet.h>
29+
#include <netinet/in.h>
30+
#include <sys/socket.h>
2931
#endif
3032

3133
#include <curl/curl.h>
32-
#include <netinet/in.h>
33-
#include <sys/socket.h>
3434

3535
#include "httpserver.hpp"
3636
#include "littletest.hpp"
@@ -53,7 +53,7 @@ class user_pass_resource : public httpserver::http_resource
5353
{
5454
if (req.get_user() != "myuser" || req.get_pass() != "mypass")
5555
{
56-
return shared_ptr<basic_auth_fail_response>(new basic_auth_fail_response("FAIL", "test@example.com"));
56+
return shared_ptr<basic_auth_fail_response>(new basic_auth_fail_response("FAIL", "examplerealm"));
5757
}
5858
return shared_ptr<string_response>(new string_response(req.get_user() + " " + req.get_pass(), 200, "text/plain"));
5959
}
@@ -65,14 +65,14 @@ class digest_resource : public httpserver::http_resource
6565
const shared_ptr<http_response> render_GET(const http_request& req)
6666
{
6767
if (req.get_digested_user() == "") {
68-
return shared_ptr<digest_auth_fail_response>(new digest_auth_fail_response("FAIL", "test@example.com", MY_OPAQUE, true));
68+
return shared_ptr<digest_auth_fail_response>(new digest_auth_fail_response("FAIL", "examplerealm", MY_OPAQUE, true));
6969
}
7070
else
7171
{
7272
bool reload_nonce = false;
73-
if(!req.check_digest_auth("test@example.com", "mypass", 300, reload_nonce))
73+
if(!req.check_digest_auth("examplerealm", "mypass", 300, reload_nonce))
7474
{
75-
return shared_ptr<digest_auth_fail_response>(new digest_auth_fail_response("FAIL", "test@example.com", MY_OPAQUE, reload_nonce));
75+
return shared_ptr<digest_auth_fail_response>(new digest_auth_fail_response("FAIL", "examplerealm", MY_OPAQUE, reload_nonce));
7676
}
7777
}
7878
return shared_ptr<string_response>(new string_response("SUCCESS", 200, "text/plain"));
@@ -139,6 +139,11 @@ LT_BEGIN_AUTO_TEST(authentication_suite, base_auth_fail)
139139
ws.stop();
140140
LT_END_AUTO_TEST(base_auth_fail)
141141

142+
// do not run the digest auth tests on windows as curl
143+
// appears to have problems with it.
144+
// Will fix this separately
145+
#ifndef _WINDOWS
146+
142147
LT_BEGIN_AUTO_TEST(authentication_suite, digest_auth)
143148
webserver ws = create_webserver(8080)
144149
.digest_auth_random("myrandom")
@@ -148,12 +153,21 @@ LT_BEGIN_AUTO_TEST(authentication_suite, digest_auth)
148153
ws.register_resource("base", &digest);
149154
ws.start(false);
150155

156+
#if defined(_WINDOWS)
157+
curl_global_init(CURL_GLOBAL_WIN32 );
158+
#else
151159
curl_global_init(CURL_GLOBAL_ALL);
160+
#endif
161+
152162
std::string s;
153163
CURL *curl = curl_easy_init();
154164
CURLcode res;
155165
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
166+
#if defined(_WINDOWS)
167+
curl_easy_setopt(curl, CURLOPT_USERPWD, "examplerealm/myuser:mypass");
168+
#else
156169
curl_easy_setopt(curl, CURLOPT_USERPWD, "myuser:mypass");
170+
#endif
157171
curl_easy_setopt(curl, CURLOPT_URL, "localhost:8080/base");
158172
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
159173
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
@@ -179,12 +193,21 @@ LT_BEGIN_AUTO_TEST(authentication_suite, digest_auth_wrong_pass)
179193
ws.register_resource("base", &digest);
180194
ws.start(false);
181195

196+
#if defined(_WINDOWS)
197+
curl_global_init(CURL_GLOBAL_WIN32 );
198+
#else
182199
curl_global_init(CURL_GLOBAL_ALL);
200+
#endif
201+
183202
std::string s;
184203
CURL *curl = curl_easy_init();
185204
CURLcode res;
186205
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
206+
#if defined(_WINDOWS)
207+
curl_easy_setopt(curl, CURLOPT_USERPWD, "examplerealm/myuser:wrongpass");
208+
#else
187209
curl_easy_setopt(curl, CURLOPT_USERPWD, "myuser:wrongpass");
210+
#endif
188211
curl_easy_setopt(curl, CURLOPT_URL, "localhost:8080/base");
189212
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
190213
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
@@ -201,6 +224,8 @@ LT_BEGIN_AUTO_TEST(authentication_suite, digest_auth_wrong_pass)
201224
ws.stop();
202225
LT_END_AUTO_TEST(digest_auth_wrong_pass)
203226

227+
#endif
228+
204229
LT_BEGIN_AUTO_TEST_ENV()
205230
AUTORUN_TESTS()
206231
LT_END_AUTO_TEST_ENV()

test/integ/deferred.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
#include <ws2tcpip.h>
2727
#else
2828
#include <arpa/inet.h>
29+
#include <netinet/in.h>
30+
#include <sys/socket.h>
2931
#endif
3032

3133
#include <curl/curl.h>
32-
#include <netinet/in.h>
3334
#include <signal.h>
34-
#include <sys/socket.h>
3535
#include <unistd.h>
3636

3737
#include "httpserver.hpp"

test/integ/ws_start_stop.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
#include <ws2tcpip.h>
2727
#else
2828
#include <arpa/inet.h>
29+
#include <netinet/in.h>
30+
#include <sys/socket.h>
2931
#endif
3032

3133
#include <curl/curl.h>
32-
#include <netinet/in.h>
3334
#include <pthread.h>
34-
#include <sys/socket.h>
35+
#include <unistd.h>
3536

3637
#include "httpserver.hpp"
3738
#include "littletest.hpp"

0 commit comments

Comments
 (0)
X Tutup