From 471efa4678741925da7afab4c1ae2f23c95d6263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Thu, 8 May 2025 22:40:34 +0800 Subject: [PATCH] hyperaio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/test/unittest/BUILD.gn | 1 + interfaces/test/unittest/hyperaio/BUILD.gn | 42 ++++++++ .../test/unittest/hyperaio/hyperaio_test.cpp | 98 +++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 interfaces/test/unittest/hyperaio/BUILD.gn create mode 100644 interfaces/test/unittest/hyperaio/hyperaio_test.cpp diff --git a/interfaces/test/unittest/BUILD.gn b/interfaces/test/unittest/BUILD.gn index 95f924b84..b14741b2d 100644 --- a/interfaces/test/unittest/BUILD.gn +++ b/interfaces/test/unittest/BUILD.gn @@ -18,5 +18,6 @@ group("unittest") { "filemgmt_libn_test:filemgmt_libn_test", "remote_uri:remote_uri_test", "task_signal:task_signal_test", + "hyperaio:hyperaio_test" ] } diff --git a/interfaces/test/unittest/hyperaio/BUILD.gn b/interfaces/test/unittest/hyperaio/BUILD.gn new file mode 100644 index 000000000..7eac1d8db --- /dev/null +++ b/interfaces/test/unittest/hyperaio/BUILD.gn @@ -0,0 +1,42 @@ +# Copyright (c) 2025 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/test.gni") +import("//foundation/filemanagement/file_api/file_api.gni") + +ohos_unittest("hyperaio_test") { + module_out_path = "file_api/file_api" + + resource_config_file = "../resource/ohos_test.xml" + + sources = [ "hyperaio_test.cpp" ] + + include_dirs = [ + "include", + "${file_api_path}/interfaces/kits/hyperaio/include", + ] + + deps = [ + "${file_api_path}/interfaces/kits/hyperaio:HyperAio", + ] + + external_deps = [ + "ability_base:zuri", + "access_token:libaccesstoken_sdk", + "c_utils:utils", + "c_utils:utilsbase", + "ipc:ipc_core", + "googletest:gtest_main", + "liburing:liburing", + ] +} diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp new file mode 100644 index 000000000..bfe94002e --- /dev/null +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025 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 +#include +#include +#include + +#include "hyperaio.h" + +namespace { + using namespace std; + using namespace OHOS::HyperAio; + + class HyperAioTest : public testing::Test { + public: + static void SetUpTestCase(void) {}; + static void TearDownTestCase() {}; + void SetUp() {}; + void TearDown() {}; + }; + + /** + * @tc.name: HyperAio_StartOpenReqs_0000 + * @tc.desc: Test function of StartOpenReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0000, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0000"; + std::unique_ptr hyperAio = std::make_unique(); + int32_t result = hyperAio->CtxInit(nullptr); + EXPECT_EQ(result, EOK); + ReadInfo readInfo = {0, 1024, 0, nullptr, 12345}; + ReadReqs readReqs = {1, &readInfo}; + result = hyperAio->StartReadReqs(&readReqs); + EXPECT_EQ(result, EOK); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0000"; + } + + /** + * @tc.name: HyperAio_StartReadReqs_0000 + * @tc.desc: Test function of StartReadReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0000, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0000"; + std::unique_ptr hyperAio = std::make_unique(); + int32_t result = hyperAio->CtxInit(nullptr); + EXPECT_EQ(result, EOK); + ReadInfo readInfo = {0, 1024, 0, nullptr, 12345}; + ReadReqs readReqs = {1, &readInfo}; + result = hyperAio->StartReadReqs(&readReqs); + EXPECT_EQ(result, EOK); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0000"; + } + + /** + * @tc.name: HyperAio_StartReadReqs_0000 + * @tc.desc: Test function of StartReadReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0000, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0000"; + std::unique_ptr hyperAio = std::make_unique(); + int32_t result = hyperAio->CtxInit(nullptr); + EXPECT_EQ(result, EOK); + ReadInfo readInfo = {0, 1024, 0, nullptr, 12345}; + ReadReqs readReqs = {1, &readInfo}; + result = hyperAio->StartReadReqs(&readReqs); + EXPECT_EQ(result, EOK); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0000"; + } + +} -- Gitee