Commit 79db165d authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Revert "Remote Linux: Rework device testing"



This reverts commit 934c067ddf365c6f12b1e4a1e431f27610b32f7d,
because it breaks running remote Linux applications due to 
buggy refactoring of the remote ports gatherer.

Change-Id: I15fd8d4f3e76452a8c5c735316991bd00900444f
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent 3b67e5dd
......@@ -50,6 +50,7 @@ HEADERS += \
maemorunconfiguration.h \
maddeuploadandinstallpackagesteps.h \
maemodeploybymountsteps.h \
maddedevicetester.h \
maddedeviceconfigurationfactory.h \
SOURCES += \
......@@ -95,6 +96,7 @@ SOURCES += \
maddedeviceconfigurationfactory.cpp \
maddeuploadandinstallpackagesteps.cpp \
maemodeploybymountsteps.cpp \
maddedevicetester.cpp \
maemorunconfiguration.cpp
FORMS += \
......
......@@ -31,9 +31,9 @@
**************************************************************************/
#include "maddedeviceconfigurationfactory.h"
#include "maddedevicetester.h"
#include "maemoconstants.h"
#include "maemodeviceconfigwizard.h"
#include "maemoglobal.h"
#include <remotelinux/linuxdevicetestdialog.h>
#include <remotelinux/publickeydeploymentdialog.h>
......@@ -46,8 +46,10 @@ using namespace RemoteLinux;
namespace Madde {
namespace Internal {
namespace {
const char MaddeDeviceTestActionId[] = "Madde.DeviceTestAction";
const char MaddeRemoteProcessesActionId[] = "Madde.RemoteProcessesAction";
} // anonymous namespace
MaddeDeviceConfigurationFactory::MaddeDeviceConfigurationFactory(QObject *parent)
: ILinuxDeviceConfigurationFactory(parent)
......@@ -105,27 +107,8 @@ QDialog *MaddeDeviceConfigurationFactory::createDeviceAction(const QString &acti
{
Q_ASSERT(supportedDeviceActionIds().contains(actionId));
if (actionId == QLatin1String(MaddeDeviceTestActionId)) {
QList<LinuxDeviceTester *> tests;
tests.append(new AuthenticationTester(deviceConfig));
tests.append(new LinuxDeviceTester(deviceConfig,
tr("Checking kernel version..."),
QLatin1String("uname -rsm")));
QString infoCmd = QLatin1String("dpkg-query -W -f "
"'${Package} ${Version} ${Status}\\n' 'libqt*' | "
"grep ' installed$' | cut -d' ' -f-2");
if (deviceConfig->osType() == MeeGoOsType)
infoCmd = QLatin1String("rpm -qa 'libqt*' --queryformat '%{NAME} %{VERSION}\\n'");
tests.append(new LinuxDeviceTester(deviceConfig, tr("Checking for Qt libraries..."), infoCmd));
tests.append(new LinuxDeviceTester(deviceConfig,
tr("Checking for connectivity support..."),
QLatin1String("test -x ") + MaemoGlobal::devrootshPath()));
tests.append(new LinuxDeviceTester(deviceConfig,
tr("Checking for QML tooling support..."),
QLatin1String("test -d /usr/lib/qt4/plugins/qmltooling")));
tests.append(new UsedPortsTester(deviceConfig));
return new LinuxDeviceTestDialog(tests, parent);
}
if (actionId == QLatin1String(MaddeDeviceTestActionId))
return new LinuxDeviceTestDialog(deviceConfig, new MaddeDeviceTester, parent);
if (actionId == QLatin1String(MaddeRemoteProcessesActionId))
return new RemoteLinuxProcessesDialog(new GenericRemoteLinuxProcessList(deviceConfig), parent);
if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId))
......
......@@ -37,8 +37,6 @@
namespace Madde {
namespace Internal {
const char MaddeDeviceTestActionId[] = "Madde.DeviceTestAction";
class MaddeDeviceConfigurationFactory : public RemoteLinux::ILinuxDeviceConfigurationFactory
{
Q_OBJECT
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "maddedevicetester.h"
#include "maemoconstants.h"
#include "maemoglobal.h"
#include <remotelinux/linuxdeviceconfiguration.h>
#include <utils/qtcassert.h>
#include <utils/ssh/sshremoteprocessrunner.h>
#include <QtCore/QRegExp>
using namespace RemoteLinux;
using namespace Utils;
namespace Madde {
namespace Internal {
namespace {
const char QmlToolingDirectory[] = "/usr/lib/qt4/plugins/qmltooling";
} // anonymous namespace
MaddeDeviceTester::MaddeDeviceTester(QObject *parent)
: AbstractLinuxDeviceTester(parent),
m_genericTester(new GenericLinuxDeviceTester(this)),
m_state(Inactive),
m_processRunner(0)
{
}
MaddeDeviceTester::~MaddeDeviceTester()
{
}
void MaddeDeviceTester::testDevice(const LinuxDeviceConfiguration::ConstPtr &deviceConfiguration)
{
QTC_ASSERT(m_state == Inactive, return);
m_deviceConfiguration = deviceConfiguration;
m_result = TestSuccess;
m_state = GenericTest;
connect(m_genericTester, SIGNAL(progressMessage(QString)), SIGNAL(progressMessage(QString)));
connect(m_genericTester, SIGNAL(errorMessage(QString)), SIGNAL(errorMessage(QString)));
connect(m_genericTester, SIGNAL(finished(RemoteLinux::AbstractLinuxDeviceTester::TestResult)),
SLOT(handleGenericTestFinished(RemoteLinux::AbstractLinuxDeviceTester::TestResult)));
m_genericTester->testDevice(deviceConfiguration);
}
void MaddeDeviceTester::stopTest()
{
QTC_ASSERT(m_state != Inactive, return);
switch (m_state) {
case Inactive:
break;
case GenericTest:
m_genericTester->stopTest();
break;
case QtTest:
case MadDeveloperTest:
case QmlToolingTest:
m_processRunner->cancel();
break;
}
m_result = TestFailure;
setFinished();
}
void MaddeDeviceTester::handleGenericTestFinished(TestResult result)
{
QTC_ASSERT(m_state == GenericTest, return);
if (result == TestFailure) {
m_result = TestFailure;
setFinished();
return;
}
if (!m_processRunner)
m_processRunner = new SshRemoteProcessRunner(this);
connect(m_processRunner, SIGNAL(connectionError()), SLOT(handleConnectionError()));
connect(m_processRunner, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleStdout(QByteArray)));
connect(m_processRunner, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleStderr(QByteArray)));
connect(m_processRunner, SIGNAL(processClosed(int)), SLOT(handleProcessFinished(int)));
QString qtInfoCmd;
if (m_deviceConfiguration->osType() == QLatin1String(MeeGoOsType)) {
qtInfoCmd = QLatin1String("rpm -qa 'libqt*' --queryformat '%{NAME} %{VERSION}\\n'");
} else {
qtInfoCmd = QLatin1String("dpkg-query -W -f "
"'${Package} ${Version} ${Status}\n' 'libqt*' |grep ' installed$'");
}
emit progressMessage(tr("Checking for Qt libraries..."));
m_stdout.clear();
m_stderr.clear();
m_state = QtTest;
m_processRunner->run(qtInfoCmd.toUtf8(), m_genericTester->connection()->connectionParameters());
}
void MaddeDeviceTester::handleConnectionError()
{
QTC_ASSERT(m_state != Inactive, return);
emit errorMessage(tr("SSH connection error: %1\n")
.arg(m_processRunner->lastConnectionErrorString()));
m_result = TestFailure;
setFinished();
}
void MaddeDeviceTester::handleStdout(const QByteArray &data)
{
QTC_ASSERT(m_state == QtTest || m_state == MadDeveloperTest || m_state == QmlToolingTest,
return);
m_stdout += data;
}
void MaddeDeviceTester::handleStderr(const QByteArray &data)
{
QTC_ASSERT(m_state == QtTest || m_state == MadDeveloperTest || m_state == QmlToolingTest,
return);
m_stderr += data;
}
void MaddeDeviceTester::handleProcessFinished(int exitStatus)
{
switch (m_state) {
case QtTest:
handleQtTestFinished(exitStatus);
break;
case MadDeveloperTest:
handleMadDeveloperTestFinished(exitStatus);
break;
case QmlToolingTest:
handleQmlToolingTestFinished(exitStatus);
break;
default:
qWarning("%s: Unexpected state %d.", Q_FUNC_INFO, m_state);
}
}
void MaddeDeviceTester::handleQtTestFinished(int exitStatus)
{
if (exitStatus != SshRemoteProcess::ExitedNormally
|| m_processRunner->processExitCode() != 0) {
if (!m_stderr.isEmpty()) {
emit errorMessage(tr("Error checking for Qt libraries: %1\n")
.arg(QString::fromUtf8(m_stderr)));
} else {
emit errorMessage(tr("Error checking for Qt libraries.\n"));
}
m_result = TestFailure;
} else {
emit progressMessage(processedQtLibsList());
}
m_stdout.clear();
m_stderr.clear();
emit progressMessage(tr("Checking for connectivity support..."));
m_state = MadDeveloperTest;
m_processRunner->run(QString(QLatin1String("test -x") + MaemoGlobal::devrootshPath()).toUtf8(),
m_genericTester->connection()->connectionParameters());
}
void MaddeDeviceTester::handleMadDeveloperTestFinished(int exitStatus)
{
if (exitStatus != SshRemoteProcess::ExitedNormally) {
if (!m_stderr.isEmpty()) {
emit errorMessage(tr("Error checking for connectivity tool: %1\n")
.arg(QString::fromUtf8(m_stderr)));
} else {
emit errorMessage(tr("Error checking for connectivity tool.\n"));
}
m_result = TestFailure;
} else if (m_processRunner->processExitCode() != 0) {
QString message = tr("Connectivity tool not installed on device. "
"Deployment currently not possible.");
if (m_deviceConfiguration->osType() == QLatin1String(HarmattanOsType)) {
message += tr("Please switch the device to developer mode "
"via Settings -> Security.");
}
emit errorMessage(message + QLatin1Char('\n'));
m_result = TestFailure;
} else {
emit progressMessage(tr("Connectivity tool present.\n"));
}
if (m_deviceConfiguration->osType() != QLatin1String(HarmattanOsType)) {
setFinished();
return;
}
m_stdout.clear();
m_stderr.clear();
emit progressMessage(tr("Checking for QML tooling support..."));
m_state = QmlToolingTest;
m_processRunner->run(QString(QLatin1String("test -d ")
+ QLatin1String(QmlToolingDirectory)).toUtf8(),
m_genericTester->connection()->connectionParameters());
}
void MaddeDeviceTester::handleQmlToolingTestFinished(int exitStatus)
{
if (exitStatus != SshRemoteProcess::ExitedNormally) {
if (!m_stderr.isEmpty()) {
emit errorMessage(tr("Error checking for QML tooling support: %1\n")
.arg(QString::fromUtf8(m_stderr)));
} else {
emit errorMessage(tr("Error checking for QML tooling support.\n"));
}
m_result = TestFailure;
} else if (m_processRunner->processExitCode() != 0) {
emit errorMessage(tr("Missing directory '%1'. You will not be able to do "
"QML debugging on this device.\n").arg(QmlToolingDirectory));
m_result = TestFailure;
} else {
emit progressMessage(tr("QML tooling support present.\n"));
}
setFinished();
}
QString MaddeDeviceTester::processedQtLibsList()
{
QString unfilteredLibs = QString::fromUtf8(m_stdout);
QString filteredLibs;
QString patternString;
if (m_deviceConfiguration->osType() == QLatin1String(MeeGoOsType))
patternString = QLatin1String("(libqt\\S+) ((\\d+)\\.(\\d+)\\.(\\d+))");
else
patternString = QLatin1String("(\\S+) (\\S*(\\d+)\\.(\\d+)\\.(\\d+)\\S*) \\S+ \\S+ \\S+");
const QRegExp packagePattern(patternString);
int index = packagePattern.indexIn(unfilteredLibs);
if (index == -1)
return tr("No Qt packages installed.");
do {
filteredLibs += QLatin1String(" ") + packagePattern.cap(1) + QLatin1String(": ")
+ packagePattern.cap(2) + QLatin1Char('\n');
index = packagePattern.indexIn(unfilteredLibs, index + packagePattern.cap(0).length());
} while (index != -1);
return filteredLibs;
}
void MaddeDeviceTester::setFinished()
{
m_state = Inactive;
disconnect(m_genericTester, 0, this, 0);
if (m_processRunner)
disconnect(m_processRunner, 0, this, 0);
emit finished(m_result);
}
} // namespace Internal
} // namespace Madde
......@@ -29,70 +29,57 @@
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef MADDEDEVICETESTER_H
#define MADDEDEVICETESTER_H
#ifndef SIMPLERUNNER_H
#define SIMPLERUNNER_H
#include <remotelinux/linuxdevicetester.h>
#include "remotelinux_export.h"
#include <QtCore/QByteArray>
#include <utils/ssh/sshconnection.h>
#include <QtCore/QObject>
QT_FORWARD_DECLARE_CLASS(QString)
namespace RemoteLinux {
class LinuxDeviceConfiguration;
namespace Utils {
class SshRemoteProcessRunner;
}
namespace Madde {
namespace Internal {
class SimpleRunnerPrivate;
} // namespace Internal
// -----------------------------------------------------------------------
// SimpleRunner:
// -----------------------------------------------------------------------
class REMOTELINUX_EXPORT SimpleRunner : public QObject
class MaddeDeviceTester : public RemoteLinux::AbstractLinuxDeviceTester
{
Q_OBJECT
public:
SimpleRunner(const QSharedPointer<const LinuxDeviceConfiguration> &deviceConfiguration,
const QString &commandline);
~SimpleRunner();
virtual QString commandLine() const;
explicit MaddeDeviceTester(QObject *parent = 0);
~MaddeDeviceTester();
virtual void run();
virtual void cancel();
void testDevice(const QSharedPointer<const RemoteLinux::LinuxDeviceConfiguration> &deviceConfiguration);
void stopTest();
signals:
void aboutToStart();
void started();
void progressMessage(const QString &message);
void errorMessage(const QString &message);
// 0 on success, other value on failure.
void finished(int result);
protected slots:
private slots:
void handleGenericTestFinished(RemoteLinux::AbstractLinuxDeviceTester::TestResult result);
void handleConnectionError();
void handleStdout(const QByteArray &data);
void handleStderr(const QByteArray &data);
void handleProcessFinished(int exitStatus);
virtual void handleConnectionFailure();
virtual void handleStdOutput(const QByteArray &data);
virtual void handleStdError(const QByteArray &data);
// 0 on success, any other value on failure.
virtual int processFinished(int exitStatus);
protected:
void setCommandLine(const QString &cmd);
Utils::SshConnectionParameters sshParameters() const;
private:
Internal::SimpleRunnerPrivate *const d;
enum State { Inactive, GenericTest, QtTest, MadDeveloperTest, QmlToolingTest };
void handleQtTestFinished(int exitStatus);
void handleMadDeveloperTestFinished(int exitStatus);
void handleQmlToolingTestFinished(int exitStatus);
QString processedQtLibsList();
void setFinished();
RemoteLinux::GenericLinuxDeviceTester * const m_genericTester;
State m_state;
TestResult m_result;
Utils::SshRemoteProcessRunner *m_processRunner;
QSharedPointer<const RemoteLinux::LinuxDeviceConfiguration> m_deviceConfiguration;
QByteArray m_stdout;
QByteArray m_stderr;
};
} // namespace RemoteLinux
} // namespace Internal
} // namespace Madde
#endif // SIMPLERUNNER_H
#endif // MADDEDEVICETESTER_H
......@@ -52,7 +52,7 @@ MaemoDeploymentMounter::MaemoDeploymentMounter(QObject *parent)
: QObject(parent),
m_state(Inactive),
m_mounter(new MaemoRemoteMounter(this)),
m_portsGatherer(0)
m_portsGatherer(new RemoteLinuxUsedPortsGatherer(this))
{
connect(m_mounter, SIGNAL(error(QString)), SLOT(handleMountError(QString)));
connect(m_mounter, SIGNAL(mounted()), SLOT(handleMounted()));
......@@ -61,6 +61,11 @@ MaemoDeploymentMounter::MaemoDeploymentMounter(QObject *parent)
SIGNAL(reportProgress(QString)));
connect(m_mounter, SIGNAL(debugOutput(QString)),
SIGNAL(debugOutput(QString)));
connect(m_portsGatherer, SIGNAL(error(QString)),
SLOT(handlePortsGathererError(QString)));
connect(m_portsGatherer, SIGNAL(portListReady()),
SLOT(handlePortListReady()));
}
MaemoDeploymentMounter::~MaemoDeploymentMounter() {}
......@@ -137,12 +142,7 @@ void MaemoDeploymentMounter::handleUnmounted()
break;
case UnmountingCurrentDirs:
setState(GatheringPorts);
if (m_portsGatherer)
delete m_portsGatherer;
m_portsGatherer = new RemoteLinuxUsedPortsGatherer(m_devConf);
connect(m_portsGatherer, SIGNAL(finished(RemoteLinux::LinuxDeviceTester::TestResult)),
this, SLOT(handlePortListReady(RemoteLinux::LinuxDeviceTester::TestResult)));
m_portsGatherer->run();
m_portsGatherer->start(m_connection, m_devConf);
break;
case UnmountingCurrentMounts:
setState(Inactive);
......@@ -166,20 +166,16 @@ void MaemoDeploymentMounter::handlePortsGathererError(const QString &errorMsg)
emit error(errorMsg);
}
void MaemoDeploymentMounter::handlePortListReady(LinuxDeviceTester::TestResult result)
void MaemoDeploymentMounter::handlePortListReady()
{
QTC_ASSERT(m_state == GatheringPorts || m_state == Inactive, return);
if (m_state == Inactive)
return;
if (result == LinuxDeviceTester::TestFailure) {
handlePortsGathererError(tr("Failed to gather port information."));
} else {
setState(Mounting);
m_freePorts = MaemoGlobal::freePorts(m_devConf, m_buildConfig->qtVersion());
m_mounter->mount(&m_freePorts, m_portsGatherer);
}
setState(Mounting);
m_freePorts = MaemoGlobal::freePorts(m_devConf, m_buildConfig->qtVersion());
m_mounter->mount(&m_freePorts, m_portsGatherer);
}
void MaemoDeploymentMounter::handleMountError(const QString &errorMsg)
......
......@@ -35,7 +35,6 @@
#include "maemomountspecification.h"
#include <remotelinux/linuxdevicetester.h>
#include <remotelinux/portlist.h>
#include <QtCore/QList>
......@@ -80,7 +79,7 @@ private slots:
void handleUnmounted();
void handleMountError(const QString &errorMsg);
void handlePortsGathererError(const QString &errorMsg);
void handlePortListReady(RemoteLinux::LinuxDeviceTester::TestResult result);
void handlePortListReady();
void handleConnectionError();
private:
......@@ -97,7 +96,7 @@ private:
QSharedPointer<Utils::SshConnection> m_connection;
QSharedPointer<const RemoteLinux::LinuxDeviceConfiguration> m_devConf;
MaemoRemoteMounter * const m_mounter;
RemoteLinux::RemoteLinuxUsedPortsGatherer *m_portsGatherer;
RemoteLinux::RemoteLinuxUsedPortsGatherer * const m_portsGatherer;
RemoteLinux::PortList m_freePorts;
QList<MaemoMountSpecification> m_mountSpecs;
const Qt4ProjectManager::Qt4BuildConfiguration *m_buildConfig;
......
......@@ -30,23 +30,21 @@
**************************************************************************/
#include "maemodeviceconfigwizard.h"
#include "maddedeviceconfigurationfactory.h"
#include "ui_maemodeviceconfigwizardkeycreationpage.h"
#include "ui_maemodeviceconfigwizardkeydeploymentpage.h"
#include "ui_maemodeviceconfigwizardpreviouskeysetupcheckpage.h"
#include "ui_maemodeviceconfigwizardreusekeyscheckpage.h"
#include "ui_maemodeviceconfigwizardstartpage.h"
#include "maddedevicetester.h"
#include "maemoconstants.h"
#include "maemoglobal.h"
#include <extensionsystem/pluginmanager.h>
#include <remotelinux/genericlinuxdeviceconfigurationwizardpages.h>
#include <remotelinux/linuxdevicetestdialog.h>
#include <remotelinux/remotelinuxutils.h>
#include <remotelinux/sshkeydeployer.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <utils/ssh/sshkeygenerator.h>
#include <QtCore/QDir>
......@@ -584,13 +582,8 @@ LinuxDeviceConfiguration::Ptr MaemoDeviceConfigWizard::deviceConfiguration()
d->wizardData.osType, d->wizardData.deviceType, PortList::fromString(freePortsSpec),
sshParams);
if (doTest) {
MaddeDeviceConfigurationFactory *factory
= ExtensionSystem::PluginManager::instance()->getObject<MaddeDeviceConfigurationFactory>();
QTC_ASSERT(factory, return LinuxDeviceConfiguration::Ptr(0));
QDialog *dlg = factory->createDeviceAction(QLatin1String(MaddeDeviceTestActionId), devConf, 0);
QTC_ASSERT(dlg, return LinuxDeviceConfiguration::Ptr(0));
dlg->exec();
delete dlg;