mirror of
https://gitee.com/openharmony/xts_hats
synced 2025-02-26 21:37:06 +00:00
!302 [startup][master]add hdi api partitionslot 4 testcases
Merge pull request !302 from leiyuqian/startup0920
This commit is contained in:
commit
a4da9559f4
19
startup/BUILD.gn
Normal file
19
startup/BUILD.gn
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (C) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import("//build/ohos_var.gni")
|
||||
group("startup") {
|
||||
testonly = true
|
||||
if (is_standard_system) {
|
||||
deps = [ "partitionslot:HatsStartupPartitionSlotTest" ]
|
||||
}
|
||||
}
|
50
startup/partitionslot/BUILD.gn
Normal file
50
startup/partitionslot/BUILD.gn
Normal file
@ -0,0 +1,50 @@
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos_var.gni")
|
||||
import("//build/test.gni")
|
||||
import("//test/xts/tools/build/suite.gni")
|
||||
|
||||
ohos_moduletest_suite("HatsStartupPartitionSlotTest") {
|
||||
module_out_path = "startup/partitionslot"
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
include_dirs = [
|
||||
"./include",
|
||||
"//drivers/peripheral/partitionslot/hal/src",
|
||||
"//third_party/googletest/googletest/include/gtest",
|
||||
"//utils/native/base/include",
|
||||
]
|
||||
|
||||
sources = [ "./src/partitionslot_test.cpp" ]
|
||||
|
||||
deps = [
|
||||
"//third_party/googletest:gtest_main",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"drivers_interface_partitionslot:libpartitionslot_proxy_1.0",
|
||||
"hdf_core:libhdf_host",
|
||||
"hdf_core:libhdf_ipc_adapter",
|
||||
"hdf_core:libhdf_utils",
|
||||
"hdf_core:libhdi",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
18
startup/partitionslot/Test.json
Normal file
18
startup/partitionslot/Test.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"kits": [
|
||||
{
|
||||
"push": [
|
||||
"HatsStartupPartitionSlotTest->/data/local/tmp/HatsStartupPartitionSlotTest"
|
||||
],
|
||||
"type": "PushKit"
|
||||
}
|
||||
],
|
||||
"driver": {
|
||||
"native-test-timeout": "120000",
|
||||
"type": "CppTest",
|
||||
"module-name": "HatsStartupPartitionSlotTest",
|
||||
"runtime-hint": "1s",
|
||||
"native-test-device-path": "/data/local/tmp"
|
||||
},
|
||||
"description": "Configuration for HatsStartupPartitionSlotTest Tests"
|
||||
}
|
89
startup/partitionslot/src/partitionslot_test.cpp
Normal file
89
startup/partitionslot/src/partitionslot_test.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <osal_mem.h>
|
||||
#include <unistd.h>
|
||||
#include "hdf_log.h"
|
||||
#include "v1_0/ipartition_slot.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::HDI::Partitionslot::V1_0;
|
||||
|
||||
class StartupPartitionSlotTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase() {}
|
||||
static void TearDownTestCase() {}
|
||||
void SetUp() {}
|
||||
void TearDown() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number: StartupPartitionSlotTest_001
|
||||
* @tc.name: testGetCurrentSlotFun001
|
||||
* @tc.desc: NA
|
||||
*/
|
||||
HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_001, Function | MediumTest | Level1) {
|
||||
printf("begin get currentslot by service \n");
|
||||
int numOfSlots = 0;
|
||||
int currentSlot = -1;
|
||||
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
|
||||
ASSERT_TRUE(partitionslot != nullptr);
|
||||
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartupPartitionSlotTest_002
|
||||
* @tc.name: testGetSlotSuffixFun001
|
||||
* @tc.desc: NA
|
||||
*/
|
||||
HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_002, Function | MediumTest | Level1) {
|
||||
printf("begin get suffix by service \n");
|
||||
std::string suffix = "";
|
||||
int slot = 2;
|
||||
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
|
||||
ASSERT_TRUE(partitionslot != nullptr);
|
||||
ASSERT_TRUE(partitionslot->GetSlotSuffix(slot, suffix) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartupPartitionSlotTest_003
|
||||
* @tc.name: testGetCurrentSlotFun001
|
||||
* @tc.desc: NA
|
||||
*/
|
||||
HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_003, Function | MediumTest | Level1) {
|
||||
printf("begin set active slot by service \n");
|
||||
int numOfSlots = 0;
|
||||
int currentSlot = 0;
|
||||
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
|
||||
ASSERT_TRUE(partitionslot != nullptr);
|
||||
partitionslot->GetCurrentSlot(currentSlot, numOfSlots);
|
||||
ASSERT_TRUE(partitionslot->SetActiveSlot(2) == 0);
|
||||
partitionslot->SetActiveSlot(currentSlot);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartupPartitionSlotTest_004
|
||||
* @tc.name: testSetSlotUnbootableFun001
|
||||
* @tc.desc: NA
|
||||
*/
|
||||
HWTEST_F(StartupPartitionSlotTest, StartupPartitionSlotTest_004, Function | MediumTest | Level1) {
|
||||
printf("begin set unbootable slot by service \n");
|
||||
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
|
||||
ASSERT_TRUE(partitionslot != nullptr);
|
||||
ASSERT_TRUE(partitionslot->SetSlotUnbootable(2) == 0);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ _all_test_packages = [
|
||||
"${HATS_ROOT}/kernel:kernel",
|
||||
"${HATS_ROOT}/useriam:useriam",
|
||||
"${HATS_ROOT}/telephony:telephony",
|
||||
"${HATS_ROOT}/startup:startup",
|
||||
]
|
||||
|
||||
_all_test_packages_ivi = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user