Skip to content

Commit 34295d3

Browse files
authored
[projmgr] Skip item from devices list when it is not end-leaf (#1308)
1 parent 95d04e4 commit 34295d3

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

tools/projmgr/src/ProjMgrRpcServerData.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,13 @@ void RpcDataCollector::CollectBoardDevices(vector<RpcArgs::Device>& boardDevices
250250
void RpcDataCollector::CollectDeviceList(RpcArgs::DeviceList& deviceList, const std::string& namePattern, const std::string& vendor) const {
251251
list<RteDevice*> devices;
252252
if(m_model) {
253-
m_model->GetDevices(devices, namePattern, vendor);
253+
m_model->GetDevices(devices, namePattern, vendor, RteDeviceItem::VARIANT);
254254
}
255255
for(auto rteDevice : devices) {
256+
if (!rteDevice->GetDeviceItems().empty()) {
257+
// skip not end-leaf item
258+
continue;
259+
}
256260
deviceList.devices.push_back(FromRteDevice(rteDevice, false));
257261
}
258262
}

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4038,6 +4038,10 @@ bool ProjMgrWorker::ListDevices(vector<string>& devices, const string& filter) {
40384038
list<RteDevice*> filteredModelDevices;
40394039
context.rteFilteredModel->GetDevices(filteredModelDevices, "", "", RteDeviceItem::VARIANT);
40404040
for (const auto& deviceItem : filteredModelDevices) {
4041+
if (!deviceItem->GetDeviceItems().empty()) {
4042+
// skip not end-leaf item
4043+
continue;
4044+
}
40414045
const string& deviceVendor = deviceItem->GetVendorName();
40424046
const string& deviceName = deviceItem->GetFullDeviceName();
40434047
const string& devicePack = deviceItem->GetPackageID();

tools/projmgr/test/src/ProjMgrRpcTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ TEST_F(ProjMgrRpcTests, RpcDeviceListNoContext) {
183183

184184
EXPECT_TRUE(responses[1]["result"]["success"]);
185185
auto deviceList = responses[1]["result"]["devices"];
186-
EXPECT_EQ(deviceList.size(), 7);
186+
EXPECT_EQ(deviceList.size(), 8);
187187
auto d0 = deviceList[0];
188188
EXPECT_EQ(d0["id"], "ARM::RteTest_ARMCM0");
189189
EXPECT_EQ(d0["family"], "RteTest ARM Cortex M");
@@ -222,7 +222,7 @@ TEST_F(ProjMgrRpcTests, RpcDeviceListContext) {
222222

223223
EXPECT_TRUE(responses[2]["result"]["success"]);
224224
auto deviceList = responses[2]["result"]["devices"];
225-
EXPECT_EQ(deviceList.size(), 6);
225+
EXPECT_EQ(deviceList.size(), 7);
226226
auto d0 = deviceList[0];
227227
EXPECT_EQ(d0["id"], "ARM::RteTest_ARMCM0");
228228

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ TEST_F(ProjMgrUnitTests, RunProjMgr_ListDevices) {
532532

533533
auto outStr = streamRedirect.GetOutString();
534534
EXPECT_STREQ(outStr.c_str(),"\
535-
ARM::RteTest_ARMCM4 (ARM::RteTest_DFP@0.2.0)\n\
536535
ARM::RteTest_ARMCM4_FP (ARM::RteTest_DFP@0.2.0)\n\
537536
ARM::RteTest_ARMCM4_NOFP (ARM::RteTest_DFP@0.2.0)\n"
538537
);

0 commit comments

Comments
 (0)