Skip to content

Commit

Permalink
[projmgr] Handle multiple common connect nodes
Browse files Browse the repository at this point in the history
Increase debug verbosity of connections iterations
  • Loading branch information
grasci-arm authored Dec 21, 2022
1 parent b619c9a commit de6d17e
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 36 deletions.
1 change: 1 addition & 0 deletions tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@
},
"set": {
"type": "string",
"pattern": "^.+\\..+$",
"description": "Set configuration option in the format 'config-id.select'"
},
"info": {
Expand Down
39 changes: 14 additions & 25 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,8 @@ bool ProjMgrWorker::DiscoverMatchingLayers(ContextItem& context) {
const auto& type = m_parser->GetGenericClayers()[*item.filename].type;
msg += "\n " + (type.empty() ? "" : type + ": ") + *item.filename;
for (const auto& connect : item.connections) {
if (!connect->set.empty()) {
msg += "\n set: " + connect->set + " (" + (connect->info.empty() ? "" : connect->info + " - ") + connect->connect + ")";
}
msg += "\n " + (connect->set.empty() ? "" : "set: " + connect->set + " ") + "(" +
(connect->info.empty() ? "" : connect->info + " - ") + connect->connect + ")";
}
}
ProjMgrLogger::Debug(msg);
Expand Down Expand Up @@ -614,33 +613,24 @@ bool ProjMgrWorker::DiscoverMatchingLayers(ContextItem& context) {

// print all valid configuration options
if (context.validConnections.size() > 0) {
map<int, map<string, map<string, ConnectPtrVec>>> configurationOptions;
int index = 1;
map<int, map<string, map<string, set<const ConnectItem*>>>> configurationOptions;
int index = 0;
for (const auto& combination : context.validConnections) {
bool hasConfigOption = false;
index++;
for (const auto& item : combination) {
if (!item.type->empty()) {
hasConfigOption = true;
configurationOptions[index][*item.type][*item.filename];
}
for (const auto& connect : item.connections) {
if (!connect->set.empty()) {
hasConfigOption = true;
configurationOptions[index][*item.type][*item.filename].push_back(connect);
}
configurationOptions[index][*item.type][*item.filename].insert(connect);
}
}
if (hasConfigOption) {
index++;
}
}
for (const auto& [index, types] : configurationOptions) {
string msg = "configuration match #" + to_string(index) + ":";
for (const auto& [type, filenames] : types) {
for (const auto& [filename, options] : filenames) {
msg += "\n " + (type.empty() ? "" : type + ": ") + filename;
for (const auto& option : options) {
msg += "\n set: " + option->set + " (" + (option->info.empty() ? "" : option->info + " - ") + option->connect + ")";
for (const auto& connect : options) {
msg += "\n " + (connect->set.empty() ? "" : "set: " + connect->set + " ") + "(" +
(connect->info.empty() ? "" : connect->info + " - ") + connect->connect + ")";
}
}
}
Expand Down Expand Up @@ -711,20 +701,19 @@ ConnectionsCollectionMap ProjMgrWorker::ClassifyConnections(const ConnectionsCol
// get common connections
ConnectPtrVec commonConnections;
bool hasMultipleSelect = false;
for (const auto& [configId, connections] : connectionsMap) {
if (connections.size() > 1) {
for (const auto& [configId, connectionsEntry] : connectionsMap) {
if (!configId.empty()) {
// 'config-id' has multiple 'select' choices
hasMultipleSelect = true;
}
else {
} else {
// 'config-id' has only one 'select'
commonConnections.insert(commonConnections.end(), connections.begin(), connections.end());
commonConnections.insert(commonConnections.end(), connectionsEntry.begin(), connectionsEntry.end());
}
}
// iterate over 'select' choices
if (hasMultipleSelect) {
for (const auto& [configId, selectConnections] : connectionsMap) {
if (selectConnections.size() > 1) {
if (!configId.empty()) {
for (const auto& connect : selectConnections) {
ConnectionsCollection collection = { collectionEntry.filename, collectionEntry.type, commonConnections };
collection.connections.push_back(connect);
Expand Down
4 changes: 4 additions & 0 deletions tools/projmgr/test/data/TestLayers/config.clayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ layer:
- connect: "test connect common T"
provides:
- connectT

- connect: "test connect common U"
provides:
- connectU
67 changes: 56 additions & 11 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,18 +642,27 @@ TEST_F(ProjMgrUnitTests, ListLayersCompatible) {
debug csolution: validating connections for context 'genericlayers.CompatibleLayers\\+AnyBoard'\n\
debug csolution: validating combined connections:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
\\(Project Connections\\)\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\
\\(Board1 Connections\\)\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
\\(Test variant Connections\\)\n\
debug csolution: connections are valid\n\
debug csolution: validating combined connections:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
\\(Project Connections\\)\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/board2.clayer.yml\n\
\\(Board2 Connections\\)\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
\\(Test variant Connections\\)\n\
debug csolution: connections are valid\n\
debug csolution: validating combined connections:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
\\(Project Connections\\)\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\
\\(Board3 Connections\\)\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
\\(Test variant Connections\\)\n\
debug csolution: connections are valid\n\
debug csolution: multiple clayers match type 'Board':\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\
Expand All @@ -662,14 +671,26 @@ debug csolution: multiple clayers match type 'Board':\n\
debug csolution: clayer of type 'TestVariant' was uniquely found:\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
debug csolution: configuration match #1:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
\\(Project Connections\\)\n\
Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\
\\(Board1 Connections\\)\n\
TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
\\(Test variant Connections\\)\n\
debug csolution: configuration match #2:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
\\(Project Connections\\)\n\
Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board2.clayer.yml\n\
\\(Board2 Connections\\)\n\
TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
\\(Test variant Connections\\)\n\
debug csolution: configuration match #3:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
\\(Project Connections\\)\n\
Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\
\\(Board3 Connections\\)\n\
TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
\\(Test variant Connections\\)\n\
";

const string& errStr = streamRedirect.GetErrorString();
Expand Down Expand Up @@ -700,23 +721,31 @@ TEST_F(ProjMgrUnitTests, ListLayersConfigurations) {
debug csolution: configuration match #1:\n\
.*/TestLayers/config.clayer.yml\n\
set: set1.select1 \\(set 1 select 1 - connect R\\)\n\
\\(test connect common T\\)\n\
\\(test connect common U\\)\n\
.*/TestLayers/config.cproject.yml\n\
set: set1.select1 \\(set 1 select 1 - project X\\)\n\
Config1: .*/ARM/RteTest_DFP/0.2.0/Layers/config1.clayer.yml\n\
set: set1.select1 \\(set 1 select 1 - connect A\\)\n\
set: set2.select1 \\(set 2 select 1 - connect C\\)\n\
\\(test connect common E\\)\n\
Config2: .*/ARM/RteTest_DFP/0.2.0/Layers/config2.clayer.yml\n\
set: set1.select1 \\(set 1 select 1 - connect F\\)\n\
\\(test connect common H\\)\n\
debug csolution: configuration match #2:\n\
.*/TestLayers/config.clayer.yml\n\
set: set1.select2 \\(set 1 select 2 - connect S\\)\n\
\\(test connect common T\\)\n\
\\(test connect common U\\)\n\
.*/TestLayers/config.cproject.yml\n\
set: set1.select2 \\(set 1 select 2 - project Y\\)\n\
Config1: .*/ARM/RteTest_DFP/0.2.0/Layers/config1.clayer.yml\n\
set: set1.select2 \\(set 1 select 2 - connect B\\)\n\
set: set2.select2 \\(set 2 select 2 - connect D\\)\n\
\\(test connect common E\\)\n\
Config2: .*/ARM/RteTest_DFP/0.2.0/Layers/config2.clayer.yml\n\
set: set1.select2 \\(set 1 select 2 - connect G\\)\n\
\\(test connect common H\\)\n\
";

const string& errStr = streamRedirect.GetErrorString();
Expand Down Expand Up @@ -772,16 +801,23 @@ TEST_F(ProjMgrUnitTests, ListLayersUniquelyCompatibleBoard) {
debug csolution: validating connections for context 'genericlayers.CompatibleLayers\\+Board3'\n\
debug csolution: validating combined connections:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
\\(Project Connections\\)\n\
Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\
\\(Board3 Connections\\)\n\
TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
\\(Test variant Connections\\)\n\
debug csolution: connections are valid\n\
debug csolution: clayer of type 'Board' was uniquely found:\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\
debug csolution: clayer of type 'TestVariant' was uniquely found:\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
debug csolution: configuration match #1:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
\\(Project Connections\\)\n\
Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\
\\(Board3 Connections\\)\n\
TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\
\\(Test variant Connections\\)\n\
";

const string& errStr = streamRedirect.GetErrorString();
Expand Down Expand Up @@ -815,9 +851,12 @@ debug csolution: no clayer matches type 'UnknownType'\n\
debug csolution: clayer type 'DifferentFromDescriptionInPdsc' does not match type 'PdscType' in pack description\n\
debug csolution: validating combined connections:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\
\\(Project Connections\\)\n\
Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\
\\(Board1 Connections\\)\n\
Incompatible: .*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\
\\(Incompatible Connections\\)\n\
DifferentFromDescriptionInPdsc: .*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\
debug csolution: connections provided with multiple different values:\n\
MultipleProvidedNonIdentical0\n\
MultipleProvidedNonIdentical1\n\
Expand All @@ -829,9 +868,12 @@ debug csolution: sum of required values exceed provided:\n\
debug csolution: connections are invalid\n\
debug csolution: validating combined connections:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/board2.clayer.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\
\\(Project Connections\\)\n\
Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board2.clayer.yml\n\
\\(Board2 Connections\\)\n\
Incompatible: .*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\
\\(Incompatible Connections\\)\n\
DifferentFromDescriptionInPdsc: .*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\
debug csolution: connections provided with multiple different values:\n\
MultipleProvidedNonIdentical0\n\
MultipleProvidedNonIdentical1\n\
Expand All @@ -843,9 +885,12 @@ debug csolution: sum of required values exceed provided:\n\
debug csolution: connections are invalid\n\
debug csolution: validating combined connections:\n\
.*/TestLayers/genericlayers.cproject.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\
.*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\
\\(Project Connections\\)\n\
Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\
\\(Board3 Connections\\)\n\
Incompatible: .*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\
\\(Incompatible Connections\\)\n\
DifferentFromDescriptionInPdsc: .*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\
debug csolution: connections provided with multiple different values:\n\
MultipleProvidedNonIdentical0\n\
MultipleProvidedNonIdentical1\n\
Expand Down

0 comments on commit de6d17e

Please sign in to comment.