summaryrefslogtreecommitdiffstats
path: root/tests/manual/qt_poll
diff options
context:
space:
mode:
authorLouai Al-Khanji <louai.al-khanji@theqtcompany.com>2015-12-02 17:22:32 -0800
committerLouai Al-Khanji <louai.al-khanji@theqtcompany.com>2015-12-05 00:47:36 +0000
commitf0a6d45cc8ca0b17838046c1c17efbc64773f2b5 (patch)
tree5ce13632dc05400b4c61ff817b01322111abde24 /tests/manual/qt_poll
parentc456fb366a92cd08f6d2bf95b6974fea82340003 (diff)
qt_poll: split out into separate file and sanitize build
The qt_poll function calls recv to query whether fds marked by select as readable should be marked POLLIN or POLLHUP in the pollfd structure. On many platforms such as QNX this requires extra link-time libraries which were not previously required by QtCore. While the qt_poll function is intended as a fallback mechanism only for those platforms which do not implement poll natively, the function was compiled unconditionally whenever QT_BUILD_INTERNAL was defined, e.g. in developer builds. Additionally the function was included on those systems that define poll in system headers so that configure determines build-time availability, but do not define _POSIX_POLL > 0 or indicate POSIX:2008 compliance via either the _POSIX_VERSION or _XOPEN_VERSION macros. On those systems a sysconf query for _SC_POLL was performed to determine at runtime whether to call the system poll or qt_poll. Both of these cases are in fact counterproductive. In the first case the sole consumer of the function is a single manual unit test. In the second, to my knowledge no platform requires the runtime fallback. Despite that, we were forcing an extra dylib in both cases. Both cases are fixed by 1) moving the implementation into its own file for the unit test to include and 2) dropping the dynamic fallback if configure determines availability of poll at compile-time. This also reverts commit 13777097118c496391d4b9656b95097ac25e4a40, which added -lsocket for QtCore on QNX. Change-Id: I2dd10695c5d4cac81b68d2c2558797f3cdabc153 Reviewed-by: James McDonnell <jmcdonnell@qnx.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/manual/qt_poll')
-rw-r--r--tests/manual/qt_poll/qt_poll.pro5
-rw-r--r--tests/manual/qt_poll/tst_qt_poll.cpp15
2 files changed, 10 insertions, 10 deletions
diff --git a/tests/manual/qt_poll/qt_poll.pro b/tests/manual/qt_poll/qt_poll.pro
index e8104c764b..beea4d1316 100644
--- a/tests/manual/qt_poll/qt_poll.pro
+++ b/tests/manual/qt_poll/qt_poll.pro
@@ -1,4 +1,7 @@
CONFIG += testcase
TARGET = tst_qt_poll
QT = core-private network testlib
-SOURCES = tst_qt_poll.cpp
+INCLUDEPATH += ../../../src/corelib/kernel
+SOURCES += \
+ tst_qt_poll.cpp \
+ ../../../src/corelib/kernel/qpoll.cpp
diff --git a/tests/manual/qt_poll/tst_qt_poll.cpp b/tests/manual/qt_poll/tst_qt_poll.cpp
index 1edc08244e..56e41e4093 100644
--- a/tests/manual/qt_poll/tst_qt_poll.cpp
+++ b/tests/manual/qt_poll/tst_qt_poll.cpp
@@ -31,33 +31,31 @@
**
****************************************************************************/
+#ifndef QT_NO_NATIVE_POLL
+#define QT_NO_NATIVE_POLL
+#endif
+
#include <QtTest/QtTest>
#include <QtNetwork>
#include <private/qcore_unix_p.h>
-#ifdef QT_BUILD_INTERNAL
QT_BEGIN_NAMESPACE
-Q_AUTOTEST_EXPORT int qt_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts);
+// defined in qpoll.cpp
+int qt_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts);
QT_END_NAMESPACE
-#endif // QT_BUILD_INTERNAL
-
-QT_USE_NAMESPACE
class tst_qt_poll : public QObject
{
Q_OBJECT
-#ifdef QT_BUILD_INTERNAL
private slots:
void pollout();
void pollin();
void pollnval();
void pollprihup();
-#endif // QT_BUILD_INTERNAL
};
-#ifdef QT_BUILD_INTERNAL
void tst_qt_poll::pollout()
{
int fds[2];
@@ -152,7 +150,6 @@ void tst_qt_poll::pollprihup()
QCOMPARE(res, 1);
QCOMPARE(pfd.revents, short(POLLHUP));
}
-#endif // QT_BUILD_INTERNAL
QTEST_APPLESS_MAIN(tst_qt_poll)
#include "tst_qt_poll.moc"