Qt Autotest Environment: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Qt Autotest Environment=
[[Category:Developing_Qt::Guidelines]]<br />[toc align_right=&quot;yes&amp;quot; depth=&quot;3&amp;quot;]


==Introduction==
= Qt Autotest Environment =
 
== Introduction ==


Many Qt autotests require some environment setup to work correctly. This page is an attempt to document precisely what this environment is.
Many Qt autotests require some environment setup to work correctly. This page is an attempt to document precisely what this environment is.


Note that this is “best-effort” documentation. It should not be interpreted as coding standards for autotests, in fact quite the opposite many of the requirements here are due to a ''lack'' of coding standards. Some of these environmental requirements can be considered problems with the autotests which should be fixed.
Note that this is &quot;best-effort&amp;quot; documentation. It should not be interpreted as coding standards for autotests, in fact quite the opposite - many of the requirements here are due to a ''lack'' of coding standards. Some of these environmental requirements can be considered problems with the autotests which should be fixed.


The information may become outdated as autotests change. The current version of this page was written for Qt 4.5 and 4.6.
The information may become outdated as autotests change. The current version of this page was written for Qt 4.5 and 4.6.


===Qt build===
=== Qt build ===


Qt autotests require that Qt be built for testing itself. This will make some additional symbols be exported and some additional code be built to support it. To enable such a build, when you configure Qt, remember to pass the option <code>-developer-build</code>:
Qt autotests require that Qt be built for testing itself. This will make some additional symbols be exported and some additional code be built to support it. To enable such a build, when you configure Qt, remember to pass the option &lt;code&amp;gt;-developer-build&amp;lt;/code&amp;gt;:
 
<code><br /> ./configure -developer-build -prefix $PWD<br /></code>


The main changes to the Qt build are:
The main changes to the Qt build are:


* <code>QT_INTERNAL_BUILD</code> is set, so code can #ifdef to determine whether to enable the additional code
* &lt;code&amp;gt;QT_INTERNAL_BUILD&amp;lt;/code&amp;gt; is set, so code can #ifdef to determine whether to enable the additional code
* <code>Q_AUTOTEST_EXPORT</code> is defined to exporting the symbols
* &lt;code&amp;gt;Q_AUTOTEST_EXPORT&amp;lt;/code&amp;gt; is defined to exporting the symbols
 
Note also that Qt tests have only been tested with a non-installing Qt (the <code>-prefix $PWD</code> option above). The test project files override the <code>make install</code> target, so they are not installable. And Qt doesn’t work at all if it’s not at its installation path.
 
===Shadow builds===


Don’t use shadow builds.
Note also that Qt tests have only been tested with a non-installing Qt (the &lt;code&amp;gt;<s>prefix $PWD&amp;lt;/code&amp;gt; option above). The test project files override the &lt;code&amp;gt;make install&amp;lt;/code&amp;gt; target, so they are not installable. And Qt doesn't work at all if it's not at its installation path.
<br />h3. Shadow builds
<br />Don't use shadow builds.
<br />Some tests assume that their source and build directory are the same directory in order to find testdata.
<br />Reference: &quot;qsslkey uses QCoreApplication::applicationDirPath() to look for testdata which lives in the source tree&amp;quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/qsslkey/tst_qsslkey.cpp#line107
<br />h3. Working directory
<br />When the test is invoked, the working directory must be the directory containing the test's source (and binary, due to &quot;no shadow builds&amp;quot; rule).
<br />For tests with multiple subdirectories, use the top level directory for that test (e.g. for the qprocess test, run from &lt;code&amp;gt;tests/auto/qprocess&amp;lt;/code&amp;gt;, even though the .pro file for the test is at &lt;code&amp;gt;tests/auto/qprocess/test&amp;lt;/code&amp;gt;).
<br />Some tests read testdata from files found relative to the current working directory.
<br />Reference: &quot;qscriptv8testsuite finds testdata relative to QDir(&quot;.&quot;)&quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp#line196
<br />h3. Environment variables
<br />QTDIR: path to Qt build directory. &quot;bic reads headers from $QTDIR/include&amp;quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/bic/tst_bic.cpp#line223
<br />QTSRCDIR: path to Qt source directory (same as QTDIR due to no shadow builds rule). Strictly speaking, does not seem required, as all tests which use this fall back on QTDIR, which is correct anyway due to &quot;no shadow builds&amp;quot; rule. &quot;xmlpatternsxqts adds $QTSRCDIR/include to INCLUDEPATH&amp;quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/xmlpatternsxqts/test/test.pro#line14
<br />PATH: must include bin directory for the tested Qt, '''in front of any bin directory from other Qt versions'''. &quot;rcc assumes &lt;code&amp;gt;rcc' is in PATH&amp;quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/rcc/tst_rcc.cpp#line129
<br />h3. Network tests
<br />In /etc/hosts (Unix) or windir32\drivers\etc\hosts (Windows), set up some hostnames to point to a server running particular test services.
<br />The hostnames to be set up are:
<br />&lt;code&amp;gt;qt-test-server&amp;lt;/code&amp;gt; and &lt;code&amp;gt;qt-test-server.qt-test-net&amp;lt;/code&amp;gt;</s> &quot;network-settings.h&amp;quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/network-settings.h#line48


Some tests assume that their source and build directory are the same directory in order to find testdata.
&lt;code&amp;gt;qt-test-server.troll.no&amp;lt;/code&amp;gt; - &quot;q3socket&amp;quot;:http://qt.gitorious.org/qt/qt/blobs/ba5fb9f05c891feac8ab69006189de1aaafebc18/tests/auto/q3socket/tst_qsocket.cpp#line127


Reference: [http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/qsslkey/tst_qsslkey.cpp#line107 qsslkey uses QCoreApplication::applicationDirPath() to look for testdata which lives in the source tree] ''[qt.gitorious.org]''
The network test server can be set up by following the &lt;code&amp;gt;qtqa/sysadmin.git&amp;lt;/code&amp;gt; repository on gitorious; see &quot;instructions here&amp;quot;:http://gitorious.org/qtqa/sysadmin/blobs/master/README.network_test_server.txt


===Working directory===
=== DBus tests ===
 
When the test is invoked, the working directory must be the directory containing the test’s source (and binary, due to “no shadow builds” rule).
 
For tests with multiple subdirectories, use the top level directory for that test (e.g. for the qprocess test, run from <code>tests/auto/qprocess</code>, even though the .pro file for the test is at <code>tests/auto/qprocess/test</code>).
 
Some tests read testdata from files found relative to the current working directory.
 
Reference: [http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp#line196 qscriptv8testsuite finds testdata relative to QDir] ''[qt.gitorious.org]''
 
===Environment variables===
 
<span class="caps">QTDIR</span>: path to Qt build directory. [http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/bic/tst_bic.cpp#line223 bic reads headers from $QTDIR/include] ''[qt.gitorious.org]''
 
<span class="caps">QTSRCDIR</span>: path to Qt source directory (same as <span class="caps">QTDIR</span> due to no shadow builds rule). Strictly speaking, does not seem required, as all tests which use this fall back on <span class="caps">QTDIR</span>, which is correct anyway due to “no shadow builds” rule. [http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/xmlpatternsxqts/test/test.pro#line14 xmlpatternsxqts adds $QTSRCDIR/include to <span class="caps">INCLUDEPATH</span>] ''[qt.gitorious.org]''
 
<span class="caps">PATH</span>: must include bin directory for the tested Qt, '''in front of any bin directory from other Qt versions'''. [http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/rcc/tst_rcc.cpp#line129 rcc assumes &lt;code&gt;rcc’ is in <span class="caps">PATH</span>] ''[qt.gitorious.org]''
 
===Network tests===
 
In /etc/hosts (Unix) or windir\system32\drivers\etc\hosts (Windows), set up some hostnames to point to a server running particular test services.
 
The hostnames to be set up are:
 
<code>qt-test-server</code> and <code>qt-test-server.qt-test-net</code> – [http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/network-settings.h#line48 network-settings.h] ''[qt.gitorious.org]''
 
<code>qt-test-server.troll.no</code> – [http://qt.gitorious.org/qt/qt/blobs/ba5fb9f05c891feac8ab69006189de1aaafebc18/tests/auto/q3socket/tst_qsocket.cpp#line127 q3socket] ''[qt.gitorious.org]''
 
The network test server can be set up by following the <code>qtqa/sysadmin.git</code> repository on gitorious; see [http://gitorious.org/qtqa/sysadmin/blobs/master/README.network_test_server.txt instructions here] ''[gitorious.org]''
 
===DBus tests===


The DBus tests require a dbus session bus to be running.
The DBus tests require a dbus session bus to be running.
===Categories:===
* [[:Category:Developing Qt|Developing_Qt]]
** [[:Category:Developing Qt::Guidelines|Guidelines]]

Revision as of 09:50, 24 February 2015


[toc align_right="yes&quot; depth="3&quot;]

Qt Autotest Environment

Introduction

Many Qt autotests require some environment setup to work correctly. This page is an attempt to document precisely what this environment is.

Note that this is "best-effort&quot; documentation. It should not be interpreted as coding standards for autotests, in fact quite the opposite - many of the requirements here are due to a lack of coding standards. Some of these environmental requirements can be considered problems with the autotests which should be fixed.

The information may become outdated as autotests change. The current version of this page was written for Qt 4.5 and 4.6.

Qt build

Qt autotests require that Qt be built for testing itself. This will make some additional symbols be exported and some additional code be built to support it. To enable such a build, when you configure Qt, remember to pass the option <code&gt;-developer-build&lt;/code&gt;:

<br /> ./configure -developer-build -prefix $PWD<br />

The main changes to the Qt build are:

  • <code&gt;QT_INTERNAL_BUILD&lt;/code&gt; is set, so code can #ifdef to determine whether to enable the additional code
  • <code&gt;Q_AUTOTEST_EXPORT&lt;/code&gt; is defined to exporting the symbols

Note also that Qt tests have only been tested with a non-installing Qt (the <code&gt;prefix $PWD&lt;/code&gt; option above). The test project files override the <code&gt;make install&lt;/code&gt; target, so they are not installable. And Qt doesn't work at all if it's not at its installation path.
h3. Shadow builds
Don't use shadow builds.
Some tests assume that their source and build directory are the same directory in order to find testdata.
Reference: "qsslkey uses QCoreApplication::applicationDirPath() to look for testdata which lives in the source tree&quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/qsslkey/tst_qsslkey.cpp#line107
h3. Working directory
When the test is invoked, the working directory must be the directory containing the test's source (and binary, due to "no shadow builds&quot; rule).
For tests with multiple subdirectories, use the top level directory for that test (e.g. for the qprocess test, run from <code&gt;tests/auto/qprocess&lt;/code&gt;, even though the .pro file for the test is at <code&gt;tests/auto/qprocess/test&lt;/code&gt;).
Some tests read testdata from files found relative to the current working directory.
Reference: "qscriptv8testsuite finds testdata relative to QDir(".")":http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp#line196
h3. Environment variables
QTDIR: path to Qt build directory. "bic reads headers from $QTDIR/include&quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/bic/tst_bic.cpp#line223
QTSRCDIR: path to Qt source directory (same as QTDIR due to no shadow builds rule). Strictly speaking, does not seem required, as all tests which use this fall back on QTDIR, which is correct anyway due to "no shadow builds&quot; rule. "xmlpatternsxqts adds $QTSRCDIR/include to INCLUDEPATH&quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/xmlpatternsxqts/test/test.pro#line14
PATH: must include bin directory for the tested Qt, in front of any bin directory from other Qt versions. "rcc assumes <code&gt;rcc' is in PATH&quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/rcc/tst_rcc.cpp#line129
h3. Network tests
In /etc/hosts (Unix) or windir32\drivers\etc\hosts (Windows), set up some hostnames to point to a server running particular test services.
The hostnames to be set up are:
<code&gt;qt-test-server&lt;/code&gt; and <code&gt;qt-test-server.qt-test-net&lt;/code&gt;
"network-settings.h&quot;:http://qt.gitorious.org/qt/qt/blobs/d6127efabb74e2004608f53d0be3b7c4a6df768d/tests/auto/network-settings.h#line48

<code&gt;qt-test-server.troll.no&lt;/code&gt; - "q3socket&quot;:http://qt.gitorious.org/qt/qt/blobs/ba5fb9f05c891feac8ab69006189de1aaafebc18/tests/auto/q3socket/tst_qsocket.cpp#line127

The network test server can be set up by following the <code&gt;qtqa/sysadmin.git&lt;/code&gt; repository on gitorious; see "instructions here&quot;:http://gitorious.org/qtqa/sysadmin/blobs/master/README.network_test_server.txt

DBus tests

The DBus tests require a dbus session bus to be running.