diff --git a/OAT.xml b/OAT.xml index e52288de5741b09b03f9e8201948e18399ea5f8e..e308ba5587edae7aced33caa4c07ee081f3cedb2 100755 --- a/OAT.xml +++ b/OAT.xml @@ -65,14 +65,22 @@ Note:If the text contains special characters, please escape them according to th - + - - - - + + + + + + + + + + + + diff --git a/services/package/pkg_package/pkg_pkgfile.cpp b/services/package/pkg_package/pkg_pkgfile.cpp index afa0724da87b1f1b325ebeb2da26e352fe8347ae..5deac71ec0084610b47f70940f06f79b37c40269 100644 --- a/services/package/pkg_package/pkg_pkgfile.cpp +++ b/services/package/pkg_package/pkg_pkgfile.cpp @@ -34,8 +34,6 @@ PkgFile::~PkgFile() } pkgEntryMapId_.clear(); pkgEntryMapFileName_.clear(); - PkgManager::StreamPtr tmpStream = pkgStream_; - PkgManager::GetPackageInstance()->ClosePkgStream(tmpStream); } PkgEntryPtr PkgFile::AddPkgEntry(const std::string &fileName) diff --git a/test/unittest/applypatch_test/imagepatch_unittest.cpp b/test/unittest/applypatch_test/imagepatch_unittest.cpp index c9a1466c03fe12e300e22a4b19ed4626d693223c..f58c5fd57db7eb5ea14ce2e9ad375ab4c082777a 100755 --- a/test/unittest/applypatch_test/imagepatch_unittest.cpp +++ b/test/unittest/applypatch_test/imagepatch_unittest.cpp @@ -73,7 +73,7 @@ int ImagePatchTest::TestZipModeImagePatch() const reinterpret_cast(sourceData.data()), sourceData.size(), reinterpret_cast(patchContent.data()), patchContent.size() }; - return RunImageApplyPatch(param, "out_put_zip.zip", expectedSHA256); + return RunImageApplyPatch(param, "/data/updater/applypatch/out_put_zip.zip", expectedSHA256); } int ImagePatchTest::TestNormalModeImagePatch() const @@ -90,7 +90,7 @@ int ImagePatchTest::TestNormalModeImagePatch() const reinterpret_cast(sourceData.data()), sourceData.size(), reinterpret_cast(patchContent.data()), patchContent.size() }; - return RunImageApplyPatch(param, "out_put_zip.zip", expectedSHA256); + return RunImageApplyPatch(param, "/data/updater/diffpatch/out_put_zip.zip", expectedSHA256); } int ImagePatchTest::TestGZipModeImagePatch() const @@ -106,7 +106,7 @@ int ImagePatchTest::TestGZipModeImagePatch() const reinterpret_cast(sourceData.data()), sourceData.size(), reinterpret_cast(patchContent.data()), patchContent.size() }; - int ret = RunImageApplyPatch(param, "out_put_gzip.gzip", expectedSHA256); + int ret = RunImageApplyPatch(param, "/data/updater/applypatch/out_put_gzip.gzip", expectedSHA256); return ret; } @@ -123,7 +123,7 @@ int ImagePatchTest::TestLZ4ModeImagePatch() const reinterpret_cast(sourceData.data()), sourceData.size(), reinterpret_cast(patchContent.data()), patchContent.size() }; - RunImageApplyPatch(param, "out_put_lz4.lz4", expectedSHA256); + RunImageApplyPatch(param, "/data/updater/diffpatch/out_put_lz4.lz4", expectedSHA256); return 0; } diff --git a/test/unittest/applypatch_test/store_unittest.cpp b/test/unittest/applypatch_test/store_unittest.cpp index 8f683f94052315e2153b8780cd4f29928142eedf..237ed9e8de61895e24fd613d2837629e610fbb18 100755 --- a/test/unittest/applypatch_test/store_unittest.cpp +++ b/test/unittest/applypatch_test/store_unittest.cpp @@ -58,10 +58,7 @@ HWTEST_F(StoreUnitTest, store_test_001, TestSize.Level1) HWTEST_F(StoreUnitTest, store_test_002, TestSize.Level1) { - std::string storePath = "/data/updater/ut_test"; - Store::CreateNewSpace(storePath, true); std::vector buffer(4096, 0); - std::string filename1 = "test_file1"; - EXPECT_EQ(Store::WriteDataToStore(storePath, filename1, buffer, -1), -1); + EXPECT_EQ(Store::WriteDataToStore("", "test_file1", buffer, buffer.size()), -1); } } diff --git a/test/unittest/fs_manager/do_partition_unittest.cpp b/test/unittest/fs_manager/do_partition_unittest.cpp index cf0a03d732d32e0e5b615bd28c455e3864fd5faa..672b20bd02933ac34918f3882b86f7b34929a329 100755 --- a/test/unittest/fs_manager/do_partition_unittest.cpp +++ b/test/unittest/fs_manager/do_partition_unittest.cpp @@ -122,8 +122,8 @@ HWTEST_F(DoPartitionUnitTest, do_partition_test_001, TestSize.Level1) int ret1 = RegisterUpdaterPartitionList(nList, olist); ASSERT_EQ(ret1, 1); - char aaa[BUFFER_SIZE]; - BlockDevice myDev; + char aaa[BUFFER_SIZE] = {0}; + BlockDevice myDev {}; myDev.devPath = "xxxxxx"; myDev.specific = (void *)aaa; SetBlockDeviceMode(myDev); diff --git a/test/unittest/package/pkg_algo_unittest.cpp b/test/unittest/package/pkg_algo_unittest.cpp index e78461bb81a4de6578b363bf1c7ee1c6fab45f17..fbab4b1c78aac23baa98a1b4dd6383b5c8615257 100755 --- a/test/unittest/package/pkg_algo_unittest.cpp +++ b/test/unittest/package/pkg_algo_unittest.cpp @@ -252,9 +252,9 @@ HWTEST_F(PkgAlgoUnitTest, TestInvalid, TestSize.Level1) HWTEST_F(PkgAlgoUnitTest, TestPkgAlgoDeflate, TestSize.Level1) { - ZipFileInfo info; + ZipFileInfo info {}; PkgAlgoDeflate a1(info); - Lz4FileInfo config; + Lz4FileInfo config {}; PkgAlgorithmLz4 a2(config); PkgAlgorithmBlockLz4 a3(config); VerifyAlgorithm a4("aa", 0); diff --git a/test/unittest/package/pkg_manager_unittest.cpp b/test/unittest/package/pkg_manager_unittest.cpp index d968d70173901cbdc14a9feb04c4c35d09cd5ff7..ec795918a0b31732a099e78b6874eae0b8672892 100755 --- a/test/unittest/package/pkg_manager_unittest.cpp +++ b/test/unittest/package/pkg_manager_unittest.cpp @@ -73,7 +73,7 @@ public: } const std::string GetFileName() const override { - return 0; + return ""; } size_t GetFileLength() override { @@ -188,7 +188,10 @@ public: // 测试文件提取 PkgManager::StreamPtr outStream = nullptr; const FileInfo *info = pkgManager_->GetFileInfo(components[0]); - EXPECT_NE(info, nullptr); + if (info == nullptr) { + return PKG_INVALID_FILE; + } + ret = pkgManager_->CreatePkgStream(outStream, components[0], info->unpackedSize, PkgStream::PkgStreamType_MemoryMap); EXPECT_NE(outStream, nullptr); @@ -266,7 +269,9 @@ public: // 测试文件提取 PkgManager::StreamPtr outStream = nullptr; const FileInfo *info = pkgManager_->GetFileInfo(components[0]); - EXPECT_NE(info, nullptr); + if (info == nullptr) { + return PKG_INVALID_FILE; + } ret = pkgManager_->CreatePkgStream(outStream, TEST_PATH_TO + components[0], info->unpackedSize, PkgStream::PkgStreamType_Write); @@ -303,7 +308,10 @@ public: // 测试文件提取 PkgManager::StreamPtr outStream = nullptr; const FileInfo *info = pkgManager_->GetFileInfo(components[0]); - EXPECT_NE(info, nullptr); + if (info == nullptr) { + return PKG_INVALID_FILE; + } + ret = pkgManager_->CreatePkgStream(outStream, components[0], TestStreamProcess, this); EXPECT_NE(outStream, nullptr); @@ -606,9 +614,10 @@ public: std::string testFileName = TEST_PATH_FROM + "../applypatch/TestDecompressGzip.new.gz"; size_t fileSize = GetFileSize(testFileName); size_t uncompressedDataSize = 1024; - int32_t fd = open(testFileName.c_str(), O_RDWR); - EXPECT_GE(fd, 0); - + int fd = open(testFileName.c_str(), O_RDWR); + if (fd < 0) { + return -1; + } uncompressedData.resize(uncompressedDataSize); PkgManager::StreamPtr stream = nullptr; pkgManager_->CreatePkgStream(stream, "Gzip", diff --git a/test/unittest/package/pkg_test.h b/test/unittest/package/pkg_test.h index badd45dfda798c01f6cdda3c27653536f7511604..16a72a4df063db9699ac7f58dc2f34d6fb429636 100755 --- a/test/unittest/package/pkg_test.h +++ b/test/unittest/package/pkg_test.h @@ -118,6 +118,7 @@ protected: EXPECT_EQ(ret, 0); manager->ClosePkgStream(outStream); const FileInfo *info = manager->GetFileInfo(components[i]); + ASSERT_NE(info, nullptr); if (info->packMethod == PKG_COMPRESS_METHOD_NONE) { const ComponentInfo* compInfo = (const ComponentInfo*)manager->GetFileInfo(components[i]); if (compInfo != nullptr) { diff --git a/test/unittest/script/script_unittest.cpp b/test/unittest/script/script_unittest.cpp index e8bee2ae9f8615073d7b04c3a994183ba5be17c2..f32fa7e6050d5fa6fc769ffbaff13c527995013b 100755 --- a/test/unittest/script/script_unittest.cpp +++ b/test/unittest/script/script_unittest.cpp @@ -72,6 +72,7 @@ public: virtual void DestoryInstructionInstance(UScriptInstructionPtr& instr) { delete instr; + instr = nullptr; } TestScriptInstructionFactory() {} virtual ~TestScriptInstructionFactory() {} @@ -108,8 +109,8 @@ public: { return isRetry; } -private: UScriptInstructionFactory *factory_ = nullptr; +private: bool isRetry = false; }; diff --git a/test/unittest/updater_binary/updater_binary_unittest.cpp b/test/unittest/updater_binary/updater_binary_unittest.cpp index 52fd11f53be394a8cc646c778710bdf14897fc75..770adb21d550510b5c8b2dedae225604b5af8f14 100755 --- a/test/unittest/updater_binary/updater_binary_unittest.cpp +++ b/test/unittest/updater_binary/updater_binary_unittest.cpp @@ -129,6 +129,9 @@ protected: ComponentInfoExt *comp = (ComponentInfoExt*)malloc( sizeof(ComponentInfoExt) * (testFileNames_.size() + fileNameIndex)); + if (comp == nullptr) { + return -1; + } for (size_t i = 0; i < testFileNames_.size(); i++) { BuildCompnentInfo(comp[i], testFileNames_[i], testFileNames_[i], componentType); } @@ -149,10 +152,18 @@ protected: free(comp[i].filePath); free(comp[i].version); } - free(pkgInfo.productUpdateId); - free(pkgInfo.softwareVersion); - free(pkgInfo.date); - free(pkgInfo.time); + if (pkgInfo.productUpdateId != nullptr) { + free(pkgInfo.productUpdateId); + } + if (pkgInfo.softwareVersion != nullptr) { + free(pkgInfo.softwareVersion); + } + if (pkgInfo.date != nullptr) { + free(pkgInfo.date); + } + if (pkgInfo.time != nullptr) { + free(pkgInfo.time); + } free(comp); return ret; } diff --git a/test/unittest/updater_main_test/updater_main_unittest.cpp b/test/unittest/updater_main_test/updater_main_unittest.cpp index a13bcbb56d420ae1953cfc81022e860e9d7bb80d..5a696c0a2d8f157a1f03183226a0a8e689fb1edc 100755 --- a/test/unittest/updater_main_test/updater_main_unittest.cpp +++ b/test/unittest/updater_main_test/updater_main_unittest.cpp @@ -164,7 +164,7 @@ HWTEST_F(UpdaterMainUnitTest, updater_main_test_compress, TestSize.Level1) { const std::string testFile = "/data/sdcard/updater/test_compress.txt"; FILE *fp = fopen(testFile.c_str(), "w"); - EXPECT_NE(fp, nullptr); + ASSERT_NE(fp, nullptr); fclose(fp); CompressLogs(testFile); }