mirror of
https://github.com/znc/znc.git
synced 2026-08-09 18:32:55 +02:00
Switch integration test to mostly use unix sockets
By not using the same hardcoded number for every test, we can parallelize the test now. There are several cases remaining where we can't easily use unix sockets (e.g. QSslSocket or imapauth module), for that ask kernel what port number is currently free to use. This is a bit racy though.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QProcess>
|
||||
#include <QLocalSocket>
|
||||
#include <QTcpSocket>
|
||||
|
||||
#include <memory>
|
||||
@@ -49,6 +50,7 @@ class IO {
|
||||
// Need to flush QTcpSocket, and QIODevice doesn't have flush at all...
|
||||
static void FlushIfCan(QIODevice*) {}
|
||||
static void FlushIfCan(QTcpSocket* sock) { sock->flush(); }
|
||||
static void FlushIfCan(QLocalSocket* sock) { sock->flush(); }
|
||||
|
||||
Device* m_device;
|
||||
bool m_verbose;
|
||||
@@ -60,7 +62,7 @@ IO<Device> WrapIO(Device* d) {
|
||||
return IO<Device>(d);
|
||||
}
|
||||
|
||||
using Socket = IO<QTcpSocket>;
|
||||
using Socket = IO<QLocalSocket>;
|
||||
|
||||
class Process : public IO<QProcess> {
|
||||
public:
|
||||
@@ -202,6 +204,9 @@ void IO<Device>::Write(QByteArray s, bool new_line) {
|
||||
FlushIfCan(m_device);
|
||||
}
|
||||
|
||||
inline void DisconnectFromServer(QTcpSocket* s) { s->disconnectFromHost(); }
|
||||
inline void DisconnectFromServer(QLocalSocket* s) { s->disconnectFromServer(); }
|
||||
|
||||
template <typename Device>
|
||||
void IO<Device>::Close() {
|
||||
#ifdef __CYGWIN__
|
||||
@@ -209,8 +214,10 @@ void IO<Device>::Close() {
|
||||
// without this line
|
||||
sleep(1);
|
||||
#endif
|
||||
m_device->disconnectFromHost();
|
||||
DisconnectFromServer(m_device);
|
||||
}
|
||||
|
||||
int PickPortNumber();
|
||||
|
||||
} // namespace znc_inttest
|
||||
|
||||
|
||||
Reference in New Issue
Block a user