|
12 | 12 |
|
13 | 13 | using namespace std; |
14 | 14 |
|
| 15 | +class CurrentFolderScope { |
| 16 | +public: |
| 17 | + explicit CurrentFolderScope(const string& path) : |
| 18 | + m_previousPath(RteFsUtils::GetCurrentFolder(false)) |
| 19 | + { |
| 20 | + RteFsUtils::SetCurrentFolder(path); |
| 21 | + } |
| 22 | + |
| 23 | + ~CurrentFolderScope() |
| 24 | + { |
| 25 | + RteFsUtils::SetCurrentFolder(m_previousPath); |
| 26 | + } |
| 27 | + |
| 28 | +private: |
| 29 | + string m_previousPath; |
| 30 | +}; |
| 31 | + |
15 | 32 | class PackChkIntegTests : public ::testing::Test { |
16 | 33 | public: |
17 | 34 | void SetUp() override; |
@@ -135,6 +152,32 @@ TEST_F(PackChkIntegTests, CheckValidPack) { |
135 | 152 | EXPECT_EQ(0, packChk.Check(2, argv, nullptr)); |
136 | 153 | } |
137 | 154 |
|
| 155 | +TEST_F(PackChkIntegTests, CheckValidPackDoesNotCreateRteDirectory) { |
| 156 | + const char* argv[2]; |
| 157 | + |
| 158 | + const string& pdscFile = PackChkIntegTestEnv::globaltestdata_dir + |
| 159 | + "/packs/ARM/RteTest_DFP/0.1.1/ARM.RteTest_DFP.pdsc"; |
| 160 | + ASSERT_TRUE(RteFsUtils::Exists(pdscFile)); |
| 161 | + |
| 162 | + const string workDir = PackChkIntegTestEnv::testoutput_dir + "/NoRteSideEffects"; |
| 163 | + if (RteFsUtils::Exists(workDir)) { |
| 164 | + RteFsUtils::RemoveDir(workDir); |
| 165 | + } |
| 166 | + ASSERT_TRUE(RteFsUtils::CreateDirectories(workDir)); |
| 167 | + ASSERT_FALSE(RteFsUtils::Exists(workDir + "/RTE")); |
| 168 | + |
| 169 | + argv[0] = (char*)""; |
| 170 | + argv[1] = (char*)pdscFile.c_str(); |
| 171 | + |
| 172 | + { |
| 173 | + CurrentFolderScope cwd(workDir); |
| 174 | + PackChk packChk; |
| 175 | + EXPECT_EQ(0, packChk.Check(2, argv, nullptr)); |
| 176 | + } |
| 177 | + |
| 178 | + EXPECT_FALSE(RteFsUtils::Exists(workDir + "/RTE")); |
| 179 | +} |
| 180 | + |
138 | 181 | // Validate invalid software pack |
139 | 182 | TEST_F(PackChkIntegTests, CheckInvalidPack) { |
140 | 183 | const char* argv[3]; |
@@ -1301,4 +1344,3 @@ TEST_F(PackChkIntegTests, CheckConditionComponentDependency_Neg) { |
1301 | 1344 | FAIL() << "error: warning M317 count != 4"; |
1302 | 1345 | } |
1303 | 1346 | } |
1304 | | - |
|
0 commit comments