partitionslot

Signed-off-by: chengjinsong <chengjinsong2@huawei.com>
Change-Id: I66fdf917f7e31b0e5f3c83c093bf1b40cc090719
This commit is contained in:
chengjinsong 2022-09-28 14:06:25 +08:00
parent 41c9fd463c
commit 2601d3b35e
2 changed files with 25 additions and 7 deletions

View File

@ -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",

View File

@ -17,16 +17,34 @@
#include <osal_mem.h>
#include <unistd.h>
#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<IPartitionSlot> 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<IPartitionSlot> 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<IPartitionSlot> 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<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->SetSlotUnbootable(2) == 0);
}