Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb46366' into 'master'
Jb46366

See merge request mer-core/ssu!28
  • Loading branch information
saukko committed Jun 25, 2019
2 parents 026a2fd + 030f880 commit aef653b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
20 changes: 19 additions & 1 deletion libssu/ssudeviceinfo.cpp
Expand Up @@ -52,6 +52,8 @@ QString SsuDeviceInfo::adaptationVariables(const QString &adaptationName, QHash<
{
SsuLog *ssuLog = SsuLog::instance();
QStringList adaptationRepoList = adaptationRepos();
QString model = deviceVariant(true);

// special handling for adaptation-repositories
// - check if repo is in right format (adaptation\d*)
// - check if the configuration has that many adaptation repos
Expand All @@ -74,7 +76,6 @@ QString SsuDeviceInfo::adaptationVariables(const QString &adaptationName, QHash<
storageHash->insert("adaptation", adaptationRepo);
ssuLog->print(LOG_DEBUG, "Found first adaptation " + adaptationName);

QString model = deviceVariant(true);
QHash<QString, QString> h;

// add global variables for this model
Expand All @@ -97,6 +98,23 @@ QString SsuDeviceInfo::adaptationVariables(const QString &adaptationName, QHash<

return "adaptation";
}

// If adaptation has defined repository-specific-variables and it matches to the
// repository name then also get those variables.
else if (boardMappings->contains(model + "/repository-specific-variables")) {
QStringList sections = boardMappings->value(model + "/repository-specific-variables").toStringList();
if (sections.contains(model + "-" + adaptationName)) {
QHash<QString, QString> h;

variableSection(model + "-" + adaptationName, &h);

QHash<QString, QString>::const_iterator i = h.constBegin();
while (i != h.constEnd()) {
storageHash->insert(i.key(), i.value());
i++;
}
}
}
return adaptationName;
}

Expand Down
11 changes: 11 additions & 0 deletions tests/ut_deviceinfo/deviceinfotest.cpp
Expand Up @@ -26,6 +26,17 @@ void DeviceInfoTest::testAdaptationVariables()
QCOMPARE(repoName, QString("adaptation"));
}

void DeviceInfoTest::testFeatureVariables()
{
SsuDeviceInfo deviceInfo("N950");
QHash<QString, QString> featureVariables;
QString repoName = deviceInfo.adaptationVariables("feature1", &featureVariables);
QHash<QString, QString> featureVariablesExpected;
featureVariablesExpected["feature"] = "test";
QCOMPARE(featureVariables, featureVariablesExpected);
QCOMPARE(repoName, QString("feature1"));
}

void DeviceInfoTest::testDeviceUid()
{
QVERIFY2(!SsuDeviceInfo().deviceUid().isEmpty(), "No method to get device UID on this platform");
Expand Down
1 change: 1 addition & 0 deletions tests/ut_deviceinfo/deviceinfotest.h
Expand Up @@ -16,6 +16,7 @@ class DeviceInfoTest: public QObject

private slots:
void testAdaptationVariables();
void testFeatureVariables();
void testDeviceUid();
void testVariableSection();
void testValue();
Expand Down
5 changes: 5 additions & 0 deletions tests/ut_deviceinfo/testdata/board-mappings.ini
Expand Up @@ -16,6 +16,7 @@ N950=N9
family=n950-n9
adaptation-repos=n9xx-common,n950-n9
variables = n9
repository-specific-variables=N9-feature1

[var-n9]
foo-n9 = foo-n9-val
Expand Down Expand Up @@ -49,3 +50,7 @@ bar2 = bar2Val

[var-baz]
variables = foo, bar

[var-N9-feature1]
feature=test

0 comments on commit aef653b

Please sign in to comment.