X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
05365be
Force windows build
etr Mar 8, 2020
a2c17d5
Temporarily reverting the re-ordering of includes
etr Mar 8, 2020
60a2e45
Moving back http_utils to be the first include
etr Mar 8, 2020
a84933c
Forcing libmicro on _WIN32_WINNT 0x600
etr Mar 8, 2020
d7d788d
Re-establishing the correct order of inclusion
etr Mar 8, 2020
d76ea70
Standardize msys2 installation
etr Mar 8, 2020
bf7b5aa
Further simplify the windows build
etr Mar 8, 2020
479736b
Remove windows-specific configure
etr Mar 8, 2020
f6622f9
Add sudo to install on linux/mac
etr Mar 8, 2020
26207d1
Manually disable poll
etr Mar 8, 2020
4582476
Speed-up build by avoid timeouts
etr Mar 8, 2020
e92de66
Kill GPG at the end of build
etr Mar 8, 2020
8085657
Printing out the configure file for debug
etr Mar 8, 2020
3be8f73
Force manifest tool to empty on win
etr Mar 9, 2020
0c1c357
Force skip check for manifest tool
etr Mar 9, 2020
3e71b3f
Disable doxygen (not working on win)
etr Mar 9, 2020
8f384fe
Remove commands not needed
etr Mar 9, 2020
4b9b7e0
Install doxygen and gnutls
etr Mar 9, 2020
c2231dc
Disable doxygen on windows only
etr Mar 9, 2020
fca96e9
Install graphviz on windows
etr Mar 9, 2020
510bb34
Install curl on windows
etr Mar 9, 2020
106ec34
Use windows networking libs for windows in tests
Mar 9, 2020
11f8057
Add explicit dependency for sleep
Mar 9, 2020
515b10a
Fix sys/socket.h to avoid using it on windows
Mar 9, 2020
11e20e7
copy test/example data rather than linking
Mar 9, 2020
eee42dc
Spell the full realm out on windows digest auth.
Mar 9, 2020
ba12120
Initialize curl with win32 dependencies
etr Mar 9, 2020
2ff9a1e
Explicitly pass the realm on windows
etr Mar 9, 2020
69c60b1
Simplify the realm string
etr Mar 9, 2020
01a2b27
Disable digest auth tests on windows
etr Mar 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 46 additions & 53 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,71 @@ language: cpp
os:
- linux
- osx
- windows
compiler:
- gcc
- clang
env:
- DEBUG="debug" COVERAGE="coverage"
- DEBUG="nodebug" COVERAGE="nocoverage"
- LINKING="static"
before_cache:
- |-
case $TRAVIS_OS_NAME in
windows)
# https://unix.stackexchange.com/a/137322/107554
$msys2 pacman --sync --clean --noconfirm
;;
esac
cache:
directories:
- $HOME/AppData/Local/Temp/chocolatey
- /C/tools/msys64
before_install:
- ps -ef
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then ps -Wla | sort ; fi
- eval "${MATRIX_EVAL}"
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/lib"; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export PATH=$PATH:/usr/local/lib; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export buildshell=''; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install info install-info; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo pip install codecov; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo pip install gcovr; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install cppcheck; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export CFLAGS='-mtune=generic'; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install -r --no-progress -y msys2 make; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then PATH=$PATH:/c/tools/msys64/usr/bin/ ; fi
- 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
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then
ln -s /c/tools/msys64/usr/share/autoconf* /usr/share/ ;
ln -s /c/tools/msys64/usr/share/automake* /usr/share/ ;
ln -s /c/tools/msys64/usr/share/aclocal* /usr/share/ ;
ln -s /c/tools/msys64/usr/share/libtool* /usr/share/ ;
ln -s /c/tools/msys64/usr/share/pkgconfig /usr/share/ ;
ln -s /c/tools/msys64/usr/bin/autom4te /usr/bin/ ;
ln -s /c/tools/msys64/usr/bin/autoconf /usr/bin/ ;
ln -s /c/tools/msys64/usr/bin/autoheader /usr/bin/ ;
ln -s /c/tools/msys64/usr/bin/m4 /usr/bin/ ;

PATH=$PATH:/c/tools/msys64/usr/bin/ ;
export SHELL=/usr/bin/sh.exe ;
fi
- |-
case $TRAVIS_OS_NAME in
windows)
[[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64
choco uninstall -y mingw
choco upgrade --no-progress -y msys2
export msys2='cmd //C RefreshEnv.cmd '
export msys2+='& set MSYS=winsymlinks:nativestrict '
export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
export buildshell="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
export msys2+=" -msys2 -c "\"\$@"\" --"
$msys2 pacman --sync --noconfirm --disable-download-timeout --needed mingw-w64-x86_64-toolchain
$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
export PATH=/C/tools/msys64/mingw64/bin:$PATH
export MAKE=mingw32-make # so that Autotools can find it
;;
esac
- curl https://s3.amazonaws.com/libhttpserver/libmicrohttpd_releases/libmicrohttpd-0.9.59.tar.gz -o libmicrohttpd-0.9.59.tar.gz
- tar -xzf libmicrohttpd-0.9.59.tar.gz
- cd libmicrohttpd-0.9.59
- if [[ "$ARM_ARCH_DIR" != "" ]]; then
./configure --build `./config.guess` --host $ARM_ARCH_DIR --disable-examples;
elif [[ "$TRAVIS_OS_NAME" = "windows" ]]; then
./configure --prefix=/usr --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --disable-examples --disable-https --enable-shared --enable-static ;
else
./configure --disable-examples;
if [ "$TRAVIS_OS_NAME" != "windows" ]; then $buildshell ./configure --disable-examples; else $buildshell ./configure --disable-examples --enable-poll=no; fi;
fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then find . -name Makefile -type f -exec sed -i "s/\${SHELL}/\/usr\/bin\/sh.exe/" "{}" + ; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then find . -name Makefile -type f -exec sed -i "s/\$(SHELL)/\/usr\/bin\/sh.exe/" "{}" + ; fi
- make
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then make install; else sudo make install; fi
- $buildshell make
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then sudo make install; else $buildshell make install; fi
- cd ..
- if [ "$BUILD_TYPE" = "asan" ]; then export CFLAGS='-fsanitize=address'; export CXXLAGS='-fsanitize=address'; export LDFLAGS='-fsanitize=address'; fi
- if [ "$BUILD_TYPE" = "msan" ]; then export CFLAGS='-fsanitize=memory'; export CXXLAGS='-fsanitize=memory'; export LDFLAGS='-fsanitize=memory'; fi
- if [ "$BUILD_TYPE" = "lsan" ]; then export CFLAGS='-fsanitize=leak'; export CXXLAGS='-fsanitize=leak'; export LDFLAGS='-fsanitize=leak'; fi
- if [ "$BUILD_TYPE" = "tsan" ]; then export CFLAGS='-fsanitize=thread'; export CXXLAGS='-fsanitize=thread'; export LDFLAGS='-fsanitize=thread'; fi
- if [ "$BUILD_TYPE" = "ubsan" ]; then export export CFLAGS='-fsanitize=undefined'; export CXXLAGS='-fsanitize=undefined'; export LDFLAGS='-fsanitize=undefined'; fi
install:
- ps -ef
- if [[ "$CROSS_COMPILE" == 1 ]] ; then
if [[ "$ARM_ARCH_DIR" == "aarch64-linux-gnu" ]] ; then
mkdir $HOME/linker_bin ;
Expand All @@ -71,35 +76,29 @@ install:
ls -al $HOME/linker_bin/ld ;
fi
fi
- ./bootstrap
- $buildshell ./bootstrap
- mkdir build
- cd build
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then
../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/' ;
cd .. ;
find . -name Makefile -type f -exec sed -i "s/\$(SHELL)/\/usr\/bin\/sh.exe/" "{}" + ;
cd build ;
elif [ "$LINKING" = "static" ]; then
../configure --enable-static --disable-fastopen;
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export MANIFEST_TOOL='no'; fi
- if [ "$LINKING" = "static" ]; then
$buildshell ../configure --enable-static --disable-fastopen;
elif [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ]; then
../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen;
$buildshell ../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen;
elif [ "$DEBUG" = "debug" ]; then
../configure --enable-debug --disable-shared --disable-fastopen;
$buildshell ../configure --enable-debug --disable-shared --disable-fastopen;
elif [ "$CROSS_COMPILE" = "1" ] && [ "$ARM_ARCH_DIR" = "aarch64-linux-gnu" ]; then
../configure --disable-fastopen --build `../config.guess` --host aarch64-linux-gnu CC="gcc -B$HOME/linker_bin" CXX="g++ -B$HOME/linker_bin";
$buildshell ../configure --disable-fastopen --build `../config.guess` --host aarch64-linux-gnu CC="gcc -B$HOME/linker_bin" CXX="g++ -B$HOME/linker_bin";
elif [ "$CROSS_COMPILE" = "1" ] && [ "$ARM_ARCH_DIR" = "arm-linux-gnueabi" ]; then
../configure --disable-fastopen --build `../config.guess` --host arm-linux-gnueabi;
$buildshell ../configure --disable-fastopen --build `../config.guess` --host arm-linux-gnueabi;
elif [ "$VALGRIND" = "valgrind" ]; then
../configure --enable-debug --disable-fastopen --disable-valgrind-helgrind --disable-valgrind-drd --disable-valgrind-sgcheck;
$buildshell ../configure --enable-debug --disable-fastopen --disable-valgrind-helgrind --disable-valgrind-drd --disable-valgrind-sgcheck;
else
../configure --disable-fastopen;
$buildshell ../configure --disable-fastopen;
fi
- if [ "$CROSS_COMPILE" = "1" ] && [ "$ARM_ARCH_DIR" = "aarch64-linux-gnu" ]; then sed -i 's+/usr/bin/ld+$HOME/linker_bin/ld+g' libtool; fi
- if [ "$CROSS_COMPILE" = "1" ] && [ "$ARM_ARCH_DIR" = "aarch64-linux-gnu" ]; then sed -i 's+/usr/bin/ld+$HOME/linker_bin/ld+g' Makefile; fi
- make
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then make check TESTS= ; fi
- $buildshell make
script:
- ps -ef
- if [[ "$CROSS_COMPILE" == 1 ]]; then
cd test ;
if [[ "$ARM_ARCH_DIR" == "aarch64-linux-gnu" ]]; then
Expand All @@ -120,8 +119,8 @@ script:
qemu-arm -L /usr/arm-linux-gnueabi/ ./.libs/threaded ;
fi
fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then make check ; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then cat test/test-suite.log; fi
- $buildshell make check
- $buildshell cat test/test-suite.log
- if [ "$VALGRIND" = "valgrind" ]; then make check-valgrind; fi;
- if [ "$VALGRIND" = "valgrind" ]; then cat test/test-suite-memcheck.log; fi;
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ../src/; cppcheck --error-exitcode=1 .; cd ../build; fi
Expand All @@ -144,19 +143,13 @@ script:
sleep 5 && ab -n 10000000 -c 100 localhost:8080/plaintext
fi
after_script:
- ps -ef
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then ps -Wla | sort ; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then gpgconf --kill gpg-agent ; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then taskkill //F //PID $(ps -Wla | tr -s ' ' | grep gpg | cut -f2 -d' ') ; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then ps -Wla | sort ; fi
- echo $$
after_success:
- if [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then bash <(curl -s https://codecov.io/bash); fi
matrix:
exclude:
- compiler: clang
env: DEBUG="debug" COVERAGE="coverage"
- os: windows
include:
- os: windows
env: DEBUG="nodebug" COVERAGE="nocoverage" YARN_GPG=no
Expand Down
16 changes: 8 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,14 @@ AC_SUBST(LDFLAGS)
AC_SUBST(EXT_LIB_PATH)
AC_SUBST(EXT_LIBS)

AC_CONFIG_LINKS([test/test_content:test/test_content])
AC_CONFIG_LINKS([test/cert.pem:test/cert.pem])
AC_CONFIG_LINKS([test/key.pem:test/key.pem])
AC_CONFIG_LINKS([test/test_root_ca.pem:test/test_root_ca.pem])
AC_CONFIG_LINKS([test/libhttpserver.supp:test/libhttpserver.supp])
AC_CONFIG_LINKS([examples/cert.pem:examples/cert.pem])
AC_CONFIG_LINKS([examples/key.pem:examples/key.pem])
AC_CONFIG_LINKS([examples/test_content:examples/test_content])
AC_CONFIG_FILES([test/test_content:test/test_content])
AC_CONFIG_FILES([test/cert.pem:test/cert.pem])
AC_CONFIG_FILES([test/key.pem:test/key.pem])
AC_CONFIG_FILES([test/test_root_ca.pem:test/test_root_ca.pem])
AC_CONFIG_FILES([test/libhttpserver.supp:test/libhttpserver.supp])
AC_CONFIG_FILES([examples/cert.pem:examples/cert.pem])
AC_CONFIG_FILES([examples/key.pem:examples/key.pem])
AC_CONFIG_FILES([examples/test_content:examples/test_content])

AC_OUTPUT(
libhttpserver.pc
Expand Down
5 changes: 1 addition & 4 deletions src/http_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include "httpserver/http_utils.hpp"

#if defined(__MINGW32__) || defined(__CYGWIN32__)
#define _WINDOWS
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x600
#include <winsock2.h>
#include <ws2tcpip.h>
#else
Expand All @@ -35,8 +32,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdexcept>
Expand Down
9 changes: 9 additions & 0 deletions src/httpserver/http_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#endif

// needed to force Vista as a bare minimum to have inet_ntop (libmicro defines
// this to include XP support as a lower version).
#if defined(__MINGW32__) || defined(__CYGWIN32__)
#define _WINDOWS
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x600
#endif

#include <microhttpd.h>
#include <algorithm>
#include <cctype>
Expand Down
37 changes: 31 additions & 6 deletions test/integ/authentication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
#include <ws2tcpip.h>
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#endif

#include <curl/curl.h>
#include <netinet/in.h>
#include <sys/socket.h>

#include "httpserver.hpp"
#include "littletest.hpp"
Expand All @@ -53,7 +53,7 @@ class user_pass_resource : public httpserver::http_resource
{
if (req.get_user() != "myuser" || req.get_pass() != "mypass")
{
return shared_ptr<basic_auth_fail_response>(new basic_auth_fail_response("FAIL", "test@example.com"));
return shared_ptr<basic_auth_fail_response>(new basic_auth_fail_response("FAIL", "examplerealm"));
}
return shared_ptr<string_response>(new string_response(req.get_user() + " " + req.get_pass(), 200, "text/plain"));
}
Expand All @@ -65,14 +65,14 @@ class digest_resource : public httpserver::http_resource
const shared_ptr<http_response> render_GET(const http_request& req)
{
if (req.get_digested_user() == "") {
return shared_ptr<digest_auth_fail_response>(new digest_auth_fail_response("FAIL", "test@example.com", MY_OPAQUE, true));
return shared_ptr<digest_auth_fail_response>(new digest_auth_fail_response("FAIL", "examplerealm", MY_OPAQUE, true));
}
else
{
bool reload_nonce = false;
if(!req.check_digest_auth("test@example.com", "mypass", 300, reload_nonce))
if(!req.check_digest_auth("examplerealm", "mypass", 300, reload_nonce))
{
return shared_ptr<digest_auth_fail_response>(new digest_auth_fail_response("FAIL", "test@example.com", MY_OPAQUE, reload_nonce));
return shared_ptr<digest_auth_fail_response>(new digest_auth_fail_response("FAIL", "examplerealm", MY_OPAQUE, reload_nonce));
}
}
return shared_ptr<string_response>(new string_response("SUCCESS", 200, "text/plain"));
Expand Down Expand Up @@ -139,6 +139,11 @@ LT_BEGIN_AUTO_TEST(authentication_suite, base_auth_fail)
ws.stop();
LT_END_AUTO_TEST(base_auth_fail)

// do not run the digest auth tests on windows as curl
// appears to have problems with it.
// Will fix this separately
#ifndef _WINDOWS

LT_BEGIN_AUTO_TEST(authentication_suite, digest_auth)
webserver ws = create_webserver(8080)
.digest_auth_random("myrandom")
Expand All @@ -148,12 +153,21 @@ LT_BEGIN_AUTO_TEST(authentication_suite, digest_auth)
ws.register_resource("base", &digest);
ws.start(false);

#if defined(_WINDOWS)
curl_global_init(CURL_GLOBAL_WIN32 );
#else
curl_global_init(CURL_GLOBAL_ALL);
#endif

std::string s;
CURL *curl = curl_easy_init();
CURLcode res;
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
#if defined(_WINDOWS)
curl_easy_setopt(curl, CURLOPT_USERPWD, "examplerealm/myuser:mypass");
#else
curl_easy_setopt(curl, CURLOPT_USERPWD, "myuser:mypass");
#endif
curl_easy_setopt(curl, CURLOPT_URL, "localhost:8080/base");
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
Expand All @@ -179,12 +193,21 @@ LT_BEGIN_AUTO_TEST(authentication_suite, digest_auth_wrong_pass)
ws.register_resource("base", &digest);
ws.start(false);

#if defined(_WINDOWS)
curl_global_init(CURL_GLOBAL_WIN32 );
#else
curl_global_init(CURL_GLOBAL_ALL);
#endif

std::string s;
CURL *curl = curl_easy_init();
CURLcode res;
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
#if defined(_WINDOWS)
curl_easy_setopt(curl, CURLOPT_USERPWD, "examplerealm/myuser:wrongpass");
#else
curl_easy_setopt(curl, CURLOPT_USERPWD, "myuser:wrongpass");
#endif
curl_easy_setopt(curl, CURLOPT_URL, "localhost:8080/base");
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
Expand All @@ -201,6 +224,8 @@ LT_BEGIN_AUTO_TEST(authentication_suite, digest_auth_wrong_pass)
ws.stop();
LT_END_AUTO_TEST(digest_auth_wrong_pass)

#endif

LT_BEGIN_AUTO_TEST_ENV()
AUTORUN_TESTS()
LT_END_AUTO_TEST_ENV()
4 changes: 2 additions & 2 deletions test/integ/deferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
#include <ws2tcpip.h>
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#endif

#include <curl/curl.h>
#include <netinet/in.h>
#include <signal.h>
#include <sys/socket.h>
#include <unistd.h>

#include "httpserver.hpp"
Expand Down
5 changes: 3 additions & 2 deletions test/integ/ws_start_stop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
#include <ws2tcpip.h>
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#endif

#include <curl/curl.h>
#include <netinet/in.h>
#include <pthread.h>
#include <sys/socket.h>
#include <unistd.h>

#include "httpserver.hpp"
#include "littletest.hpp"
Expand Down
X Tutup