summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Baak <ed.baak@nokia.com>2010-07-29 10:44:25 +1000
committerEd Baak <ed.baak@nokia.com>2010-07-29 10:44:25 +1000
commit0593673766da8df14a35e2940fcdddb710d9684c (patch)
tree387a24471e6362c7f1ffec53a90c197d95204d7f
parentab5fbe577829fedf5416d5d0835b67dbaeb88688 (diff)
Cleanup exec and runTest functions
-rw-r--r--interpreter/qscriptsystemtest.cpp40
-rw-r--r--interpreter/qscriptsystemtest.h5
-rw-r--r--libqsystemtest/qabstracttest.cpp86
-rw-r--r--libqsystemtest/qabstracttest.h12
-rw-r--r--libqsystemtest/qsystemtest.cpp15
-rw-r--r--libqsystemtest/qsystemtest.h2
6 files changed, 69 insertions, 91 deletions
diff --git a/interpreter/qscriptsystemtest.cpp b/interpreter/qscriptsystemtest.cpp
index 2b6a2f4..cae12ae 100644
--- a/interpreter/qscriptsystemtest.cpp
+++ b/interpreter/qscriptsystemtest.cpp
@@ -490,6 +490,38 @@ bool QScriptSystemTest::setQueryError( const QString &errString )
return ret;
}
+#ifndef QTCREATOR_QTEST
+/*
+ \internal
+ Executes all test functions as specified on the command line, while running the
+ application event loop.
+
+ The \a argc and \a argv parameters should be passed in from the main()
+ function of the application and are used to parse command-line arguments
+ specific to QAbstractTest. Also, subclasses may override the runTest(),
+
+ The \a filename parameter contains the full path to the source file containing the
+ test in question. It is used to determine where test data should be located.
+
+*/
+int QScriptSystemTest::exec( int argc, char* argv[], char* filename )
+{
+ setupTestDataPath(filename);
+
+ QStringList options;
+ for (int i = 1; i < argc; ++i) options << argv[i];
+
+ QString defOpt = qgetenv("QTUITEST_DEFAULT_OPTIONS");
+ if (defOpt.length()) {
+ options << defOpt.split(' ');
+ }
+
+ processCommandLine(options);
+ QString script = options.first();
+ return runTest(script, options, QStringList());
+}
+#endif
+
int QScriptSystemTest::runTest(const QString &fname, const QStringList &parameters,
const QStringList &environment)
{
@@ -558,7 +590,13 @@ int QScriptSystemTest::runTest(const QString &fname, const QStringList &paramete
m_engine.setAgent(m_agent);
}
- int retval = QTest::qExec(&tc, parameters);
+ int retval;
+// int retval = QSystemTest::runTest(&tc, fname, parameters, environment);//QTest::qExec(&tc, parameters);
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
+ signal(SIGSEGV, handle_segfault);
+ if (!setjmp(*segfaultJmp()))
+#endif
+ retval = QTest::qExec(&tc, parameters);
testObject = 0;
diff --git a/interpreter/qscriptsystemtest.h b/interpreter/qscriptsystemtest.h
index 9624fd0..dec150d 100644
--- a/interpreter/qscriptsystemtest.h
+++ b/interpreter/qscriptsystemtest.h
@@ -67,6 +67,11 @@ public:
virtual int runTest(const QString &fname, const QStringList &parameters,
const QStringList &environment);
+#ifndef Q_QDOC
+# ifndef QTCREATOR_QTEST
+ int exec( int argc, char* argv[], char* filename = 0 );
+# endif
+#endif
public slots:
virtual bool fail(QString const &message);
diff --git a/libqsystemtest/qabstracttest.cpp b/libqsystemtest/qabstracttest.cpp
index f441938..476e2e2 100644
--- a/libqsystemtest/qabstracttest.cpp
+++ b/libqsystemtest/qabstracttest.cpp
@@ -50,7 +50,13 @@
# include <unistd.h>
# include <time.h>
# include <signal.h>
-# include <setjmp.h>
+
+jmp_buf segfault_jump;
+jmp_buf *segfaultJmp()
+{
+ return &segfault_jump;
+}
+
#endif
/*!
@@ -305,38 +311,6 @@ QString QAbstractTest::currentTestFunction( bool fullName ) const
return fullName ? QString("%1::%2").arg(testCaseName()).arg(QTest::currentTestFunction()) : (QString(QTest::currentTestFunction()));
}
-#ifndef QTCREATOR_QTEST
-/*
- \internal
- Executes all test functions as specified on the command line, while running the
- application event loop.
-
- The \a argc and \a argv parameters should be passed in from the main()
- function of the application and are used to parse command-line arguments
- specific to QAbstractTest. Also, subclasses may override the runTest(),
-
- The \a filename parameter contains the full path to the source file containing the
- test in question. It is used to determine where test data should be located.
-
-*/
-int QAbstractTest::exec( int argc, char* argv[], char* filename )
-{
- setupTestDataPath(filename);
-
- QStringList options;
- for (int i = 1; i < argc; ++i) options << argv[i];
-
- QString defOpt = qgetenv("QTUITEST_DEFAULT_OPTIONS");
- if (defOpt.length()) {
- options << defOpt.split(' ');
- }
-
- processCommandLine(options);
- QString script = options.first();
- return runTest(script, options, QStringList());
-}
-#endif
-
//#ifndef QTCREATOR_QTEST
/*
\internal
@@ -443,40 +417,6 @@ void QAbstractTest::processCommandLine( QStringList &args )
}
}
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
-jmp_buf segfault_jmp;
-
-void handle_segfault(int signum)
-{
- signal(signum, SIG_DFL);
- QTest::qFail("A segmentation fault occurred.", "Unknown file", 0);
- longjmp(segfault_jmp, 1);
- _exit(0);
-}
-#endif
-
-//# ifndef QTCREATOR_QTEST
-/*
- \internal
- Run test with arguments \a argc, \a argv, and return an exit code.
- The base implementation executes private slots as testfunctions
- using QTest::qExec(). Subclasses may reimplement this function to provide
- other behaviour.
-*/
-int QAbstractTest::runTest(const QString &fname, const QStringList &args,
- const QStringList &environment)
-{
- Q_UNUSED(fname);
- Q_UNUSED(environment);
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
- signal(SIGSEGV, handle_segfault);
- if (!setjmp(segfault_jmp))
-#endif
- return QTest::qExec( this, args );
- return -1;
-}
-//#endif
-
/*!
\internal
Set up the test data path, where \a filename is the name of the test source file.
@@ -623,7 +563,7 @@ void FatalTimeoutThread::run()
case TimedOut:
QTest::qFail(qPrintable(QString("Test did not finish within the allowed %1 ms").arg(m_timeout)), "Unknown file", 0);
#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
- longjmp(segfault_jmp, 1);
+ longjmp(segfault_jump, 1);
#endif
_exit(0);
case DidNotTimeOut:
@@ -736,4 +676,14 @@ int QTimedTest::real_qt_metacall(QMetaObject::Call _c, int _id, void **_a)
return _id;
}
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
+void handle_segfault(int signum)
+{
+ signal(signum, SIG_DFL);
+ QTest::qFail("A segmentation fault occurred.", "Unknown file", 0);
+ longjmp(segfault_jump, 1);
+ _exit(0);
+}
+#endif
+
#include "qabstracttest.moc"
diff --git a/libqsystemtest/qabstracttest.h b/libqsystemtest/qabstracttest.h
index 2a20d09..8b5d51d 100644
--- a/libqsystemtest/qabstracttest.h
+++ b/libqsystemtest/qabstracttest.h
@@ -49,6 +49,13 @@
#include "qtuitestglobal.h"
#include <qdebug.h>
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
+# include <setjmp.h>
+
+jmp_buf *segfaultJmp();
+void handle_segfault(int signum);
+#endif
+
class QSYSTEMTEST_EXPORT Autotest_QLog {
public:
static inline bool enabled() { return m_enabled; }
@@ -109,9 +116,6 @@ public:
, QObject *parent = 0);
virtual ~QAbstractTest();
-# ifndef QTCREATOR_QTEST
- int exec( int argc, char* argv[], char* filename = 0 );
-# endif
#endif
public slots:
@@ -131,8 +135,6 @@ public slots:
#ifndef Q_QDOC
protected:
- virtual int runTest(const QString &fname, const QStringList &parameters,
- const QStringList &environment);
virtual void printUsage() const;
virtual void processCommandLine(QStringList&);
diff --git a/libqsystemtest/qsystemtest.cpp b/libqsystemtest/qsystemtest.cpp
index f472166..72045f6 100644
--- a/libqsystemtest/qsystemtest.cpp
+++ b/libqsystemtest/qsystemtest.cpp
@@ -3063,21 +3063,6 @@ bool QSystemTest::setQueryError( const QTestMessage &message )
return false; // query is NOT successfull
}
-//#ifndef QTCREATOR_QTEST
-/*!
- \internal
- Launch AUT and run the test.
-*/
-int QSystemTest::runTest(const QString &fname, const QStringList &args,
- const QStringList &environment)
-{
- // Try to launch the aut script, and if successful, start executing the test.
- // QTest::qExec will also start the application event loop, and will not return until the tests have finished.
-
- return QAbstractTest::runTest(fname, args, environment);
-}
-//#endif
-
/*!
\internal
Attempts to launch the AUT (Application Under Test), and returns whether it was successful.
diff --git a/libqsystemtest/qsystemtest.h b/libqsystemtest/qsystemtest.h
index 9d21db4..3a3879a 100644
--- a/libqsystemtest/qsystemtest.h
+++ b/libqsystemtest/qsystemtest.h
@@ -400,8 +400,6 @@ protected slots:
protected:
virtual void printUsage() const;
- virtual int runTest(const QString &fname, const QStringList &parameters,
- const QStringList &environment);
virtual void processCommandLine(QStringList&);
bool connectToAut(int timeout = 10000);