Skip to content

Commit

Permalink
Replace %Instance% with instance index in [email protected] files
Browse files Browse the repository at this point in the history
  • Loading branch information
grasci-arm authored Jan 12, 2024
1 parent fa828be commit 09cde26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libs/rtemodel/src/RteProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ void RteProject::UpdateConfigFileBackups(RteFileInstance* fi, RteFile* f)
// create base file if possible
if (baseVersion == updateVersion) {
// we can use current version as base one
RteFsUtils::CopyCheckFile(src, baseFile, false);
RteFsUtils::CopyMergeFile(src, baseFile, fi->GetInstanceIndex(), false);
RteFsUtils::SetFileReadOnly(baseFile, true);
} else {
baseFile.clear(); //no such file
Expand All @@ -685,7 +685,7 @@ void RteProject::UpdateConfigFileBackups(RteFileInstance* fi, RteFile* f)
// copy current file if version differs
string updateFile = RteUtils::AppendFileUpdateVersion(absPath, updateVersion);
if (!baseFile.empty() && baseVersion != updateVersion) { // only copy update if base exists
RteFsUtils::CopyCheckFile(src, updateFile, false);
RteFsUtils::CopyMergeFile(src, updateFile, fi->GetInstanceIndex(), false);
RteFsUtils::SetFileReadOnly(updateFile, true);
} else {
updateFile.clear(); // no need in that
Expand Down
18 changes: 16 additions & 2 deletions libs/rtemodel/test/src/RteModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,24 @@ TEST_F(RteModelPrjTest, LoadCprjConfigVer) {
ASSERT_NE(loadedCprjProject, nullptr);

const string rteDir = RteUtils::ExtractFilePath(RteTestM3_cprj, true) + loadedCprjProject->GetRteFolder() + "/";
const string CompConfig_0_Base_Version = rteDir + "RteTest/" + "[email protected]";
const string CompConfig_1_Base_Version = rteDir + "RteTest/" + "[email protected]";
const string CompConfig_0 = rteDir + "RteTest/" + "ComponentLevelConfig_0.h";
const string CompConfig_0_Base_Version = CompConfig_0 + "[email protected]";
EXPECT_TRUE(RteFsUtils::Exists(CompConfig_0));
EXPECT_TRUE(RteFsUtils::Exists(CompConfig_0_Base_Version));
const string CompConfig_1 = rteDir + "RteTest/" + "ComponentLevelConfig_1.h";
const string CompConfig_1_Base_Version = CompConfig_1 + "[email protected]";
EXPECT_TRUE(RteFsUtils::Exists(CompConfig_1));
EXPECT_TRUE(RteFsUtils::Exists(CompConfig_1_Base_Version));
// check if freshly copied files match their base
// that also checks if base files expand %Instance% with correct instance
string buf, bufBase;
EXPECT_TRUE(RteFsUtils::ReadFile(CompConfig_0, buf));
EXPECT_TRUE(RteFsUtils::ReadFile(CompConfig_0_Base_Version, bufBase));
EXPECT_EQ(buf, bufBase);

EXPECT_TRUE(RteFsUtils::ReadFile(CompConfig_1, buf));
EXPECT_TRUE(RteFsUtils::ReadFile(CompConfig_1_Base_Version, bufBase));
EXPECT_EQ(buf, bufBase);

const string deviceDir = rteDir + "Device/RteTest_ARMCM3/";
EXPECT_TRUE(RteFsUtils::Exists(deviceDir + "ARMCM3_ac6.sct"));
Expand Down

0 comments on commit 09cde26

Please sign in to comment.