summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2014-11-24 18:21:57 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2014-11-27 11:19:43 +0100
commitab51ad6a5f4e533c31bd8e5b6f16a3bcd09a3ee6 (patch)
tree783f2a4cccc2fcc420bef5557bf8b47aa10049d6
parenta00cbfb7f336a56b9ae2235c44149ec63ced9ee5 (diff)
downloadqtserialport-ab51ad6a5f4e533c31bd8e5b6f16a3bcd09a3ee6.tar.gz
Allow to use custom devices paths
QSP incorrectly transforms non-standard device names to their paths and vice-versa (for example, "/home/ttyS0", "//./COM1", and so on). Now this problem is solved: * The transformation code is moved to QSPP. * Added autotests auto/qserialportinfoprivate to testing of conversion algorithm. These tests are private and can be activated with building of QtSerialPort with: qmake "QT_CONFIG+=private_tests warnings_are_errors" \ DEFINES+=QT_BUILD_INTERNAL Tested on Windows 8, Linux, OSX with auto-tests, with on-board and virtual serial ports. Task-number: QTBUG-38639 Change-Id: I43757a7f1390f53ed2b1d70de59c6bfb71892a59 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
-rw-r--r--src/serialport/qserialport.cpp18
-rw-r--r--src/serialport/qserialport_unix.cpp35
-rw-r--r--src/serialport/qserialport_unix_p.h3
-rw-r--r--src/serialport/qserialport_win.cpp18
-rw-r--r--src/serialport/qserialport_win_p.h3
-rw-r--r--src/serialport/qserialport_wince.cpp16
-rw-r--r--src/serialport/qserialport_wince_p.h3
-rw-r--r--src/serialport/qserialportinfo_mac.cpp14
-rw-r--r--src/serialport/qserialportinfo_p.h12
-rw-r--r--src/serialport/qserialportinfo_unix.cpp18
-rw-r--r--src/serialport/qserialportinfo_win.cpp23
-rw-r--r--src/serialport/qserialportinfo_wince.cpp14
-rw-r--r--tests/auto/auto.pro5
-rw-r--r--tests/auto/qserialportinfoprivate/qserialportinfoprivate.pro4
-rw-r--r--tests/auto/qserialportinfoprivate/tst_qserialportinfoprivate.cpp110
15 files changed, 196 insertions, 100 deletions
diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp
index 82bcde3..2bd7c69 100644
--- a/src/serialport/qserialport.cpp
+++ b/src/serialport/qserialport.cpp
@@ -36,6 +36,7 @@
#include "qserialport.h"
#include "qserialportinfo.h"
+#include "qserialportinfo_p.h"
#ifdef Q_OS_WINCE
#include "qserialport_wince_p.h"
@@ -435,7 +436,7 @@ QSerialPort::~QSerialPort()
void QSerialPort::setPortName(const QString &name)
{
Q_D(QSerialPort);
- d->systemLocation = QSerialPortPrivate::portNameToSystemLocation(name);
+ d->systemLocation = QSerialPortInfoPrivate::portNameToSystemLocation(name);
}
/*!
@@ -446,7 +447,7 @@ void QSerialPort::setPortName(const QString &name)
void QSerialPort::setPort(const QSerialPortInfo &serialPortInfo)
{
Q_D(QSerialPort);
- d->systemLocation = QSerialPortPrivate::portNameToSystemLocation(serialPortInfo.systemLocation());
+ d->systemLocation = serialPortInfo.systemLocation();
}
/*!
@@ -460,7 +461,7 @@ void QSerialPort::setPort(const QSerialPortInfo &serialPortInfo)
\li Brief Description
\row
\li Windows
- \li Removes the prefix "\\\\.\\" from the system location
+ \li Removes the prefix "\\\\.\\" or "//./" from the system location
and returns the remainder of the string.
\row
\li Windows CE
@@ -471,16 +472,9 @@ void QSerialPort::setPort(const QSerialPortInfo &serialPortInfo)
\li Returns the system location as it is,
as it is equivalent to the port name.
\row
- \li GNU/Linux
+ \li Unix, BSD
\li Removes the prefix "/dev/" from the system location
and returns the remainder of the string.
- \row
- \li Mac OSX
- \li Removes the prefix "/dev/cu." and "/dev/tty." from the
- system location and returns the remainder of the string.
- \row
- \li Other *nix
- \li The same as for GNU/Linux.
\endtable
\sa setPort(), QSerialPortInfo::portName()
@@ -488,7 +482,7 @@ void QSerialPort::setPort(const QSerialPortInfo &serialPortInfo)
QString QSerialPort::portName() const
{
Q_D(const QSerialPort);
- return QSerialPortPrivate::portNameFromSystemLocation(d->systemLocation);
+ return QSerialPortInfoPrivate::portNameFromSystemLocation(d->systemLocation);
}
/*!
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index c836eb2..599f151 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -34,6 +34,7 @@
****************************************************************************/
#include "qserialport_unix_p.h"
+#include "qserialportinfo_p.h"
#include <errno.h>
#include <sys/time.h>
@@ -163,7 +164,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
{
Q_Q(QSerialPort);
- QString lockFilePath = serialPortLockFilePath(portNameFromSystemLocation(systemLocation));
+ QString lockFilePath = serialPortLockFilePath(QSerialPortInfoPrivate::portNameFromSystemLocation(systemLocation));
bool isLockFileEmpty = lockFilePath.isEmpty();
if (isLockFileEmpty) {
qWarning("Failed to create a lock file for opening the device");
@@ -1156,38 +1157,6 @@ qint64 QSerialPortPrivate::readPerChar(char *data, qint64 maxSize)
return ret;
}
-#ifdef Q_OS_MAC
-static const QString defaultFilePathPrefix = QStringLiteral("/dev/cu.");
-static const QString unusedFilePathPrefix = QStringLiteral("/dev/tty.");
-#else
-static const QString defaultFilePathPrefix = QStringLiteral("/dev/");
-#endif
-
-QString QSerialPortPrivate::portNameToSystemLocation(const QString &port)
-{
- QString ret = port;
-
-#ifdef Q_OS_MAC
- ret.remove(unusedFilePathPrefix);
-#endif
-
- if (!ret.contains(defaultFilePathPrefix))
- ret.prepend(defaultFilePathPrefix);
- return ret;
-}
-
-QString QSerialPortPrivate::portNameFromSystemLocation(const QString &location)
-{
- QString ret = location;
-
-#ifdef Q_OS_MAC
- ret.remove(unusedFilePathPrefix);
-#endif
-
- ret.remove(defaultFilePathPrefix);
- return ret;
-}
-
typedef QMap<qint32, qint32> BaudRateMap;
// The OS specific defines can be found in termios.h
diff --git a/src/serialport/qserialport_unix_p.h b/src/serialport/qserialport_unix_p.h
index 1cc767d..f1821ea 100644
--- a/src/serialport/qserialport_unix_p.h
+++ b/src/serialport/qserialport_unix_p.h
@@ -131,9 +131,6 @@ public:
qint64 bytesToWrite() const;
qint64 writeData(const char *data, qint64 maxSize);
- static QString portNameToSystemLocation(const QString &port);
- static QString portNameFromSystemLocation(const QString &location);
-
static qint32 baudRateFromSetting(qint32 setting);
static qint32 settingFromBaudRate(qint32 baudRate);
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index 5a2cf8e..7b7405e 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -900,24 +900,6 @@ bool QSerialPortPrivate::waitAnyEvent(int msecs, bool *timedOut, HANDLE *trigger
return true;
}
-static const QString defaultPathPrefix = QStringLiteral("\\\\.\\");
-
-QString QSerialPortPrivate::portNameToSystemLocation(const QString &port)
-{
- QString ret = port;
- if (!ret.contains(defaultPathPrefix))
- ret.prepend(defaultPathPrefix);
- return ret;
-}
-
-QString QSerialPortPrivate::portNameFromSystemLocation(const QString &location)
-{
- QString ret = location;
- if (ret.contains(defaultPathPrefix))
- ret.remove(defaultPathPrefix);
- return ret;
-}
-
// This table contains standard values of baud rates that
// are defined in MSDN and/or in Win SDK file winbase.h
diff --git a/src/serialport/qserialport_win_p.h b/src/serialport/qserialport_win_p.h
index 78529e8..1e941a0 100644
--- a/src/serialport/qserialport_win_p.h
+++ b/src/serialport/qserialport_win_p.h
@@ -108,9 +108,6 @@ public:
qint64 bytesToWrite() const;
qint64 writeData(const char *data, qint64 maxSize);
- static QString portNameToSystemLocation(const QString &port);
- static QString portNameFromSystemLocation(const QString &location);
-
static qint32 baudRateFromSetting(qint32 setting);
static qint32 settingFromBaudRate(qint32 baudRate);
diff --git a/src/serialport/qserialport_wince.cpp b/src/serialport/qserialport_wince.cpp
index ee5d395..04c09b1 100644
--- a/src/serialport/qserialport_wince.cpp
+++ b/src/serialport/qserialport_wince.cpp
@@ -766,22 +766,6 @@ bool QSerialPortPrivate::waitForReadOrWrite(bool *selectForRead, bool *selectFor
return false;
}
-QString QSerialPortPrivate::portNameToSystemLocation(const QString &port)
-{
- QString ret = port;
- if (!ret.contains(QLatin1Char(':')))
- ret.append(QLatin1Char(':'));
- return ret;
-}
-
-QString QSerialPortPrivate::portNameFromSystemLocation(const QString &location)
-{
- QString ret = location;
- if (ret.contains(QLatin1Char(':')))
- ret.remove(QLatin1Char(':'));
- return ret;
-}
-
static const QList<qint32> standardBaudRatePairList()
{
diff --git a/src/serialport/qserialport_wince_p.h b/src/serialport/qserialport_wince_p.h
index dedd4b1..3fc4e23 100644
--- a/src/serialport/qserialport_wince_p.h
+++ b/src/serialport/qserialport_wince_p.h
@@ -99,9 +99,6 @@ public:
qint64 bytesToWrite() const;
qint64 writeData(const char *data, qint64 maxSize);
- static QString portNameToSystemLocation(const QString &port);
- static QString portNameFromSystemLocation(const QString &location);
-
static qint32 baudRateFromSetting(qint32 setting);
static qint32 settingFromBaudRate(qint32 baudRate);
diff --git a/src/serialport/qserialportinfo_mac.cpp b/src/serialport/qserialportinfo_mac.cpp
index 3685d55..54abe21 100644
--- a/src/serialport/qserialportinfo_mac.cpp
+++ b/src/serialport/qserialportinfo_mac.cpp
@@ -242,4 +242,18 @@ bool QSerialPortInfo::isValid() const
return f.exists();
}
+QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
+{
+ return (source.startsWith(QLatin1Char('/'))
+ || source.startsWith(QStringLiteral("./"))
+ || source.startsWith(QStringLiteral("../")))
+ ? source : (QStringLiteral("/dev/") + source);
+}
+
+QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source)
+{
+ return source.startsWith(QStringLiteral("/dev/"))
+ ? source.mid(5) : source;
+}
+
QT_END_NAMESPACE
diff --git a/src/serialport/qserialportinfo_p.h b/src/serialport/qserialportinfo_p.h
index 6ab4117..c9f1086 100644
--- a/src/serialport/qserialportinfo_p.h
+++ b/src/serialport/qserialportinfo_p.h
@@ -51,7 +51,7 @@
QT_BEGIN_NAMESPACE
-class QSerialPortInfoPrivate
+class Q_AUTOTEST_EXPORT QSerialPortInfoPrivate
{
public:
QSerialPortInfoPrivate()
@@ -59,9 +59,15 @@ public:
, productIdentifier(0)
, hasVendorIdentifier(false)
, hasProductIdentifier(false)
- {}
+ {
+ }
+
+ ~QSerialPortInfoPrivate()
+ {
+ }
- ~QSerialPortInfoPrivate() {}
+ static QString portNameToSystemLocation(const QString &source);
+ static QString portNameFromSystemLocation(const QString &source);
QString portName;
QString device;
diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp
index 7322a3c..9637581 100644
--- a/src/serialport/qserialportinfo_unix.cpp
+++ b/src/serialport/qserialportinfo_unix.cpp
@@ -100,7 +100,7 @@ QList<QSerialPortInfo> availablePortsByFiltersOfDevices()
foreach (const QString &deviceFilePath, filteredDeviceFilePaths()) {
QSerialPortInfoPrivate priv;
priv.device = deviceFilePath;
- priv.portName = QSerialPortPrivate::portNameFromSystemLocation(deviceFilePath);
+ priv.portName = QSerialPortInfoPrivate::portNameFromSystemLocation(deviceFilePath);
serialPortInfoList.append(priv);
}
@@ -202,7 +202,7 @@ QList<QSerialPortInfo> availablePortsBySysfs()
}
priv.portName = targetPath.mid(lastIndexOfSlash + 1);
- priv.device = QSerialPortPrivate::portNameToSystemLocation(priv.portName);
+ priv.device = QSerialPortInfoPrivate::portNameToSystemLocation(priv.portName);
serialPortInfoList.append(priv);
}
@@ -401,4 +401,18 @@ bool QSerialPortInfo::isValid() const
return f.exists();
}
+QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
+{
+ return (source.startsWith(QLatin1Char('/'))
+ || source.startsWith(QStringLiteral("./"))
+ || source.startsWith(QStringLiteral("../")))
+ ? source : (QStringLiteral("/dev/") + source);
+}
+
+QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source)
+{
+ return source.startsWith(QStringLiteral("/dev/"))
+ ? source.mid(5) : source;
+}
+
QT_END_NAMESPACE
diff --git a/src/serialport/qserialportinfo_win.cpp b/src/serialport/qserialportinfo_win.cpp
index d4dff94..e595964 100644
--- a/src/serialport/qserialportinfo_win.cpp
+++ b/src/serialport/qserialportinfo_win.cpp
@@ -315,7 +315,7 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
QSerialPortInfoPrivate priv;
priv.portName = portName;
- priv.device = QSerialPortPrivate::portNameToSystemLocation(portName);
+ priv.device = QSerialPortInfoPrivate::portNameToSystemLocation(portName);
priv.description = deviceDescription(deviceInfoSet, &deviceInfoData);
priv.manufacturer = deviceManufacturer(deviceInfoSet, &deviceInfoData);
@@ -336,10 +336,10 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
foreach (const QString &portName, portNamesFromHardwareDeviceMap()) {
if (std::find_if(serialPortInfoList.begin(), serialPortInfoList.end(),
SerialPortNameEqualFunctor(portName)) == serialPortInfoList.end()) {
- QSerialPortInfo serialPortInfo;
- serialPortInfo.d_ptr->portName = portName;
- serialPortInfo.d_ptr->device = QSerialPortPrivate::portNameToSystemLocation(portName);
- serialPortInfoList.append(serialPortInfo);
+ QSerialPortInfoPrivate priv;
+ priv.portName = portName;
+ priv.device = QSerialPortInfoPrivate::portNameToSystemLocation(portName);
+ serialPortInfoList.append(priv);
}
}
@@ -379,4 +379,17 @@ bool QSerialPortInfo::isValid() const
return true;
}
+QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
+{
+ return source.startsWith(QStringLiteral("COM"))
+ ? (QStringLiteral("\\\\.\\") + source) : source;
+}
+
+QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source)
+{
+ return (source.startsWith(QStringLiteral("\\\\.\\"))
+ || source.startsWith(QStringLiteral("//./")))
+ ? source.mid(4) : source;
+}
+
QT_END_NAMESPACE
diff --git a/src/serialport/qserialportinfo_wince.cpp b/src/serialport/qserialportinfo_wince.cpp
index f39b5a2..5a7ce62 100644
--- a/src/serialport/qserialportinfo_wince.cpp
+++ b/src/serialport/qserialportinfo_wince.cpp
@@ -107,7 +107,7 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
do {
QSerialPortInfoPrivate priv;
priv.device = QString::fromWCharArray(di.szLegacyName);
- priv.portName = QSerialPortPrivate::portNameFromSystemLocation(priv.device);
+ priv.portName = QSerialPortInfoPrivate::portNameFromSystemLocation(priv.device);
priv.description = findDescription(HKEY_LOCAL_MACHINE,
QString::fromWCharArray(di.szDeviceKey));
@@ -153,4 +153,16 @@ bool QSerialPortInfo::isValid() const
return true;
}
+QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
+{
+ return source.endsWith(QLatin1Char(':'))
+ ? source : (source + QLatin1Char(':'));
+}
+
+QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source)
+{
+ return source.endsWith(QLatin1Char(':'))
+ ? source.mid(0, source.size() - 1) : source;
+}
+
QT_END_NAMESPACE
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 5e317d7..2fa03f0 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,2 +1,5 @@
TEMPLATE = subdirs
-SUBDIRS += qserialport qserialportinfo cmake
+SUBDIRS += qserialport qserialportinfo qserialportinfoprivate cmake
+
+!contains(QT_CONFIG, private_tests): SUBDIRS -= \
+ qserialportinfoprivate
diff --git a/tests/auto/qserialportinfoprivate/qserialportinfoprivate.pro b/tests/auto/qserialportinfoprivate/qserialportinfoprivate.pro
new file mode 100644
index 0000000..f479a29
--- /dev/null
+++ b/tests/auto/qserialportinfoprivate/qserialportinfoprivate.pro
@@ -0,0 +1,4 @@
+QT = core testlib serialport-private
+TARGET = tst_qserialportinfoprivate
+#CONFIG += testcase
+SOURCES = tst_qserialportinfoprivate.cpp
diff --git a/tests/auto/qserialportinfoprivate/tst_qserialportinfoprivate.cpp b/tests/auto/qserialportinfoprivate/tst_qserialportinfoprivate.cpp
new file mode 100644
index 0000000..cfd2d85
--- /dev/null
+++ b/tests/auto/qserialportinfoprivate/tst_qserialportinfoprivate.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSerialPort module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <private/qserialportinfo_p.h>
+
+class tst_QSerialPortInfoPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ explicit tst_QSerialPortInfoPrivate();
+
+private slots:
+ void canonical_data();
+ void canonical();
+};
+
+tst_QSerialPortInfoPrivate::tst_QSerialPortInfoPrivate()
+{
+}
+
+void tst_QSerialPortInfoPrivate::canonical_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<QString>("name");
+ QTest::addColumn<QString>("location");
+
+#if defined (Q_OS_WINCE)
+ QTest::newRow("Test1") << "COM1" << "COM1" << "COM1:";
+ QTest::newRow("Test2") << "COM1:" << "COM1" << "COM1:";
+#elif defined (Q_OS_WIN32)
+ QTest::newRow("Test1") << "COM1" << "COM1" << "\\\\.\\COM1";
+ QTest::newRow("Test2") << "\\\\.\\COM1" << "COM1" << "\\\\.\\COM1";
+ QTest::newRow("Test3") << "//./COM1" << "COM1" << "//./COM1";
+#elif defined (Q_OS_OSX)
+ QTest::newRow("Test1") << "ttyS0" << "ttyS0" << "/dev/ttyS0";
+ QTest::newRow("Test2") << "cu.serial1" << "cu.serial1" << "/dev/cu.serial1";
+ QTest::newRow("Test3") << "tty.serial1" << "tty.serial1" << "/dev/tty.serial1";
+ QTest::newRow("Test4") << "/dev/ttyS0" << "ttyS0" << "/dev/ttyS0";
+ QTest::newRow("Test5") << "/dev/tty.serial1" << "tty.serial1" << "/dev/tty.serial1";
+ QTest::newRow("Test6") << "/dev/cu.serial1" << "cu.serial1" << "/dev/cu.serial1";
+ QTest::newRow("Test7") << "/dev/serial/ttyS0" << "serial/ttyS0" << "/dev/serial/ttyS0";
+ QTest::newRow("Test8") << "/home/ttyS0" << "/home/ttyS0" << "/home/ttyS0";
+ QTest::newRow("Test9") << "/home/serial/ttyS0" << "/home/serial/ttyS0" << "/home/serial/ttyS0";
+ QTest::newRow("Test10") << "serial/ttyS0" << "serial/ttyS0" << "/dev/serial/ttyS0";
+ QTest::newRow("Test11") << "./ttyS0" << "./ttyS0" << "./ttyS0";
+ QTest::newRow("Test12") << "../ttyS0" << "../ttyS0" << "../ttyS0";
+#elif defined (Q_OS_UNIX)
+ QTest::newRow("Test1") << "ttyS0" << "ttyS0" << "/dev/ttyS0";
+ QTest::newRow("Test2") << "/dev/ttyS0" << "ttyS0" << "/dev/ttyS0";
+ QTest::newRow("Test3") << "/dev/serial/ttyS0" << "serial/ttyS0" << "/dev/serial/ttyS0";
+ QTest::newRow("Test4") << "/home/ttyS0" << "/home/ttyS0" << "/home/ttyS0";
+ QTest::newRow("Test5") << "/home/serial/ttyS0" << "/home/serial/ttyS0" << "/home/serial/ttyS0";
+ QTest::newRow("Test6") << "serial/ttyS0" << "serial/ttyS0" << "/dev/serial/ttyS0";
+ QTest::newRow("Test7") << "./ttyS0" << "./ttyS0" << "./ttyS0";
+ QTest::newRow("Test8") << "../ttyS0" << "../ttyS0" << "../ttyS0";
+#endif
+}
+
+void tst_QSerialPortInfoPrivate::canonical()
+{
+ QFETCH(QString, source);
+ QFETCH(QString, name);
+ QFETCH(QString, location);
+
+ QCOMPARE(QSerialPortInfoPrivate::portNameFromSystemLocation(source), name);
+ QCOMPARE(QSerialPortInfoPrivate::portNameToSystemLocation(source), location);
+}
+
+QTEST_MAIN(tst_QSerialPortInfoPrivate)
+#include "tst_qserialportinfoprivate.moc"