From 81a07b069a126244944962932928236c0c585658 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Sun, 4 Jan 2015 16:11:27 +0000 Subject: Skip the constructByInfo() test if no serial ports are found on *nix In unix-like systems it is possible to use socat to creation of the virtual serial ports. But these devices are symlinks on the /dev/pts devices, that is not a serial ports. Thus QSPI can not find it and will construct a null object. In this case this is not an error and we need just to skip test. Change-Id: I59bbb3c4653555be39ea6fff903c386065c10d0a Reviewed-by: Sergey Belyashov --- tests/auto/qserialport/tst_qserialport.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/auto/qserialport/tst_qserialport.cpp b/tests/auto/qserialport/tst_qserialport.cpp index f34b939..e064333 100644 --- a/tests/auto/qserialport/tst_qserialport.cpp +++ b/tests/auto/qserialport/tst_qserialport.cpp @@ -234,9 +234,23 @@ void tst_QSerialPort::constructByName() void tst_QSerialPort::constructByInfo() { QSerialPortInfo senderPortInfo(m_senderPortName); + QSerialPortInfo receiverPortInfo(m_receiverPortName); + +#if defined(Q_OS_UNIX) + if (senderPortInfo.isNull() || receiverPortInfo.isNull()) { + static const char message[] = + "Test doesn't work because the specified serial ports aren't" + " found in system and can't be constructed by QSerialPortInfo.\n"; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + QSKIP(message); +#else + QSKIP(message, SkipAll); +#endif + } +#endif + QSerialPort serialPort(senderPortInfo); QCOMPARE(serialPort.portName(), m_senderPortName); - QSerialPortInfo receiverPortInfo(m_receiverPortName); serialPort.setPort(receiverPortInfo); QCOMPARE(serialPort.portName(), m_receiverPortName); } -- cgit v1.2.1