Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when same pack is located on 2 paths #1063

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tools/projmgr/src/ProjMgrKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ bool ProjMgrKernel::LoadAndInsertPacks(std::list<RtePackage*>& packs, std::list<
}

globalModel->InsertPacks(newPacks);
packs.insert(packs.end(), newPacks.begin(), newPacks.end());

// Track only packs that were actually inserted into the model
packs.clear();
for (const auto& [_, pack] : globalModel->GetPackages()) {
packs.push_back(pack);
}
return true;
}
24 changes: 24 additions & 0 deletions tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,30 @@ TEST_F(ProjMgrWorkerUnitTests, LoadDuplicatePacks) {
EXPECT_EQ("ARM.RteTest_DFP.0.2.0", (*m_loadedPacks.begin())->GetPackageID());
}

TEST_F(ProjMgrWorkerUnitTests, LoadDuplicatePacksFromDifferentPaths) {
std::list<std::string> pdscFiles = { // Important that these 2 files contain the *same* vendor/name/version!
testcmsispack_folder + "/ARM/RteTest_DFP/0.2.0/ARM.RteTest_DFP.pdsc",
testinput_folder + "/SolutionSpecificPack/ARM.RteTest_DFP.pdsc"
};

m_kernel = ProjMgrKernel::Get();
ASSERT_TRUE(m_kernel);
m_model = m_kernel->GetGlobalModel();
ASSERT_TRUE(m_kernel);

EXPECT_TRUE(m_kernel->LoadAndInsertPacks(m_loadedPacks, pdscFiles));

// Check if only one pack is loaded
ASSERT_EQ(1, m_loadedPacks.size());
EXPECT_EQ("ARM.RteTest_DFP.0.2.0", (*m_loadedPacks.begin())->GetPackageID());

// Check that warning is issued
EXPECT_FALSE(m_model->Validate());
const auto& errors = m_model->GetErrors();
EXPECT_EQ(errors.size(), 1);
EXPECT_NE(string::npos, errors.front().find("warning #500:"));
}

TEST_F(ProjMgrWorkerUnitTests, LoadRequiredPacks) {
CsolutionItem csolution;
SetCsolutionPacks(&csolution, { "ARM::[email protected]"}, "Test");
Expand Down
Loading