author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 08 Apr 2010 14:19:33 +0300 | |
branch | RCL_3 |
changeset 7 | 3f74d0d4af4c |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the tools applications 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 qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifdef QT_CETEST_NO_ACTIVESYNC |
|
43 |
# include "cetcpsyncconnection.h" |
|
44 |
#else |
|
45 |
# include "activesyncconnection.h" |
|
46 |
#endif |
|
47 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
48 |
const int SLEEP_AFTER_RESET = 60000; // sleep for 1 minute |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
49 |
const int SLEEP_RECONNECT = 2000; // sleep for 2 seconds before trying another reconnect |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
50 |
|
0 | 51 |
#include "deployment.h" |
52 |
#include <option.h> |
|
53 |
#include <project.h> |
|
54 |
#include <property.h> |
|
55 |
#include <qstringlist.h> |
|
56 |
#include <qfileinfo.h> |
|
57 |
#include <qdir.h> |
|
58 |
#include <iostream> |
|
59 |
using namespace std; |
|
60 |
||
61 |
const int debugLevel = 0; |
|
62 |
void debugOutput(const QString& text, int level) |
|
63 |
{ |
|
64 |
if (level <= debugLevel) |
|
65 |
cout << qPrintable(text) << endl; |
|
66 |
} |
|
67 |
||
68 |
// needed for QMake sources to compile |
|
69 |
QString project_builtin_regx() { return QString();} |
|
70 |
static QString pwd; |
|
71 |
QString qmake_getpwd() |
|
72 |
{ |
|
73 |
if(pwd.isNull()) |
|
74 |
pwd = QDir::currentPath(); |
|
75 |
return pwd; |
|
76 |
} |
|
77 |
bool qmake_setpwd(const QString &p) |
|
78 |
{ |
|
79 |
if(QDir::setCurrent(p)) { |
|
80 |
pwd = QDir::currentPath(); |
|
81 |
return true; |
|
82 |
} |
|
83 |
return false; |
|
84 |
} |
|
85 |
||
86 |
namespace TestConfiguration { |
|
87 |
QString localExecutable; |
|
88 |
QString localQtConf; |
|
89 |
QString remoteTestPath; |
|
90 |
QString remoteLibraryPath; |
|
91 |
QString remoteExecutable; |
|
92 |
QString remoteResultFile; |
|
93 |
||
94 |
bool testDebug; |
|
95 |
void init() |
|
96 |
{ |
|
97 |
testDebug = true; |
|
98 |
localQtConf = QLatin1String("no"); |
|
99 |
remoteTestPath = QLatin1String("\\Program Files\\qt_test"); |
|
100 |
remoteLibraryPath = remoteTestPath; |
|
101 |
remoteResultFile = QLatin1String("\\qt_test_results.txt"); |
|
102 |
} |
|
103 |
} |
|
104 |
||
105 |
void usage() |
|
106 |
{ |
|
107 |
cout << |
|
108 |
"QTestLib options\n" |
|
109 |
" -functions : Returns a list of current testfunctions\n" |
|
110 |
" -xml : Outputs results as XML document\n" |
|
111 |
" -lightxml : Outputs results as stream of XML tags\n" |
|
112 |
" -o filename: Writes all output into a file\n" |
|
113 |
" -silent : Only outputs warnings and failures\n" |
|
114 |
" -v1 : Print enter messages for each testfunction\n" |
|
115 |
" -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n" |
|
116 |
" -vs : Print every signal emitted\n" |
|
117 |
" -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n" |
|
118 |
" -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n" |
|
119 |
" -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n" |
|
120 |
" -keyevent-verbose : Turn on verbose messages for keyboard simulation\n" |
|
121 |
" -maxwarnings n : Sets the maximum amount of messages to output.\n" |
|
122 |
" 0 means unlimited, default: 2000\n" |
|
123 |
" -help : This help\n"; |
|
124 |
cout << |
|
125 |
"cetest specific options\n" |
|
126 |
" -debug : Test debug version[default]\n" |
|
127 |
" -release : Test release version\n" |
|
128 |
" -libpath <path> : Remote path to deploy Qt libraries to\n" |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
129 |
" -reset : Reset device before starting a test\n" |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
130 |
" -awake : Device does not go sleep mode\n" |
0 | 131 |
" -qt-delete : Delete the Qt libraries after execution\n" |
132 |
" -project-delete : Delete the project file(s) after execution\n" |
|
133 |
" -delete : Delete everything deployed after execution\n" |
|
134 |
" -conf : Specify location of qt.conf file\n" |
|
135 |
" -f <file> : Specify project file\n" |
|
136 |
" -cache <file> : Specify .qmake.cache file to use\n" |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
" -d : Increase qmake debugging \n" |
0 | 138 |
" -timeout <value> : Specify a timeout value after which the test will be terminated\n" |
139 |
" -1 specifies waiting forever (default)\n" |
|
140 |
" 0 specifies starting the process detached\n" |
|
141 |
" >0 wait <value> seconds\n" |
|
142 |
"\n"; |
|
143 |
} |
|
144 |
||
145 |
int main(int argc, char **argv) |
|
146 |
{ |
|
147 |
QStringList arguments; |
|
148 |
for (int i=0; i<argc; ++i) |
|
149 |
arguments.append(QString::fromLatin1(argv[i])); |
|
150 |
||
151 |
TestConfiguration::init(); |
|
152 |
||
153 |
QStringList launchArguments; |
|
154 |
QString resultFile; |
|
155 |
QString proFile; |
|
156 |
QString cacheFile; |
|
157 |
int timeout = -1; |
|
158 |
bool cleanupQt = false; |
|
159 |
bool cleanupProject = false; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
160 |
bool deviceReset = false; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
161 |
bool keepAwake = false; |
0 | 162 |
|
163 |
for (int i=1; i<arguments.size(); ++i) { |
|
164 |
if (arguments.at(i).toLower() == QLatin1String("-help") |
|
165 |
|| arguments.at(i).toLower() == QLatin1String("--help") |
|
166 |
|| arguments.at(i).toLower() == QLatin1String("/?")) { |
|
167 |
usage(); |
|
168 |
return 0; |
|
169 |
} else if (arguments.at(i).toLower() == QLatin1String("-o")) { |
|
170 |
if (++i == arguments.size()) { |
|
171 |
cout << "Error: No output file specified!" << endl; |
|
172 |
return -1; |
|
173 |
} |
|
174 |
resultFile = arguments.at(i); |
|
175 |
} else if (arguments.at(i).toLower() == QLatin1String("-eventdelay") |
|
176 |
|| arguments.at(i).toLower() == QLatin1String("-keydelay") |
|
177 |
|| arguments.at(i).toLower() == QLatin1String("-mousedelay") |
|
178 |
|| arguments.at(i).toLower() == QLatin1String("-maxwarnings")) { |
|
179 |
launchArguments.append(arguments.at(i++)); |
|
180 |
if (i == arguments.size()) { |
|
181 |
cout << "Please specify value for:" << qPrintable(arguments.at(i-1).mid(1)) << endl; |
|
182 |
return -1; |
|
183 |
} |
|
184 |
launchArguments.append(arguments.at(i)); |
|
185 |
} else if (arguments.at(i).toLower() == QLatin1String("-debug")) { |
|
186 |
TestConfiguration::testDebug = true; |
|
187 |
Option::before_user_vars.append("CONFIG-=release"); |
|
188 |
Option::before_user_vars.append("CONFIG+=debug"); |
|
189 |
} else if (arguments.at(i).toLower() == QLatin1String("-release")) { |
|
190 |
TestConfiguration::testDebug = false; |
|
191 |
Option::before_user_vars.append("CONFIG-=debug"); |
|
192 |
Option::before_user_vars.append("CONFIG+=release"); |
|
193 |
} else if (arguments.at(i).toLower() == QLatin1String("-libpath")) { |
|
194 |
if (++i == arguments.size()) { |
|
195 |
cout << "Error: No library path specified!" << endl; |
|
196 |
return -1; |
|
197 |
} |
|
198 |
TestConfiguration::remoteLibraryPath = arguments.at(i); |
|
199 |
} else if (arguments.at(i).toLower() == QLatin1String("-qt-delete")) { |
|
200 |
cleanupQt = true; |
|
201 |
} else if (arguments.at(i).toLower() == QLatin1String("-project-delete")) { |
|
202 |
cleanupProject = true; |
|
203 |
} else if (arguments.at(i).toLower() == QLatin1String("-delete")) { |
|
204 |
cleanupQt = true; |
|
205 |
cleanupProject = true; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
206 |
} else if (arguments.at(i).toLower() == QLatin1String("-reset")) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
207 |
deviceReset = true; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
208 |
} else if (arguments.at(i).toLower() == QLatin1String("-awake")) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
209 |
keepAwake = true; |
0 | 210 |
} else if (arguments.at(i).toLower() == QLatin1String("-conf")) { |
211 |
if (++i == arguments.size()) { |
|
212 |
cout << "Error: No qt.conf file specified!" << endl; |
|
213 |
return -1; |
|
214 |
} |
|
215 |
if (!QFileInfo(arguments.at(i)).exists()) |
|
216 |
cout << "Warning: could not find qt.conf file at:" << qPrintable(arguments.at(i)) << endl; |
|
217 |
else |
|
218 |
TestConfiguration::localQtConf = arguments.at(i); |
|
219 |
} else if (arguments.at(i).toLower() == QLatin1String("-f")) { |
|
220 |
if (++i == arguments.size()) { |
|
221 |
cout << "Error: No output file specified!" << endl; |
|
222 |
return -1; |
|
223 |
} |
|
224 |
proFile = arguments.at(i); |
|
225 |
} else if (arguments.at(i).toLower() == QLatin1String("-cache")) { |
|
226 |
if (++i == arguments.size()) { |
|
227 |
cout << "Error: No cache file specified!" << endl; |
|
228 |
return -1; |
|
229 |
} |
|
230 |
cacheFile = arguments.at(i); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
231 |
} else if (arguments.at(i).toLower() == QLatin1String("-d")) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
Option::debug_level++; |
0 | 233 |
} else if (arguments.at(i).toLower() == QLatin1String("-timeout")) { |
234 |
if (++i == arguments.size()) { |
|
235 |
cout << "Error: No timeout value specified!" << endl; |
|
236 |
return -1; |
|
237 |
} |
|
238 |
timeout = QString(arguments.at(i)).toInt(); |
|
239 |
} else { |
|
240 |
launchArguments.append(arguments.at(i)); |
|
241 |
} |
|
242 |
} |
|
243 |
||
244 |
// check for .pro file |
|
245 |
if (proFile.isEmpty()) { |
|
246 |
proFile = QDir::current().dirName() + QLatin1String(".pro"); |
|
247 |
if (!QFileInfo(proFile).exists()) { |
|
248 |
cout << "Error: Could not find project file in current directory." << endl; |
|
249 |
return -1; |
|
250 |
} |
|
251 |
debugOutput(QString::fromLatin1("Using Project File:").append(proFile),1); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
252 |
}else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
253 |
if (!QFileInfo(proFile).exists()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
cout << "Error: Project file does not exist " << qPrintable(proFile) << endl; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
255 |
return -1; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
256 |
} |
0 | 257 |
} |
258 |
||
259 |
Option::before_user_vars.append("CONFIG+=build_pass"); |
|
260 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
261 |
// read target and deployment rules passing the .pro to use instead of |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
262 |
// relying on qmake guessing the .pro to use |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
263 |
int qmakeArgc = 2; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
264 |
QByteArray ba(QFile::encodeName(proFile)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
char* proFileEncodedName = ba.data(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
266 |
char* qmakeArgv[2] = { "qmake.exe", proFileEncodedName }; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
267 |
|
0 | 268 |
Option::qmake_mode = Option::QMAKE_GENERATE_NOTHING; |
269 |
Option::output_dir = qmake_getpwd(); |
|
270 |
if (!cacheFile.isEmpty()) |
|
271 |
Option::mkfile::cachefile = cacheFile; |
|
272 |
int ret = Option::init(qmakeArgc, qmakeArgv); |
|
273 |
if(ret != Option::QMAKE_CMDLINE_SUCCESS) { |
|
274 |
cout << "Error: could not parse " << qPrintable(proFile) << endl; |
|
275 |
return -1; |
|
276 |
} |
|
277 |
||
278 |
QMakeProperty prop; |
|
279 |
QMakeProject project(&prop); |
|
280 |
||
281 |
project.read(proFile); |
|
282 |
if (project.values("TEMPLATE").join(" ").toLower() != QString("app")) { |
|
283 |
cout << "Error: Can only test executables!" << endl; |
|
284 |
return -1; |
|
285 |
} |
|
286 |
// Check wether the project is still in debug/release mode after reading |
|
287 |
// If .pro specifies to be one mode only, we need to accept this |
|
288 |
if (project.isActiveConfig("debug")) |
|
289 |
TestConfiguration::testDebug = true; |
|
290 |
else |
|
291 |
TestConfiguration::testDebug = false; |
|
292 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
293 |
// determine what is the real mkspec to use if the default mkspec is being used |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
294 |
if (Option::mkfile::qmakespec.endsWith("/default")) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
295 |
project.values("QMAKESPEC") = project.values("QMAKESPEC_ORIGINAL"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
296 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
project.values("QMAKESPEC") = QStringList() << Option::mkfile::qmakespec; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
298 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
// ensure that QMAKESPEC is non-empty .. to meet requirements of QList::at() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
if (project.values("QMAKESPEC").isEmpty()){ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
cout << "Error: QMAKESPEC not set after parsing " << qPrintable(proFile) << endl; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
302 |
return -1; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
303 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
304 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
305 |
// ensure that QT_CE_C_RUNTIME is non-empty .. to meet requirements of QList::at() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
306 |
if (project.values("QT_CE_C_RUNTIME").isEmpty()){ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
cout << "Error: QT_CE_C_RUNTIME not defined in mkspec/qconfig.pri " << qPrintable(project.values("QMAKESPEC").join(" ")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
308 |
return -1; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
309 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
310 |
|
0 | 311 |
QString destDir = project.values("DESTDIR").join(" "); |
312 |
if (!destDir.isEmpty()) { |
|
313 |
if (QDir::isRelativePath(destDir)) { |
|
314 |
QFileInfo fi(proFile); |
|
315 |
if (destDir == QLatin1String(".")) |
|
316 |
destDir = fi.absolutePath() + "/" + destDir + "/" + (TestConfiguration::testDebug ? "debug" : "release"); |
|
317 |
else |
|
318 |
destDir = fi.absolutePath() + QDir::separator() + destDir; |
|
319 |
} |
|
320 |
} else { |
|
321 |
QFileInfo fi(proFile); |
|
322 |
destDir = fi.absolutePath(); |
|
323 |
destDir += QDir::separator() + QLatin1String(TestConfiguration::testDebug ? "debug" : "release"); |
|
324 |
} |
|
325 |
||
326 |
DeploymentList qtDeploymentList; |
|
327 |
DeploymentList projectDeploymentList; |
|
328 |
||
329 |
TestConfiguration::localExecutable = Option::fixPathToLocalOS(destDir + QDir::separator() + project.values("TARGET").join(" ") + QLatin1String(".exe")); |
|
330 |
TestConfiguration::remoteTestPath = QLatin1String("\\Program Files\\") + Option::fixPathToLocalOS(project.values("TARGET").join(QLatin1String(" "))); |
|
331 |
if (!arguments.contains(QLatin1String("-libpath"), Qt::CaseInsensitive)) |
|
332 |
TestConfiguration::remoteLibraryPath = TestConfiguration::remoteTestPath; |
|
333 |
||
334 |
QString targetExecutable = Option::fixPathToLocalOS(project.values("TARGET").join(QLatin1String(" "))); |
|
335 |
int last = targetExecutable.lastIndexOf(QLatin1Char('\\')); |
|
336 |
targetExecutable = targetExecutable.mid( last == -1 ? 0 : last+1 ); |
|
337 |
TestConfiguration::remoteExecutable = TestConfiguration::remoteTestPath + QDir::separator() + targetExecutable + QLatin1String(".exe"); |
|
338 |
projectDeploymentList.append(CopyItem(TestConfiguration::localExecutable , TestConfiguration::remoteExecutable)); |
|
339 |
||
340 |
// deploy |
|
341 |
#ifdef QT_CETEST_NO_ACTIVESYNC |
|
342 |
CeTcpSyncConnection connection; |
|
343 |
#else |
|
344 |
ActiveSyncConnection connection; |
|
345 |
#endif |
|
346 |
if (!connection.connect()) { |
|
347 |
cout << "Error: Could not connect to device!" << endl; |
|
348 |
return -1; |
|
349 |
} |
|
350 |
DeploymentHandler deployment; |
|
351 |
deployment.setConnection(&connection); |
|
352 |
||
353 |
deployment.initQtDeploy(&project, qtDeploymentList, TestConfiguration::remoteLibraryPath); |
|
354 |
deployment.initProjectDeploy(&project , projectDeploymentList, TestConfiguration::remoteTestPath); |
|
355 |
||
356 |
// add qt.conf |
|
357 |
if (TestConfiguration::localQtConf != QLatin1String("no")) { |
|
358 |
QString qtConfOrigin = QFileInfo(TestConfiguration::localQtConf).absoluteFilePath(); |
|
359 |
QString qtConfTarget = Option::fixPathToLocalOS(TestConfiguration::remoteTestPath + QDir::separator() + QLatin1String("qt.conf")); |
|
360 |
projectDeploymentList.append(CopyItem(qtConfOrigin, qtConfTarget)); |
|
361 |
} |
|
362 |
||
363 |
if (!deployment.deviceDeploy(qtDeploymentList) || !deployment.deviceDeploy(projectDeploymentList)) { |
|
364 |
cout << "Error: Could not copy file(s) to device" << endl; |
|
365 |
return -1; |
|
366 |
} |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
367 |
// device power mode |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
368 |
if (keepAwake) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
369 |
{ |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
370 |
int retVal = 0; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
371 |
if (!connection.setDeviceAwake(true, &retVal)) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
372 |
cout << "Error: Could not set unattended mode on device" << endl; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
373 |
return -1; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
374 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
375 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
376 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
377 |
// reset device |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
378 |
if (deviceReset) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
379 |
{ |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
380 |
if (!connection.resetDevice()) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
381 |
//if (!connection.toggleDevicePower( &retVal)) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
382 |
cout << "Error: Could not reset the device" << endl; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
383 |
return -1; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
384 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
385 |
cout << " Entering sleep after reset for " << SLEEP_AFTER_RESET / 1000 << " seconds ... " << endl; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
386 |
Sleep(SLEEP_AFTER_RESET); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
387 |
cout << " ... woke up. " << endl; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
388 |
connection.disconnect(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
389 |
// reconnect after reset |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
390 |
int retryCount = 21; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
391 |
while (--retryCount) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
392 |
{ |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
393 |
if (!connection.connect()) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
394 |
Sleep(SLEEP_RECONNECT); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
395 |
else |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
396 |
break; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
397 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
398 |
if (!connection.isConnected()) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
399 |
{ |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
400 |
cout << "Error: Could not connect to device!" << endl; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
401 |
return -1; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
402 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
403 |
} |
0 | 404 |
|
405 |
// launch |
|
406 |
launchArguments.append("-o"); |
|
407 |
launchArguments.append(TestConfiguration::remoteResultFile); |
|
408 |
||
409 |
cout << endl << "Remote Launch:" << qPrintable(TestConfiguration::remoteExecutable) << " " << qPrintable(launchArguments.join(" ")) << endl; |
|
410 |
if (!connection.execute(TestConfiguration::remoteExecutable, launchArguments.join(" "), timeout)) { |
|
411 |
cout << "Error: Could not execute target file" << endl; |
|
412 |
return -1; |
|
413 |
} |
|
414 |
||
415 |
||
416 |
// copy result file |
|
417 |
// show results |
|
418 |
if (resultFile.isEmpty()) { |
|
419 |
QString tempResultFile = Option::fixPathToLocalOS(QDir::tempPath() + "/qt_ce_temp_result_file.txt"); |
|
420 |
if (connection.copyFileFromDevice(TestConfiguration::remoteResultFile, tempResultFile)) { |
|
421 |
QFile file(tempResultFile); |
|
422 |
QByteArray arr; |
|
423 |
if (file.open(QIODevice::ReadOnly)) { |
|
424 |
arr = file.readAll(); |
|
425 |
cout << arr.constData() << endl; |
|
426 |
} |
|
427 |
file.close(); |
|
428 |
file.remove(); |
|
429 |
} |
|
430 |
} else { |
|
431 |
connection.copyFileFromDevice(TestConfiguration::remoteResultFile, resultFile); |
|
432 |
} |
|
433 |
||
434 |
// delete |
|
435 |
connection.deleteFile(TestConfiguration::remoteResultFile); |
|
436 |
if (cleanupQt) |
|
437 |
deployment.cleanup(qtDeploymentList); |
|
438 |
if (cleanupProject) |
|
439 |
deployment.cleanup(projectDeploymentList); |
|
440 |
return 0; |
|
441 |
} |