From 8333e1b4c5eb9f4170f70612931a89381802f5f8 Mon Sep 17 00:00:00 2001 From: s30051537 Date: Wed, 23 Oct 2024 11:49:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=88=86sd=E5=8D=A1=20u=E7=9B=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: s30051537 --- .../volume/test/external_volume_info_test.cpp | 12 ++++++------ .../innerkits_impl/src/volume_external.cpp | 5 +++++ .../innerkits_impl/test/volume_external_test.cpp | 4 ++++ .../volumeexternal_fuzzer/volumeexternal_fuzzer.cpp | 2 ++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/services/storage_daemon/volume/test/external_volume_info_test.cpp b/services/storage_daemon/volume/test/external_volume_info_test.cpp index a63a9d08..e4b2ff38 100644 --- a/services/storage_daemon/volume/test/external_volume_info_test.cpp +++ b/services/storage_daemon/volume/test/external_volume_info_test.cpp @@ -296,21 +296,21 @@ HWTEST_F(ExternalVolumeInfoTest, Storage_Service_ExternalVolumeInfoTest_GetFsUui } /** - * @tc.name: Storage_Service_ExternalVolumeInfoTest_GetFsLabel_001 - * @tc.desc: Verify the GetFsLabel function. + * @tc.name: Storage_Service_ExternalVolumeInfoTest_GetFlags_001 + * @tc.desc: Verify the GetFlags function. * @tc.type: FUNC * @tc.require: AR000H09L6 */ -HWTEST_F(ExternalVolumeInfoTest, Storage_Service_ExternalVolumeInfoTest_GetFsLabel_001, TestSize.Level1) +HWTEST_F(ExternalVolumeInfoTest, Storage_Service_ExternalVolumeInfoTest_GetFlags_001, TestSize.Level1) { - GTEST_LOG_(INFO) << "Storage_Service_ExternalVolumeInfoTest_GetFsLabel_001 start"; + GTEST_LOG_(INFO) << "Storage_Service_ExternalVolumeInfoTest_GetFlags_001 start"; ASSERT_TRUE(externalVolumeInfo_ != nullptr); - std::string ret = externalVolumeInfo_->GetFsLabel(); + std::string ret = externalVolumeInfo_->GetFlags(); GTEST_LOG_(INFO) << ret; EXPECT_TRUE(ret.empty()); - GTEST_LOG_(INFO) << "Storage_Service_ExternalVolumeInfoTest_GetFsLabel_001 end"; + GTEST_LOG_(INFO) << "Storage_Service_ExternalVolumeInfoTest_GetFlags_001 end"; } /** diff --git a/services/storage_manager/innerkits_impl/src/volume_external.cpp b/services/storage_manager/innerkits_impl/src/volume_external.cpp index 9a92571e..45d60258 100644 --- a/services/storage_manager/innerkits_impl/src/volume_external.cpp +++ b/services/storage_manager/innerkits_impl/src/volume_external.cpp @@ -92,6 +92,10 @@ bool VolumeExternal::Marshalling(Parcel &parcel) const return false; } + if (!parcel.WriteInt32(flags_)) { + return false; + } + if (!parcel.WriteInt32(fsType_)) { return false; } @@ -114,6 +118,7 @@ bool VolumeExternal::Marshalling(Parcel &parcel) const std::unique_ptr VolumeExternal::Unmarshalling(Parcel &parcel) { auto obj = std::make_unique(*VolumeCore::Unmarshalling(parcel)); + obj->flags_ = parcel.ReadInt32(); obj->fsType_ = parcel.ReadInt32(); obj->fsUuid_ = parcel.ReadString(); obj->path_ = parcel.ReadString(); diff --git a/services/storage_manager/innerkits_impl/test/volume_external_test.cpp b/services/storage_manager/innerkits_impl/test/volume_external_test.cpp index 9fde85ce..5db4bca3 100644 --- a/services/storage_manager/innerkits_impl/test/volume_external_test.cpp +++ b/services/storage_manager/innerkits_impl/test/volume_external_test.cpp @@ -42,6 +42,7 @@ public: HWTEST_F(VolumeExternalTest, Volume_external_Get_0000, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "VolumeExternalTest-begin Volume_external_Get_0000"; + int32_t flags = 1; int32_t fsType = 1; std::string fsUuid = "100"; std::string path = "/"; @@ -51,6 +52,7 @@ HWTEST_F(VolumeExternalTest, Volume_external_Get_0000, testing::ext::TestSize.Le volumeexternal.SetFsUuid(fsUuid); volumeexternal.SetPath(path); volumeexternal.SetDescription(description); + volumeexternal.SetFlags(flags); auto result1 = volumeexternal.GetFsType(); EXPECT_EQ(result1, fsType); auto result2 = volumeexternal.GetUuid(); @@ -66,6 +68,8 @@ HWTEST_F(VolumeExternalTest, Volume_external_Get_0000, testing::ext::TestSize.Le volumeexternal.SetFsType(FsType::UNDEFINED); auto result6 = volumeexternal.GetFsTypeString(); EXPECT_EQ(result6, "undefined"); + auto result7 = volumeexternal.GetFlags(); + EXPECT_EQ(result7, flags); volumeexternal.Reset(); GTEST_LOG_(INFO) << "VolumeExternalTest-end Volume_external_Get_0000"; } diff --git a/test/fuzztest/volumeexternal_fuzzer/volumeexternal_fuzzer.cpp b/test/fuzztest/volumeexternal_fuzzer/volumeexternal_fuzzer.cpp index 59acaf07..67c816cc 100644 --- a/test/fuzztest/volumeexternal_fuzzer/volumeexternal_fuzzer.cpp +++ b/test/fuzztest/volumeexternal_fuzzer/volumeexternal_fuzzer.cpp @@ -27,10 +27,12 @@ bool FileUtilFuzzTest(const uint8_t *data, size_t size) StorageManager::VolumeExternal volumeexternal; int32_t fsType = *(reinterpret_cast(data)); std::string metaData(reinterpret_cast(data), size); + volumeexternal.SetFlags(fsType); volumeexternal.SetFsType(fsType); volumeexternal.SetFsUuid(metaData); volumeexternal.SetPath(metaData); volumeexternal.SetDescription(metaData); + volumeexternal.GetFlags();; volumeexternal.GetFsType(); volumeexternal.GetUuid(); volumeexternal.GetPath();