Skip to content

Commit 02fd8c1

Browse files
author
Qt Continuous Integration System
committed
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging: Skip tst_maketestselftest::make_check by default on Windows Fixed tst_maketestselftest on QWS and Windows. Add a test for the `make check' feature. Fix `make check' for debug-and-release on Windows. Move `check' target for autotests into testcase.prf
2 parents 1448e19 + 21bd54d commit 02fd8c1

File tree

7 files changed

+269
-41
lines changed

7 files changed

+269
-41
lines changed

mkspecs/features/qttest_p4.prf

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
isEmpty(TEMPLATE):TEMPLATE=app
2-
CONFIG += qt warn_on console depend_includepath
2+
CONFIG += qt warn_on console depend_includepath testcase
33

44
qtAddLibrary(QtTest)
55

@@ -13,39 +13,5 @@ symbian:{
1313
# prefix test binary with tst_
1414
!contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_")
1515

16-
17-
check.files =
18-
check.path = .
19-
!isEmpty(DESTDIR): check.commands = cd ./$(DESTDIR) &&
20-
macx: check.commands += ./$(QMAKE_TARGET).app/Contents/MacOS/$(QMAKE_TARGET)
21-
else:unix: check.commands += ./$(QMAKE_TARGET)
22-
else:win32: {
23-
CONFIG(debug, debug|release):check.commands += $(DESTDIR_TARGET)
24-
else:check.commands += $(DESTDIR_TARGET)
25-
}
26-
embedded: check.commands += -qws
27-
QMAKE_EXTRA_TARGETS += check
28-
29-
!debug_and_release|build_pass {
30-
check.depends = first
31-
} else {
32-
check.CONFIG = recursive
33-
# In debug and release mode, only run the test once.
34-
# Run debug if available, release otherwise.
35-
debug_and_release {
36-
check.target = dummy_check
37-
check.recurse_target = check
38-
debug {
39-
real_check.depends = debug-check
40-
real_check.target = check
41-
QMAKE_EXTRA_TARGETS += real_check
42-
} else {
43-
real_check.depends = release-check
44-
real_check.target = check
45-
QMAKE_EXTRA_TARGETS += real_check
46-
}
47-
}
48-
}
49-
5016
target.path += $$[QT_INSTALL_PREFIX]/tests/qt4
5117
INSTALLS += target

mkspecs/features/testcase.prf

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
!contains(TEMPLATE,subdirs) {
2+
3+
check.files =
4+
check.path = .
5+
6+
# If the test ends up in a different directory, we should cd to that directory.
7+
# Note that qmake modifies DESTDIR after this file is processed,
8+
# therefore, testing DESTDIR for emptiness is not sufficient.
9+
# Also note that in debug-and-release mode we don't want to cd into the debug/release
10+
# directory (e.g. if the test goes to foo/release/tst_thing.exe, we want to do
11+
# cd foo && release/tst_thing.exe ).
12+
MUNGED_DESTDIR=$$DESTDIR
13+
MUNGED_TARGET=$$TARGET
14+
win32:debug_and_release {
15+
contains(DESTDIR,^release$)|contains(DESTDIR,^debug$):MUNGED_DESTDIR=
16+
17+
# In debug-and-release mode, the first ../ in TARGET breaks out of the debug/release
18+
# subdirectory. However, since make's working directory is already outside of the
19+
# debug/release subdirectory, this first ../ should be ignored when deciding if
20+
# we have to change directory before running the test.
21+
MUNGED_TARGET=$$replace(MUNGED_TARGET,^\.\./,)
22+
}
23+
!isEmpty(MUNGED_DESTDIR):!contains(MUNGED_DESTDIR,^\./?):check.commands = cd $(DESTDIR) &&
24+
contains(MUNGED_TARGET,.*/.*):check.commands = cd $(DESTDIR) &&
25+
26+
# Allow for a custom test runner script
27+
check.commands += $(TESTRUNNER)
28+
29+
macx {
30+
app_bundle: check.commands += ./$(QMAKE_TARGET).app/Contents/MacOS/$(QMAKE_TARGET)
31+
else: check.commands += ./$(QMAKE_TARGET)
32+
}
33+
else:unix: check.commands += ./$(QMAKE_TARGET)
34+
else: check.commands += $(DESTDIR_TARGET)
35+
36+
# For Qt/Embedded, run every test app as a QWS server
37+
embedded: check.commands += -qws
38+
39+
# Allow for custom arguments to tests
40+
check.commands += $(TESTARGS)
41+
QMAKE_EXTRA_TARGETS *= check
42+
43+
!debug_and_release|build_pass {
44+
check.depends = first
45+
} else {
46+
check.CONFIG = recursive
47+
# In debug and release mode, only run the test once.
48+
# Run debug if available, release otherwise.
49+
debug_and_release {
50+
check.target = dummy_check
51+
check.recurse_target = check
52+
debug {
53+
real_check.depends = debug-check
54+
real_check.target = check
55+
QMAKE_EXTRA_TARGETS += real_check
56+
} else {
57+
real_check.depends = release-check
58+
real_check.target = check
59+
QMAKE_EXTRA_TARGETS += real_check
60+
}
61+
}
62+
}
63+
64+
}
65+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
TEMPLATE = app
2+
TARGET = checktest
3+
CONFIG += console
4+
CONFIG -= app_bundle
5+
DESTDIR = ./
6+
QT = core
7+
SOURCES += main.cpp
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4+
** All rights reserved.
5+
** Contact: Nokia Corporation ([email protected])
6+
**
7+
** This file is part of the test suite of the Qt Toolkit.
8+
**
9+
** $QT_BEGIN_LICENSE:LGPL$
10+
** No Commercial Usage
11+
** This file contains pre-release code and may not be distributed.
12+
** You may use this file in accordance with the terms and conditions
13+
** contained in the Technology Preview License Agreement accompanying
14+
** this package.
15+
**
16+
** GNU Lesser General Public License Usage
17+
** Alternatively, this file may be used under the terms of the GNU Lesser
18+
** General Public License version 2.1 as published by the Free Software
19+
** Foundation and appearing in the file LICENSE.LGPL included in the
20+
** packaging of this file. Please review the following information to
21+
** ensure the GNU Lesser General Public License version 2.1 requirements
22+
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23+
**
24+
** In addition, as a special exception, Nokia gives you certain additional
25+
** rights. These rights are described in the Nokia Qt LGPL Exception
26+
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27+
**
28+
** If you have questions regarding the use of this file, please contact
29+
** Nokia at [email protected].
30+
**
31+
**
32+
**
33+
**
34+
**
35+
**
36+
**
37+
**
38+
** $QT_END_LICENSE$
39+
**
40+
****************************************************************************/
41+
42+
#include <QCoreApplication>
43+
#include <QDir>
44+
#include <QFile>
45+
#include <QFileInfo>
46+
#include <QStringList>
47+
48+
#include <stdio.h>
49+
#include <stdlib.h>
50+
51+
void fail(QString const& message)
52+
{
53+
printf("CHECKTEST FAIL: %s\n", qPrintable(message));
54+
exit(0);
55+
}
56+
57+
void pass(QString const& message)
58+
{
59+
printf("CHECKTEST PASS: %s\n", qPrintable(message));
60+
exit(0);
61+
}
62+
63+
int main(int argc, char** argv)
64+
{
65+
QCoreApplication app(argc, argv);
66+
67+
QStringList args = app.arguments();
68+
args.removeFirst(); // ourself
69+
70+
QString args_quoted = QString("'%1'").arg(args.join("','"));
71+
72+
#ifdef Q_WS_QWS
73+
{
74+
// for QWS we expect tests to be run as the QWS server
75+
QString qws = args.takeLast();
76+
if (qws != "-qws") {
77+
fail(QString("Expected test to be run with `-qws', but it wasn't; args: %1").arg(args_quoted));
78+
}
79+
}
80+
#endif
81+
82+
if (args.count() != 1) {
83+
fail(QString("These arguments are not what I expected: %1").arg(args_quoted));
84+
}
85+
86+
QString test = args.at(0);
87+
88+
QFileInfo testfile(test);
89+
if (!testfile.exists()) {
90+
fail(QString("File %1 does not exist (my working directory is: %2, my args are: %3)")
91+
.arg(test)
92+
.arg(QDir::currentPath())
93+
.arg(args_quoted)
94+
);
95+
}
96+
97+
pass(args_quoted);
98+
}
99+
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
load(qttest_p4)
2-
3-
SOURCES += tst_maketestselftest.cpp
4-
QT = core
5-
6-
DEFINES += SRCDIR=\\\"$$PWD/\\\"
1+
TEMPLATE = subdirs
2+
SUBDIRS = checktest test
3+
test.depends = checktest
74

85
requires(!cross_compile)
96

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load(qttest_p4)
2+
3+
TARGET = ../tst_maketestselftest
4+
SOURCES += ../tst_maketestselftest.cpp
5+
QT = core
6+
7+
DEFINES += SRCDIR=\\\"$$PWD/..\\\"
8+
9+
requires(!cross_compile)
10+
11+
win32 {
12+
CONFIG(debug, debug|release) {
13+
TARGET = ../../debug/tst_maketestselftest
14+
} else {
15+
TARGET = ../../release/tst_maketestselftest
16+
}
17+
}
18+

tests/auto/maketestselftest/tst_maketestselftest.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ private slots:
6666
void naming_convention();
6767
void naming_convention_data();
6868

69+
void make_check();
70+
6971
private:
7072
QStringList find_subdirs(QString const&, FindSubdirsMode, QString const& = QString());
7173

@@ -446,6 +448,80 @@ QStringList tst_MakeTestSelfTest::find_subdirs(QString const& pro_file, FindSubd
446448
return out;
447449
}
448450

451+
void tst_MakeTestSelfTest::make_check()
452+
{
453+
/*
454+
Run `make check' over the whole tests tree with a custom TESTRUNNER,
455+
to verify that the TESTRUNNER mechanism works right.
456+
*/
457+
QString testsDir(SRCDIR "/..");
458+
QString checktest(SRCDIR "/checktest/checktest");
459+
460+
#ifdef Q_OS_WIN32
461+
if (qgetenv("RUN_SLOW_TESTS").isEmpty()) {
462+
QSKIP("This test is too slow to run by default on Windows. Set RUN_SLOW_TESTS=1 to run it.", SkipAll);
463+
}
464+
checktest.replace("/", "\\");
465+
checktest += ".exe";
466+
#endif
467+
468+
QProcess make;
469+
make.setWorkingDirectory(testsDir);
470+
471+
QStringList arguments;
472+
arguments << "-k";
473+
arguments << "check";
474+
arguments << QString("TESTRUNNER=%1").arg(checktest);
475+
476+
// find the right make; from externaltests.cpp
477+
static const char makes[] =
478+
"nmake.exe\0"
479+
"mingw32-make.exe\0"
480+
"gmake\0"
481+
"make\0"
482+
;
483+
484+
bool ok = false;
485+
for (const char *p = makes; *p; p += strlen(p) + 1) {
486+
make.start(p, arguments);
487+
if (make.waitForStarted()) {
488+
ok = true;
489+
break;
490+
}
491+
}
492+
493+
if (!ok) {
494+
QFAIL("Could not find the right make tool in PATH");
495+
}
496+
497+
QVERIFY(make.waitForFinished(1000 * 60 * 10));
498+
QCOMPARE(make.exitStatus(), QProcess::NormalExit);
499+
500+
int pass = 0;
501+
QList<QByteArray> out = make.readAllStandardOutput().split('\n');
502+
QStringList fails;
503+
foreach (QByteArray line, out) {
504+
while (line.endsWith("\r")) {
505+
line.chop(1);
506+
}
507+
if (line.startsWith("CHECKTEST FAIL")) {
508+
fails << QString::fromLocal8Bit(line);
509+
}
510+
if (line.startsWith("CHECKTEST PASS")) {
511+
++pass;
512+
}
513+
}
514+
515+
// We can't check that the exit code of make is 0, because some tests
516+
// may have failed to compile, but that doesn't mean `make check' is broken.
517+
// We do assume there are at least this many unbroken tests, though.
518+
QVERIFY2(fails.count() == 0,
519+
qPrintable(QString("`make check' doesn't work for %1 tests:\n%2")
520+
.arg(fails.count()).arg(fails.join("\n")))
521+
);
522+
QVERIFY(pass > 50);
523+
}
524+
449525
QStringList find_test_class(QString const& filename)
450526
{
451527
QStringList out;

0 commit comments

Comments
 (0)