Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
391 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @file main.cpp | ||
* @copyright 2012 Jolla Ltd. | ||
* @author Martin Kampas <martin.kampas@tieto.com> | ||
* @date 2012 | ||
*/ | ||
|
||
#include <QtTest/QtTest> | ||
|
||
#include "rndssuclitest.h" | ||
|
||
int main(int argc, char **argv){ | ||
RndSsuCliTest rndSsuCliTest; | ||
|
||
if (QTest::qExec(&rndSsuCliTest, argc, argv)) | ||
return 1; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
/** | ||
* @file rndssuclitest.cpp | ||
* @copyright 2013 Jolla Ltd. | ||
* @author Martin Kampas <martin.kampas@tieto.com> | ||
* @date 2013 | ||
*/ | ||
|
||
#include "rndssuclitest.h" | ||
|
||
#include <stdlib.h> | ||
#include <zypp/media/UrlResolverPlugin.h> | ||
|
||
#include <QtTest/QtTest> | ||
|
||
typedef QStringList Args; // improve readability | ||
|
||
class RndSsuCliTest::Process { | ||
public: | ||
enum ExpectedResult { | ||
ExpectSuccess, | ||
ExpectFail | ||
}; | ||
|
||
Process() : m_expectFail(false), m_timedOut(false) {} | ||
|
||
QString execute(const QString &program, const QStringList &arguments, | ||
bool expectedResult = ExpectSuccess){ | ||
Q_ASSERT(processStatus() == NotRunning); | ||
m_program = program; | ||
m_arguments = arguments; | ||
m_expectFail = expectedResult == ExpectFail; | ||
m_process.start(program, arguments); | ||
m_timedOut = !m_process.waitForFinished(); | ||
return m_process.readAllStandardOutput(); | ||
} | ||
|
||
bool hasError(){ | ||
return m_timedOut | ||
|| m_process.error() != QProcess::UnknownError | ||
|| m_process.exitStatus() != QProcess::NormalExit | ||
|| (m_process.exitCode() != 0) != m_expectFail; | ||
} | ||
|
||
QString fmtErrorMessage(){ | ||
Q_ASSERT(hasError()); | ||
|
||
QStringList reasons; | ||
if (m_timedOut){ | ||
reasons.append("Timed out"); | ||
}else if (m_process.exitStatus() != QProcess::NormalExit){ | ||
reasons.append("Process crashed"); | ||
}else if (m_expectFail && (m_process.exitCode() == 0)){ | ||
reasons.append("Did not fail while it was expected to"); | ||
}else{ | ||
if (m_process.error() != QProcess::UnknownError){ | ||
reasons.append(m_process.errorString()); | ||
} | ||
const QString errorOut = m_process.readAllStandardError(); | ||
if (!errorOut.isEmpty()){ | ||
reasons.append(errorOut); | ||
} | ||
} | ||
|
||
return QString("Failed to execute `%1 %2`: %3") | ||
.arg(m_program) | ||
.arg(QStringList(m_arguments).replaceInStrings(QRegExp("^|$"), "\"").join(" ")) | ||
.arg(reasons.join(": ")); | ||
} | ||
|
||
private: | ||
QProcess m_process; | ||
QString m_program; | ||
QStringList m_arguments; | ||
bool m_expectFail; | ||
bool m_timedOut; | ||
}; | ||
|
||
void RndSsuCliTest::initTestCase(){ | ||
Process mktemp; | ||
tempDir = | ||
mktemp.execute("mktemp", Args() << "-t" << "-d" << "ut_rndssucli.XXX").trimmed(); | ||
QVERIFY2(!mktemp.hasError(), qPrintable(mktemp.fmtErrorMessage())); | ||
|
||
QVERIFY2(QFileInfo(tempDir).isDir(), qPrintable( | ||
QString("Temporary directory disappeared: '%1'").arg(tempDir))); | ||
|
||
setenv("LD_PRELOAD", qPrintable(QString("%1/libsandboxhook.so").arg(TESTS_PATH)), 1); | ||
setenv("SSU_TESTS_SANDBOX", qPrintable(QString("%1/configroot").arg(tempDir)), 1); | ||
} | ||
|
||
void RndSsuCliTest::cleanupTestCase(){ | ||
|
||
if (tempDir.isEmpty()){ | ||
return; | ||
} | ||
|
||
Process rm; | ||
rm.execute("rm", Args() << "-rf" << tempDir); | ||
QVERIFY2(!rm.hasError(), qPrintable(rm.fmtErrorMessage())); | ||
} | ||
|
||
void RndSsuCliTest::init(){ | ||
Q_ASSERT(!tempDir.isEmpty()); | ||
|
||
QVERIFY2(QFileInfo(tempDir).isDir(), qPrintable( | ||
QString("Temporary directory disappeared: '%1'").arg(tempDir))); | ||
QVERIFY2(QDir(tempDir).entryList(QDir::NoDotAndDotDot).count() == 0, qPrintable( | ||
QString("Garbage in temporary directory: '%1'").arg(tempDir))); | ||
|
||
Process cp; | ||
cp.execute("cp", Args() << "-r" << QString("%1/configroot").arg(TESTS_DATA_PATH) << tempDir); | ||
QVERIFY2(!cp.hasError(), qPrintable(cp.fmtErrorMessage())); | ||
} | ||
|
||
void RndSsuCliTest::cleanup(){ | ||
Q_ASSERT(!tempDir.isEmpty()); | ||
|
||
Process rm; | ||
rm.execute("rm", Args() << "-rf" << QString("%1/configroot").arg(tempDir)); | ||
QVERIFY2(!rm.hasError(), qPrintable(rm.fmtErrorMessage())); | ||
} | ||
|
||
void RndSsuCliTest::testSubcommandFlavour(){ | ||
Process ssu; | ||
QString output; | ||
|
||
// set flavour to 'release' | ||
ssu.execute("ssu", Args() << "flavour" << "release"); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
output = ssu.execute("ssu", Args() << "flavour").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device flavour is currently: release")); | ||
|
||
// set flavour to 'testing' | ||
ssu.execute("ssu", Args() << "flavour" << "testing"); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
output = ssu.execute("ssu", Args() << "flavour").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device flavour is currently: testing")); | ||
} | ||
|
||
void RndSsuCliTest::testSubcommandRelease(){ | ||
Process ssu; | ||
QString output; | ||
|
||
// set release to latest | ||
ssu.execute("ssu", Args() << "release" << "latest"); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
output = ssu.execute("ssu", Args() << "release").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device release is currently: latest")); | ||
|
||
// set release to next | ||
ssu.execute("ssu", Args() << "release" << "next"); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
output = ssu.execute("ssu", Args() << "release").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device release is currently: next")); | ||
|
||
// verify the mode is release | ||
output = ssu.execute("ssu", Args() << "mode").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device mode is: 0 ()")); | ||
|
||
// set RnD release to latest | ||
ssu.execute("ssu", Args() << "release" << "-r" << "latest"); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
output = ssu.execute("ssu", Args() << "release" << "-r").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device release (RnD) is currently: latest")); | ||
|
||
// set RnD release to next | ||
ssu.execute("ssu", Args() << "release" << "-r" << "next"); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
output = ssu.execute("ssu", Args() << "release" << "-r").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device release (RnD) is currently: next")); | ||
|
||
// verify the mode is RnD | ||
output = ssu.execute("ssu", Args() << "mode").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device mode is: 2 (RndMode)")); | ||
} | ||
|
||
void RndSsuCliTest::testSubcommandMode(){ | ||
Process ssu; | ||
QString output; | ||
|
||
// set release mode | ||
ssu.execute("ssu", Args() << "mode" << "0"); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
output = ssu.execute("ssu", Args() << "mode").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device mode is: 0 ()")); | ||
|
||
// set RnD mode | ||
ssu.execute("ssu", Args() << "mode" << "2"); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
output = ssu.execute("ssu", Args() << "mode").trimmed(); | ||
QVERIFY2(!ssu.hasError(), qPrintable(ssu.fmtErrorMessage())); | ||
|
||
QCOMPARE(output, QString("Device mode is: 2 (RndMode)")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @file rndssuclitest.h | ||
* @copyright 2013 Jolla Ltd. | ||
* @author Martin Kampas <martin.kampas@tieto.com> | ||
* @date 2013 | ||
*/ | ||
|
||
#ifndef _RNDSSUCLITEST_H | ||
#define _RNDSSUCLITEST_H | ||
|
||
#include <QObject> | ||
|
||
class RndSsuCliTest: public QObject { | ||
Q_OBJECT | ||
|
||
class Process; | ||
|
||
private slots: | ||
void initTestCase(); | ||
void cleanupTestCase(); | ||
void init(); | ||
void cleanup(); | ||
|
||
void testSubcommandFlavour(); | ||
void testSubcommandRelease(); | ||
void testSubcommandMode(); | ||
|
||
private: | ||
QString tempDir; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[file.exists] | ||
SDK=/mer-sdk-chroot | ||
|
||
[systeminfo.equals] | ||
|
||
[cpuinfo.contains] | ||
N900=Nokia RX-51 board | ||
N950=Nokia RM-680 board | ||
N9=Nokia RM-696 board | ||
|
||
[arch.equals] | ||
generic-x86=i586 | ||
|
||
[variants] | ||
N950=N9 | ||
|
||
[N9] | ||
family=n950-n9 | ||
adaptation-repos=n9xx-common,n950-n9 | ||
|
||
[N900] | ||
family=n900 | ||
adaptation-repos=n9xx-common,n900 | ||
|
||
[SDK] | ||
|
||
[generic-x86] | ||
family=x86 | ||
adaptation-repos=x86 | ||
|
||
[UNKNOWN] | ||
family=UNKNOWN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[all] | ||
credentials=jolla | ||
credentials-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/credentials.xml | ||
register-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/register.xml | ||
|
||
[release] | ||
mer-core=https://%(packagesDomain)/%(release)/mer/%(arch)/%(debugSplit)/ | ||
|
||
[rnd] | ||
mer-core=https://%(packagesDomain)/mer/%(release)/builds/%(arch)/%(debugSplit)/ | ||
|
||
[devel-flavour] | ||
flavour-pattern= | ||
|
||
[release-flavour] | ||
flavour-pattern=:/release | ||
|
||
[testing-flavour] | ||
flavour-pattern=:/testing | ||
|
||
[example-domain] | ||
dumpDomain=dump.example.com | ||
packagesDomain=packages.example.com | ||
ssuRegDomain=ssu.example.com | ||
ssuRegPath=ssu/device | ||
|
||
# fallback if domain is not matched or not set | ||
[default-domain] | ||
dumpDomain=dump.testing.com | ||
packagesDomain=packages.testing.com | ||
ssuRegDomain=ssu.testing.com | ||
ssuRegPath=ssu/device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[General] | ||
initialized=true | ||
flavour=testing | ||
registered=false | ||
rndRelease=latest | ||
release= | ||
adaptation= | ||
ca-certificate= | ||
credentials-scope=example | ||
|
||
[repository-urls] | ||
|
||
[repository-url-variables] |
Oops, something went wrong.