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

[rtemodel] Fix nullptr exception in RteCallback::ExpandString #1474

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
6 changes: 5 additions & 1 deletion libs/rtemodel/src/RteCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ string RteCallback::ExpandString(const string& str) {
if (!activeTarget) {
return RteUtils::EMPTY_STRING;
}
const auto devicePackage = activeTarget->GetDevicePackage();
if (!devicePackage) {
return RteUtils::EMPTY_STRING;
}

const string& prjPath(activeProject->GetProjectPath());
const string& prjPathFile(prjPath + activeProject->GetName() + ".cprj");
const string& packPath(activeTarget->GetDevicePackage()->GetAbsolutePackagePath());
const string& packPath(devicePackage->GetAbsolutePackagePath());
const string& deviceName(activeTarget->GetDeviceName());
const string& generatorInputFile(activeTarget->GetGeneratorInputFile());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json

solution:
target-types:
- type: CM0
device: RteTestGen_ARMCM0
compiler: AC6
optimize: balanced

build-types:
- type: Debug

- type: Release
optimize: none # optimize redefinition from target-type to build-type is not allowed

projects:
- project: ./test-gpdsc.cproject.yml
14 changes: 14 additions & 0 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5428,3 +5428,17 @@ TEST_F(ProjMgrUnitTests, Executes) {
auto errStr = streamRedirect.GetErrorString();
EXPECT_NE(string::npos, errStr.find("error csolution: context 'unknown.Debug+RteTest_ARMCM3' referenced by access sequence 'elf' is not compatible"));
}

TEST_F(ProjMgrUnitTests, RunProjMgr_GeneratorError) {
char* argv[6];
StdStreamRedirect streamRedirect;
const string& csolution = testinput_folder + "/TestGenerator/test-gpdsc-error.csolution.yml";
argv[1] = (char*)"convert";
argv[2] = (char*)"--solution";
argv[3] = (char*)csolution.c_str();
argv[4] = (char*)"-o";
argv[5] = (char*)testoutput_folder.c_str();
EXPECT_EQ(1, RunProjMgr(6, argv, 0));
auto errStr = streamRedirect.GetErrorString();
EXPECT_NE(string::npos, errStr.find("error csolution: redefinition from 'balanced' into 'none' is not allowed"));
}