1212
1313#include " CrossPlatformUtils.h"
1414#include " ProductInfo.h"
15+ #include " RteFsUtils.h"
1516#include " yaml-cpp/yaml.h"
1617
1718#include < fstream>
@@ -72,7 +73,7 @@ vector<json> ProjMgrRpcTests::RunRpcMethods(const string& strIn) {
7273 StdStreamRedirect streamRedirect;
7374 streamRedirect.SetInString (strIn);
7475 char * argv[] = { (char *)" csolution" , (char *)" rpc" };
75- EXPECT_EQ (0 , RunProjMgr (2 , argv, 0 ));
76+ EXPECT_EQ (0 , RunProjMgr (2 , argv, m_envp ));
7677 string line;
7778 vector<json> responses;
7879 istringstream iss (streamRedirect.GetOutString ());
@@ -86,7 +87,7 @@ string ProjMgrRpcTests::RunRpcMethodsWithContent(const string& strIn) {
8687 StdStreamRedirect streamRedirect;
8788 streamRedirect.SetInString (strIn);
8889 char * argv[] = { (char *)" csolution" , (char *)" rpc" , (char *)" --content-length" };
89- EXPECT_EQ (0 , RunProjMgr (3 , argv, 0 ));
90+ EXPECT_EQ (0 , RunProjMgr (3 , argv, m_envp ));
9091 return streamRedirect.GetOutString ();
9192}
9293
@@ -704,4 +705,39 @@ TEST_F(ProjMgrRpcTests, RpcGetDraftProjects) {
704705 EXPECT_EQ (responses[0 ][" result" ][" message" ], " Packs must be loaded before retrieving draft projects" );
705706}
706707
708+ TEST_F (ProjMgrRpcTests, RpcConvertSolution) {
709+ auto csolutionPath = testinput_folder + " /TestRpc/minimal.csolution.yml" ;
710+ auto requests = FormatRequest (1 , " ConvertSolution" ,
711+ json ({ { " solution" , csolutionPath }, { " activeTarget" , " TestHW" }, { " updateRte" , true } }));
712+ auto responses = RunRpcMethods (requests);
713+ EXPECT_TRUE (responses[0 ][" result" ][" success" ]);
714+ EXPECT_TRUE (RteFsUtils::Exists (testinput_folder + " /TestRpc/minimal.cbuild-idx.yml" ));
715+ EXPECT_TRUE (RteFsUtils::Exists (testinput_folder + " /TestRpc/minimal.cbuild-pack.yml" ));
716+ EXPECT_TRUE (RteFsUtils::Exists (testinput_folder + " /TestRpc/out/minimal+TestHW.cbuild-run.yml" ));
717+ EXPECT_TRUE (RteFsUtils::Exists (testinput_folder + " /TestRpc/out/minimal/TestHW/minimal+TestHW.cbuild.yml" ));
718+
719+ // convert fail
720+ csolutionPath = testinput_folder + " /TestRpc/unknown-component.csolution.yml" ;
721+ requests = FormatRequest (1 , " ConvertSolution" ,
722+ json ({ { " solution" , csolutionPath }, { " activeTarget" , " " }, { " updateRte" , true } }));
723+ responses = RunRpcMethods (requests);
724+ EXPECT_FALSE (responses[0 ][" result" ][" success" ]);
725+
726+ // undefined compiler
727+ csolutionPath = testinput_folder + " /TestSolution/SelectableToolchains/select-compiler.csolution.yml" ;
728+ requests = FormatRequest (1 , " ConvertSolution" ,
729+ json ({ { " solution" , csolutionPath }, { " activeTarget" , " " }, { " updateRte" , true } }));
730+ responses = RunRpcMethods (requests);
731+ EXPECT_FALSE (responses[0 ][" result" ][" success" ]);
732+ EXPECT_EQ (responses[0 ][" result" ][" selectCompiler" ][0 ], " AC6@>=6.0.0" );
733+ EXPECT_EQ (responses[0 ][" result" ][" selectCompiler" ][1 ], " GCC@>=8.0.0" );
734+
735+ // undefined layer
736+ csolutionPath = testinput_folder + " /TestLayers/variables-notdefined.csolution.yml" ;
737+ requests = FormatRequest (1 , " ConvertSolution" ,
738+ json ({ { " solution" , csolutionPath }, { " activeTarget" , " " }, { " updateRte" , true } }));
739+ responses = RunRpcMethods (requests);
740+ EXPECT_FALSE (responses[0 ][" result" ][" success" ]);
741+ EXPECT_EQ (responses[0 ][" result" ][" undefinedLayers" ][0 ], " NotDefined" );
742+ }
707743// end of ProjMgrRpcTests.cpp
0 commit comments