From 2601d3b35e9d5869c4fa5a30cdea7e71ce7af800 Mon Sep 17 00:00:00 2001 From: chengjinsong Date: Wed, 28 Sep 2022 14:06:25 +0800 Subject: [PATCH] partitionslot Signed-off-by: chengjinsong Change-Id: I66fdf917f7e31b0e5f3c83c093bf1b40cc090719 --- startup/partitionslot/BUILD.gn | 1 + .../partitionslot/src/partitionslot_test.cpp | 31 ++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/startup/partitionslot/BUILD.gn b/startup/partitionslot/BUILD.gn index f4fdd456..16385126 100644 --- a/startup/partitionslot/BUILD.gn +++ b/startup/partitionslot/BUILD.gn @@ -26,6 +26,7 @@ ohos_moduletest_suite("HatsStartupPartitionSlotTest") { ] include_dirs = [ "./include", + "//drivers/hdf_core/adapter/uhdf2/include", "//drivers/peripheral/partitionslot/hal/src", "//third_party/googletest/googletest/include/gtest", "//commonlibrary/c_utils/base/include", diff --git a/startup/partitionslot/src/partitionslot_test.cpp b/startup/partitionslot/src/partitionslot_test.cpp index 26e95a40..7dc38db2 100644 --- a/startup/partitionslot/src/partitionslot_test.cpp +++ b/startup/partitionslot/src/partitionslot_test.cpp @@ -17,16 +17,34 @@ #include #include #include "hdf_log.h" +#include "hdi/idevmgr_hdi.h" #include "v1_0/ipartition_slot.h" using namespace testing; using namespace testing::ext; using namespace OHOS::HDI::Partitionslot::V1_0; +using OHOS::HDI::DeviceManager::V1_0::IDeviceManager; class StartupPartitionSlotTest : public testing::Test { public: - static void SetUpTestCase() {} - static void TearDownTestCase() {} + static void SetUpTestCase() + { + auto devmgr = IDeviceManager::Get(); + if (devmgr != nullptr) { + devmgr->LoadDevice("partition_slot_service"); + } else { + std::cout << "Get devmgr failed" << std::endl; + } + } + static void TearDownTestCase() + { + auto devmgr = IDeviceManager::Get(); + if (devmgr != nullptr) { + devmgr->UnloadDevice("partition_slot_service"); + } else { + std::cout << "Get devmgr failed" << std::endl; + } + } void SetUp() {} void TearDown() {} }; @@ -37,7 +55,7 @@ class StartupPartitionSlotTest : public testing::Test { * @tc.desc: NA */ HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_001, Function | MediumTest | Level1) { - printf("begin get currentslot by service \n"); + std::cout << "begin get currentslot by service" << std::endl; int numOfSlots = 0; int currentSlot = -1; sptr partitionslot = IPartitionSlot::Get(); @@ -51,7 +69,7 @@ HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_001, Function | Medi * @tc.desc: NA */ HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_002, Function | MediumTest | Level1) { - printf("begin get suffix by service \n"); + std::cout << "begin get suffix by service" << std::endl; std::string suffix = ""; int slot = 2; sptr partitionslot = IPartitionSlot::Get(); @@ -65,7 +83,7 @@ HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_002, Function | Medi * @tc.desc: NA */ HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_003, Function | MediumTest | Level1) { - printf("begin set active slot by service \n"); + std::cout << "begin set active slot by service" << std::endl; int numOfSlots = 0; int currentSlot = 0; sptr partitionslot = IPartitionSlot::Get(); @@ -81,9 +99,8 @@ HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_003, Function | Medi * @tc.desc: NA */ HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_004, Function | MediumTest | Level1) { - printf("begin set unbootable slot by service \n"); + std::cout << "begin set unbootable slot by service" << std::endl; sptr partitionslot = IPartitionSlot::Get(); ASSERT_TRUE(partitionslot != nullptr); ASSERT_TRUE(partitionslot->SetSlotUnbootable(2) == 0); } -