From 3c400f4f0224b43d6b236355dd7519a4c5f35890 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Thu, 4 Jan 2018 10:57:57 +0100 Subject: [PATCH 1/7] Add PlatformCheck class, for runtime platform detection. --- src/PlatformCheck.cpp | 20 ++++++++++++++++++++ src/PlatformCheck.h | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/PlatformCheck.cpp create mode 100644 src/PlatformCheck.h diff --git a/src/PlatformCheck.cpp b/src/PlatformCheck.cpp new file mode 100644 index 000000000..9519e76c1 --- /dev/null +++ b/src/PlatformCheck.cpp @@ -0,0 +1,20 @@ +// Copyright 2005-2018 The Mumble Developers. All rights reserved. +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file at the root of the +// Mumble source tree or at . + +#include "murmur_pch.h" + +#include + +#include "PlatformCheck.h" + +bool PlatformCheck::IsWine() { +#ifdef Q_OS_WIN + void *ptr = QLibrary::resolve(QLatin1String("ntdll.dll"), "wine_get_version"); + if (ptr != NULL) { + return true; + } +#endif + return false; +} diff --git a/src/PlatformCheck.h b/src/PlatformCheck.h new file mode 100644 index 000000000..b6e9c28b4 --- /dev/null +++ b/src/PlatformCheck.h @@ -0,0 +1,16 @@ +// Copyright 2005-2018 The Mumble Developers. All rights reserved. +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file at the root of the +// Mumble source tree or at . + +#ifndef MUMBLE_PLATFORMCHECK_H_ +#define MUMBLE_PLATFORMCHECK_H_ + +/// PlatformCheck performs platform checks. +class PlatformCheck { + public: + /// IsWine returns true when running under Wine. + static bool IsWine(); +}; + +#endif From 29ebd2beffaecc40428de19d56b83aedb8d8ebb2 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Thu, 4 Jan 2018 10:58:19 +0100 Subject: [PATCH 2/7] Build PlatformCheck into all test binaries. --- src/tests/test.pri | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/test.pri b/src/tests/test.pri index ad543a977..653d31515 100644 --- a/src/tests/test.pri +++ b/src/tests/test.pri @@ -27,6 +27,9 @@ LANGUAGE = C++ VPATH *= ../.. ../../murmur ../../mumble INCLUDEPATH *= ../.. ../../murmur ../../mumble +SOURCES += PlatformCheck.cpp +HEADERS += PlatformCheck.h + # We have to depend on OpenSSL in all tests # for no-pch builds to work. Our PCH headers # include OpenSSL, and if the headers aren't From 5192831bc6f2e4a4d8a42cd09ac6d68de34fd356 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Thu, 4 Jan 2018 11:19:50 +0100 Subject: [PATCH 3/7] src/tests: update .pro files to append to SOURCES and HEADERS instead of overwriting them. Now that test.pri adds source files and headers by default, the .pro files of our tests need to append to SOURCES and HEADERS to ensure everything test.pri adds to SOURCES and HEADERS are kept around. --- src/tests/TestCrypt/TestCrypt.pro | 4 ++-- src/tests/TestCryptographicHash/TestCryptographicHash.pro | 4 ++-- src/tests/TestCryptographicRandom/TestCryptographicRandom.pro | 4 ++-- src/tests/TestFFDHE/TestFFDHE.pro | 4 ++-- src/tests/TestPacketDataStream/TestPacketDataStream.pro | 2 +- src/tests/TestPasswordGenerator/TestPasswordGenerator.pro | 4 ++-- src/tests/TestSSLLocks/TestSSLLocks.pro | 4 ++-- .../TestSelfSignedCertificate/TestSelfSignedCertificate.pro | 4 ++-- src/tests/TestServerAddress/TestServerAddress.pro | 4 ++-- src/tests/TestServerResolver/TestServerResolver.pro | 4 ++-- src/tests/TestStdAbs/TestStdAbs.pro | 2 +- src/tests/TestTimer/TestTimer.pro | 4 ++-- .../TestUnresolvedServerAddress.pro | 4 ++-- src/tests/TestXMLTools/TestXMLTools.pro | 4 ++-- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/tests/TestCrypt/TestCrypt.pro b/src/tests/TestCrypt/TestCrypt.pro index 3d9fa5540..2f61dc03d 100644 --- a/src/tests/TestCrypt/TestCrypt.pro +++ b/src/tests/TestCrypt/TestCrypt.pro @@ -8,5 +8,5 @@ include(../test.pri) QT *= network TARGET = TestCrypt -HEADERS = SSL.h SSLLocks.h Timer.h CryptState.h -SOURCES = SSL.cpp SSLLocks.cpp TestCrypt.cpp CryptState.cpp Timer.cpp +HEADERS *= SSL.h SSLLocks.h Timer.h CryptState.h +SOURCES *= SSL.cpp SSLLocks.cpp TestCrypt.cpp CryptState.cpp Timer.cpp diff --git a/src/tests/TestCryptographicHash/TestCryptographicHash.pro b/src/tests/TestCryptographicHash/TestCryptographicHash.pro index fd6e5d7cf..debc78e86 100644 --- a/src/tests/TestCryptographicHash/TestCryptographicHash.pro +++ b/src/tests/TestCryptographicHash/TestCryptographicHash.pro @@ -8,5 +8,5 @@ include(../test.pri) QT += network TARGET = TestCryptographicHash -SOURCES = SSL.cpp SSLLocks.cpp TestCryptographicHash.cpp CryptographicHash.cpp -HEADERS = SSL.h SSLLocks.h CryptographicHash.h +SOURCES *= SSL.cpp SSLLocks.cpp TestCryptographicHash.cpp CryptographicHash.cpp +HEADERS *= SSL.h SSLLocks.h CryptographicHash.h diff --git a/src/tests/TestCryptographicRandom/TestCryptographicRandom.pro b/src/tests/TestCryptographicRandom/TestCryptographicRandom.pro index b38a3818d..5d3edddf1 100644 --- a/src/tests/TestCryptographicRandom/TestCryptographicRandom.pro +++ b/src/tests/TestCryptographicRandom/TestCryptographicRandom.pro @@ -8,8 +8,8 @@ include(../test.pri) QT += network TARGET = TestCryptographicRandom -SOURCES = SSL.cpp SSLLocks.cpp TestCryptographicRandom.cpp CryptographicRandom.cpp arc4random_uniform.cpp -HEADERS = SSL.h SSLLocks.h CryptographicHash.h +SOURCES *= SSL.cpp SSLLocks.cpp TestCryptographicRandom.cpp CryptographicRandom.cpp arc4random_uniform.cpp +HEADERS *= SSL.h SSLLocks.h CryptographicHash.h VPATH *= ../../../3rdparty/arc4random-src INCLUDEPATH *= ../../../3rdparty/arc4random-src diff --git a/src/tests/TestFFDHE/TestFFDHE.pro b/src/tests/TestFFDHE/TestFFDHE.pro index 56d11a4eb..862ec15bf 100644 --- a/src/tests/TestFFDHE/TestFFDHE.pro +++ b/src/tests/TestFFDHE/TestFFDHE.pro @@ -16,5 +16,5 @@ QT += network } TARGET = TestFFDHE -SOURCES = SSL.cpp SSLLocks.cpp FFDHE.cpp TestFFDHE.cpp -HEADERS = SSL.h SSLLocks.h FFDHE.h FFDHETable.h +SOURCES *= SSL.cpp SSLLocks.cpp FFDHE.cpp TestFFDHE.cpp +HEADERS *= SSL.h SSLLocks.h FFDHE.h FFDHETable.h diff --git a/src/tests/TestPacketDataStream/TestPacketDataStream.pro b/src/tests/TestPacketDataStream/TestPacketDataStream.pro index dbbbaa3a3..bc307ec9b 100644 --- a/src/tests/TestPacketDataStream/TestPacketDataStream.pro +++ b/src/tests/TestPacketDataStream/TestPacketDataStream.pro @@ -8,4 +8,4 @@ include(../test.pri) QT *= network TARGET = TestPacketDataStream -SOURCES = TestPacketDataStream.cpp +SOURCES *= TestPacketDataStream.cpp diff --git a/src/tests/TestPasswordGenerator/TestPasswordGenerator.pro b/src/tests/TestPasswordGenerator/TestPasswordGenerator.pro index c08aad494..7a709d48c 100644 --- a/src/tests/TestPasswordGenerator/TestPasswordGenerator.pro +++ b/src/tests/TestPasswordGenerator/TestPasswordGenerator.pro @@ -8,8 +8,8 @@ include(../test.pri) QT += network TARGET = TestPasswordGenerator -SOURCES = SSL.cpp SSLLocks.cpp TestPasswordGenerator.cpp PasswordGenerator.cpp CryptographicRandom.cpp arc4random_uniform.cpp -HEADERS = SSL.h SSLLocks.h PasswordGenerator.h CryptographicHash.h +SOURCES *= SSL.cpp SSLLocks.cpp TestPasswordGenerator.cpp PasswordGenerator.cpp CryptographicRandom.cpp arc4random_uniform.cpp +HEADERS *= SSL.h SSLLocks.h PasswordGenerator.h CryptographicHash.h VPATH *= ../../../3rdparty/arc4random-src INCLUDEPATH *= ../../../3rdparty/arc4random-src diff --git a/src/tests/TestSSLLocks/TestSSLLocks.pro b/src/tests/TestSSLLocks/TestSSLLocks.pro index 1fd3dfdfa..e6be0c5e2 100644 --- a/src/tests/TestSSLLocks/TestSSLLocks.pro +++ b/src/tests/TestSSLLocks/TestSSLLocks.pro @@ -8,5 +8,5 @@ include(../test.pri) QT += network TARGET = TestSSLLocks -SOURCES = SSL.cpp SSLLocks.cpp TestSSLLocks.cpp -HEADERS = SSL.h SSLLocks.h +SOURCES *= SSL.cpp SSLLocks.cpp TestSSLLocks.cpp +HEADERS *= SSL.h SSLLocks.h diff --git a/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.pro b/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.pro index 7412d15ee..375fecd2b 100644 --- a/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.pro +++ b/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.pro @@ -9,5 +9,5 @@ include(../../../qmake/qt.pri) QT *= network TARGET = TestSelfSignedCertificate -SOURCES = SSL.cpp SSLLocks.cpp TestSelfSignedCertificate.cpp SelfSignedCertificate.cpp -HEADERS = SSL.h SSLLocks.h SelfSignedCertificate.h +SOURCES *= SSL.cpp SSLLocks.cpp TestSelfSignedCertificate.cpp SelfSignedCertificate.cpp +HEADERS *= SSL.h SSLLocks.h SelfSignedCertificate.h diff --git a/src/tests/TestServerAddress/TestServerAddress.pro b/src/tests/TestServerAddress/TestServerAddress.pro index 738b2594e..e045c1e17 100644 --- a/src/tests/TestServerAddress/TestServerAddress.pro +++ b/src/tests/TestServerAddress/TestServerAddress.pro @@ -8,5 +8,5 @@ include(../test.pri) QT += network TARGET = TestServerAddress -SOURCES = TestServerAddress.cpp ServerAddress.cpp HostAddress.cpp -HEADERS = ServerAddress.h HostAddress.h +SOURCES *= TestServerAddress.cpp ServerAddress.cpp HostAddress.cpp +HEADERS *= ServerAddress.h HostAddress.h diff --git a/src/tests/TestServerResolver/TestServerResolver.pro b/src/tests/TestServerResolver/TestServerResolver.pro index 73f7cbc8a..b0c4c73bb 100644 --- a/src/tests/TestServerResolver/TestServerResolver.pro +++ b/src/tests/TestServerResolver/TestServerResolver.pro @@ -9,8 +9,8 @@ include(../../../qmake/qt.pri) QT *= network TARGET = TestServerResolver -SOURCES = TestServerResolver.cpp HostAddress.cpp ServerResolver_qt5.cpp ServerResolverRecord.cpp -HEADERS = HostAddress.h ServerResolver.h ServerResolverRecord.h +SOURCES *= TestServerResolver.cpp HostAddress.cpp ServerResolver_qt5.cpp ServerResolverRecord.cpp +HEADERS *= HostAddress.h ServerResolver.h ServerResolverRecord.h isEqual(QT_MAJOR_VERSION, 4) { CONFIG *= no-srv diff --git a/src/tests/TestStdAbs/TestStdAbs.pro b/src/tests/TestStdAbs/TestStdAbs.pro index ce3a36107..0164085f2 100644 --- a/src/tests/TestStdAbs/TestStdAbs.pro +++ b/src/tests/TestStdAbs/TestStdAbs.pro @@ -6,4 +6,4 @@ include(../test.pri) TARGET = TestStdAbs -SOURCES = TestStdAbs.cpp +SOURCES *= TestStdAbs.cpp diff --git a/src/tests/TestTimer/TestTimer.pro b/src/tests/TestTimer/TestTimer.pro index 31fa522ee..1318a74ad 100644 --- a/src/tests/TestTimer/TestTimer.pro +++ b/src/tests/TestTimer/TestTimer.pro @@ -6,5 +6,5 @@ include(../test.pri) TARGET = TestTimer -SOURCES = TestTimer.cpp Timer.cpp -HEADERS = Timer.h +SOURCES *= TestTimer.cpp Timer.cpp +HEADERS *= Timer.h diff --git a/src/tests/TestUnresolvedServerAddress/TestUnresolvedServerAddress.pro b/src/tests/TestUnresolvedServerAddress/TestUnresolvedServerAddress.pro index 09d315ae3..c26663abb 100644 --- a/src/tests/TestUnresolvedServerAddress/TestUnresolvedServerAddress.pro +++ b/src/tests/TestUnresolvedServerAddress/TestUnresolvedServerAddress.pro @@ -6,5 +6,5 @@ include(../test.pri) TARGET = TestUnresolvedServerAddress -SOURCES = TestUnresolvedServerAddress.cpp UnresolvedServerAddress.cpp -HEADERS = UnresolvedServerAddress.h +SOURCES *= TestUnresolvedServerAddress.cpp UnresolvedServerAddress.cpp +HEADERS *= UnresolvedServerAddress.h diff --git a/src/tests/TestXMLTools/TestXMLTools.pro b/src/tests/TestXMLTools/TestXMLTools.pro index 6884329d5..53396c666 100644 --- a/src/tests/TestXMLTools/TestXMLTools.pro +++ b/src/tests/TestXMLTools/TestXMLTools.pro @@ -6,5 +6,5 @@ include(../test.pri) TARGET = TestXMLTools -HEADERS = XMLTools.h -SOURCES = TestXMLTools.cpp XMLTools.cpp +HEADERS *= XMLTools.h +SOURCES *= TestXMLTools.cpp XMLTools.cpp From f0c2d8b1fcedba2ffd2f8aab7ebf3b61b7d6cd37 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Thu, 4 Jan 2018 10:58:34 +0100 Subject: [PATCH 4/7] TestServerResolver: skip SRV tests when running on Wine. --- src/tests/TestServerResolver/TestServerResolver.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tests/TestServerResolver/TestServerResolver.cpp b/src/tests/TestServerResolver/TestServerResolver.cpp index 3f85dac71..b5ecb62fe 100644 --- a/src/tests/TestServerResolver/TestServerResolver.cpp +++ b/src/tests/TestServerResolver/TestServerResolver.cpp @@ -8,6 +8,7 @@ #include #include "ServerResolver.h" +#include "PlatformCheck.h" void signalSpyWait(QSignalSpy &spy) { // We increase the timeout from 5s to 8s because travis builds could fail otherwise (slow network response). @@ -36,6 +37,11 @@ void TestServerResolver::simpleSrv() { return; #endif + // Qt 5's SRV resolver does not work in Wine. + if (PlatformCheck::IsWine()) { + return; + } + ServerResolver r; QSignalSpy spy(&r, SIGNAL(resolved())); @@ -83,6 +89,11 @@ void TestServerResolver::srvCustomPort() { return; #endif + // Qt 5's SRV resolver does not work in Wine. + if (PlatformCheck::IsWine()) { + return; + } + ServerResolver r; QSignalSpy spy(&r, SIGNAL(resolved())); From 159be4bc4cd1a75747154e9f9a789225083a1706 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Thu, 4 Jan 2018 12:09:39 +0100 Subject: [PATCH 5/7] PlatformCheck: do not assign QLibrary::resolve() retval to variable for wider compatibility. Qt 4 uses 'void *' for this, Qt 5 uses QFunctionPointer -- a typedef to 'void (*)()'. --- src/PlatformCheck.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PlatformCheck.cpp b/src/PlatformCheck.cpp index 9519e76c1..b6ebc5764 100644 --- a/src/PlatformCheck.cpp +++ b/src/PlatformCheck.cpp @@ -11,8 +11,7 @@ bool PlatformCheck::IsWine() { #ifdef Q_OS_WIN - void *ptr = QLibrary::resolve(QLatin1String("ntdll.dll"), "wine_get_version"); - if (ptr != NULL) { + if (QLibrary::resolve(QLatin1String("ntdll.dll"), "wine_get_version") != NULL) { return true; } #endif From 3dd8f1d980443a4bdfae6fff9116ae5bce45e428 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Thu, 4 Jan 2018 16:58:02 +0100 Subject: [PATCH 6/7] PlatformCheck: add a reference to the Wine wiki for our Wine detection code. --- src/PlatformCheck.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PlatformCheck.cpp b/src/PlatformCheck.cpp index b6ebc5764..8335fb055 100644 --- a/src/PlatformCheck.cpp +++ b/src/PlatformCheck.cpp @@ -11,6 +11,8 @@ bool PlatformCheck::IsWine() { #ifdef Q_OS_WIN + // Detect if we're running under Wine. + // For more info, see https://wiki.winehq.org/Developer_FAQ#How_can_I_detect_Wine.3F if (QLibrary::resolve(QLatin1String("ntdll.dll"), "wine_get_version") != NULL) { return true; } From 28f55afc348f96783ee330977c0bec4c4275be69 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Thu, 4 Jan 2018 22:53:46 +0100 Subject: [PATCH 7/7] TestServerResolver: reference upstream WineHQ bug in tests skipped on Wine. --- src/tests/TestServerResolver/TestServerResolver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tests/TestServerResolver/TestServerResolver.cpp b/src/tests/TestServerResolver/TestServerResolver.cpp index b5ecb62fe..484b617c6 100644 --- a/src/tests/TestServerResolver/TestServerResolver.cpp +++ b/src/tests/TestServerResolver/TestServerResolver.cpp @@ -38,6 +38,7 @@ void TestServerResolver::simpleSrv() { #endif // Qt 5's SRV resolver does not work in Wine. + // For more info, see https://bugs.winehq.org/show_bug.cgi?id=44296 if (PlatformCheck::IsWine()) { return; } @@ -90,6 +91,7 @@ void TestServerResolver::srvCustomPort() { #endif // Qt 5's SRV resolver does not work in Wine. + // For more info, see https://bugs.winehq.org/show_bug.cgi?id=44296 if (PlatformCheck::IsWine()) { return; }