From 00f8021bf8913597822fd536abb002801e305f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sun, 15 Jun 2025 16:11:38 +0800 Subject: [PATCH 01/17] add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 1 + interfaces/kits/hyperaio/src/hyperaio_trace.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index bd4d38d2a..ed3442740 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -302,6 +302,7 @@ int32_t HyperAio::DestroyCtx() if (harvestThread_.joinable()) { HILOGI("start harvest thread join"); harvestThread_.join(); + // No print this log means join failed HILOGI("join success"); } diff --git a/interfaces/kits/hyperaio/src/hyperaio_trace.cpp b/interfaces/kits/hyperaio/src/hyperaio_trace.cpp index b51c24b34..4dfce0b0c 100644 --- a/interfaces/kits/hyperaio/src/hyperaio_trace.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio_trace.cpp @@ -23,13 +23,13 @@ HyperaioTrace::HyperaioTrace(const std::string& value, bool isShowLog) : value_( if (isShowLog) { HILOGI("%{public}s", value_.c_str()); } - StartTrace(HITRACE_TAG_OHOS, "[HyperAio]" + value); + StartTrace(HITRACE_TAG_FILEMANAGEMENT, "[HyperAio]" + value); } void HyperaioTrace::End() { if (!isFinished_) { - FinishTrace(HITRACE_TAG_OHOS); + FinishTrace(HITRACE_TAG_FILEMANAGEMENT); isFinished_ = true; } } -- Gitee From 5798c36f5e76822ccc67f9b599cc8533aaa6bce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sun, 15 Jun 2025 16:32:09 +0800 Subject: [PATCH 02/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index ed3442740..3adb59efb 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -277,7 +277,7 @@ void HyperAio::HarvestRes() } cqeCount_++; auto response = std::make_unique(cqe->user_data, cqe->res, cqe->flags); - HILOGI("get cqe, user_data = %{public}lld, res = %{public}d, flags = %{public}u", + HILOGI("get cqe, user_data = %{public}lu, res = %{public}d, flags = %{public}u", cqe->user_data, cqe->res, cqe->flags); HyperaioTrace trace("harvest: userdata " + std::to_string(cqe->user_data) + " res " + std::to_string(cqe->res) + "flags " + std::to_string(cqe->flags)); -- Gitee From a0d585788c7f4f515b66fa736649f0b1cf9265e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sun, 15 Jun 2025 16:42:46 +0800 Subject: [PATCH 03/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index 3adb59efb..458baed1b 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -277,7 +277,7 @@ void HyperAio::HarvestRes() } cqeCount_++; auto response = std::make_unique(cqe->user_data, cqe->res, cqe->flags); - HILOGI("get cqe, user_data = %{public}lu, res = %{public}d, flags = %{public}u", + HILOGI("get cqe, user_data = %{public}llu, res = %{public}d, flags = %{public}u", cqe->user_data, cqe->res, cqe->flags); HyperaioTrace trace("harvest: userdata " + std::to_string(cqe->user_data) + " res " + std::to_string(cqe->res) + "flags " + std::to_string(cqe->flags)); -- Gitee From 665221054e6fc825512c15f58fe0544bd127ecf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sun, 15 Jun 2025 17:07:32 +0800 Subject: [PATCH 04/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index 458baed1b..a9b5629dc 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -277,8 +277,6 @@ void HyperAio::HarvestRes() } cqeCount_++; auto response = std::make_unique(cqe->user_data, cqe->res, cqe->flags); - HILOGI("get cqe, user_data = %{public}llu, res = %{public}d, flags = %{public}u", - cqe->user_data, cqe->res, cqe->flags); HyperaioTrace trace("harvest: userdata " + std::to_string(cqe->user_data) + " res " + std::to_string(cqe->res) + "flags " + std::to_string(cqe->flags)); io_uring_cqe_seen(&pImpl_->uring_, cqe); -- Gitee From 6cd75df9f369c05bc6ed057c7f1c25470493bca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Mon, 16 Jun 2025 17:30:37 +0800 Subject: [PATCH 05/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 47 +++++++++-------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index a9b5629dc..baadeab4f 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -53,6 +53,10 @@ static bool HasAccessIouringPermission() return true; } +static bool ValidateReqNum(uint32_t reqNum) { + return reqNum > 0 && reqNum <= URING_QUEUE_SIZE; +} + uint32_t HyperAio::SupportIouring() { HyperaioTrace trace("SupportIouring"); @@ -121,6 +125,10 @@ int32_t HyperAio::StartOpenReqs(OpenReqs *req) HILOGE("HyperAio is not initialized"); return -EPERM; } + if (!ValidateReqNum(req->reqNum)) { + HILOGE("reqNum is out of range: %{public}u", req->reqNum); + return -EINVAL; + } HyperaioTrace trace("StartOpenReqs" + std::to_string(req->reqNum)); uint32_t totalReqs = req->reqNum; uint32_t count = 0; @@ -139,7 +147,7 @@ int32_t HyperAio::StartOpenReqs(OpenReqs *req) HyperaioTrace trace("open flags:" + std::to_string(openInfo->flags) + "mode:" + std::to_string(openInfo->mode) + "userData:" + std::to_string(openInfo->userData)); count++; - if (count >= BATCH_SIZE) { + if (count >= BATCH_SIZE || i == totalReqs - 1) { int32_t ret = io_uring_submit(&pImpl_->uring_); if (ret < 0) { HILOGE("submit open reqs failed, ret = %{public}d", ret); @@ -149,14 +157,6 @@ int32_t HyperAio::StartOpenReqs(OpenReqs *req) count = 0; } } - if (count > 0 && count < BATCH_SIZE) { - int32_t ret = io_uring_submit(&pImpl_->uring_); - if (ret < 0) { - HILOGE("submit open reqs failed, ret = %{public}d", ret); - return ret; - } - openReqCount_ += count; - } return EOK; } @@ -172,6 +172,10 @@ int32_t HyperAio::StartReadReqs(ReadReqs *req) HILOGE("HyperAio is not initialized"); return -EPERM; } + if (!ValidateReqNum(req->reqNum)) { + HILOGE("reqNum is out of range: %{public}u", req->reqNum); + return -EINVAL; + } HyperaioTrace trace("StartReadReqs" + std::to_string(req->reqNum)); uint32_t totalReqs = req->reqNum; uint32_t count = 0; @@ -189,7 +193,7 @@ int32_t HyperAio::StartReadReqs(ReadReqs *req) HyperaioTrace trace("read len:" + std::to_string(readInfo->len) + "offset:" + std::to_string(readInfo->offset) + "userData:" + std::to_string(readInfo->userData)); count++; - if (count >= BATCH_SIZE) { + if (count >= BATCH_SIZE || i == totalReqs - 1) { int32_t ret = io_uring_submit(&pImpl_->uring_); if (ret < 0) { HILOGE("submit read reqs failed, ret = %{public}d", ret); @@ -199,15 +203,6 @@ int32_t HyperAio::StartReadReqs(ReadReqs *req) count = 0; } } - if (count > 0 && count < BATCH_SIZE) { - int32_t ret = io_uring_submit(&pImpl_->uring_); - if (ret < 0) { - HILOGE("submit read reqs failed, ret = %{public}d", ret); - return ret; - } - readReqCount_ += count; - } - return EOK; } @@ -223,6 +218,10 @@ int32_t HyperAio::StartCancelReqs(CancelReqs *req) HILOGE("HyperAio is not initialized"); return -EPERM; } + if (!ValidateReqNum(req->reqNum)) { + HILOGE("reqNum is out of range: %{public}u", req->reqNum); + return -EINVAL; + } HyperaioTrace trace("StartCancelReqs" + std::to_string(req->reqNum)); uint32_t totalReqs = req->reqNum; uint32_t count = 0; @@ -240,7 +239,7 @@ int32_t HyperAio::StartCancelReqs(CancelReqs *req) HyperaioTrace trace("cancel userData:" + std::to_string(cancelInfo->userData) + "targetUserData:" + std::to_string(cancelInfo->targetUserData)); count++; - if (count >= BATCH_SIZE) { + if (count >= BATCH_SIZE || i == totalReqs - 1) { int32_t ret = io_uring_submit(&pImpl_->uring_); if (ret < 0) { HILOGE("submit cancel reqs failed, ret = %{public}d", ret); @@ -250,14 +249,6 @@ int32_t HyperAio::StartCancelReqs(CancelReqs *req) count = 0; } } - if (count > 0 && count < BATCH_SIZE) { - int32_t ret = io_uring_submit(&pImpl_->uring_); - if (ret < 0) { - HILOGE("submit cancel reqs failed, ret = %{public}d", ret); - return ret; - } - cancelReqCount_ += count; - } return EOK; } -- Gitee From 2becbe878cb595d3f6f23a9a2f019bbf5d6124bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Mon, 16 Jun 2025 18:43:49 +0800 Subject: [PATCH 06/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index baadeab4f..c4f16cc46 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -53,7 +53,8 @@ static bool HasAccessIouringPermission() return true; } -static bool ValidateReqNum(uint32_t reqNum) { +static bool ValidateReqNum(uint32_t reqNum) +{ return reqNum > 0 && reqNum <= URING_QUEUE_SIZE; } -- Gitee From 7dcf0fd1d05e90a9ade0949ee00e13c3ec6ffad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Mon, 16 Jun 2025 20:22:44 +0800 Subject: [PATCH 07/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- .../test/unittest/hyperaio/hyperaio_test.cpp | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp index 2d43b7d86..30e7d4889 100644 --- a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -35,6 +35,7 @@ namespace OHOS::HyperAio { const uint64_t userData = 12345; const uint32_t len = 1024; const uint32_t batchSize = 300; + const uint32_t Threshold = 600; HyperAio::ProcessIoResultCallBack callBack = [](std::unique_ptr response) { GTEST_LOG_(INFO) << "HyperAioTest callBack"; }; @@ -227,6 +228,36 @@ namespace OHOS::HyperAio { GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartOpenReqs_0003"; } + /** + * @tc.name: HyperAio_StartOpenReqs_0004 + * @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_StartOpenReqs_0004, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartOpenReqs_0004"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + auto openInfos = std::make_unique(Threshold); + for (int i = 0; i < Threshold; ++i) { + openInfos[i].dfd = 0; + openInfos[i].flags = O_RDWR; + openInfos[i].mode = 0; + openInfos[i].path = nullptr; + openInfos[i].userData = userData + i; + } + OpenReqs openReqs = {Threshold, openInfos.get()}; + result = hyperAio_->StartOpenReqs(&openReqs); + EXPECT_EQ(result, -EINVAL); + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartOpenReqs_0004"; + } + /** * @tc.name: HyperAio_StartReadReqs_0000 * @tc.desc: Test function of StartReadReqs() interface for SUCCESS. @@ -293,6 +324,65 @@ namespace OHOS::HyperAio { GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0002"; } + /** + * @tc.name: HyperAio_StartReadReqs_0003 + * @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_0003, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0003"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + auto readInfos = std::make_unique(batchSize); + for (int i = 0; i < batchSize; ++i) { + readInfos[i].fd = 0; + readInfos[i].len = len; + readInfos[i].offset = 0; + readInfos[i].buf = nullptr; + readInfos[i].userData = userData + i; + } + ReadReqs readReqs = {batchSize, readInfos.get()}; + result = hyperAio_->StartReadReqs(&readReqs); + EXPECT_EQ(result, 0); + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0003"; + } + + /** + * @tc.name: HyperAio_StartReadReqs_0004 + * @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_0004, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0004"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + auto readInfos = std::make_unique(Threshold); + for (int i = 0; i < Threshold; ++i) { + readInfos[i].fd = 0; + readInfos[i].len = len; + readInfos[i].offset = 0; + readInfos[i].buf = nullptr; + readInfos[i].userData = userData + i; + } + ReadReqs readReqs = {Threshold, readInfos.get()}; + result = hyperAio_->StartReadReqs(&readReqs); + EXPECT_EQ(result, -EINVAL); + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0004"; + } /** * @tc.name: HyperAio_StartCancelReqs_0000 * @tc.desc: Test function of StartCancelReqs() interface for SUCCESS. @@ -357,5 +447,59 @@ namespace OHOS::HyperAio { EXPECT_EQ(result, 0); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0002"; } + + /** + * @tc.name: HyperAio_StartCancelReqs_0003 + * @tc.desc: Test function of StartCancelReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0003, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0003"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + auto cancelInfos = std::make_unique(batchSize); + for (int i = 0; i < batchSize; ++i) { + cancelInfos[i].userData = userData + i; + cancelInfos[i].targetUserData = userData + i; + } + CancelReqs cancelReqs = {batchSize, cancelInfos.get()}; + result = hyperAio_->StartCancelReqs(&cancelReqs); + EXPECT_EQ(result, 0); + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0003"; + } + + /** + * @tc.name: HyperAio_StartCancelReqs_0004 + * @tc.desc: Test function of StartCancelReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0004, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0004"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + auto cancelInfos = std::make_unique(Threshold); + for (int i = 0; i < Threshold; ++i) { + cancelInfos[i].userData = userData + i; + cancelInfos[i].targetUserData = userData + i; + } + CancelReqs cancelReqs = {Threshold, cancelInfos.get()}; + result = hyperAio_->StartCancelReqs(&cancelReqs); + EXPECT_EQ(result, -EINVAL); + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0004"; + } #endif } -- Gitee From 1a71098af962f3db9f908e9d8bbef59f6f758641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Mon, 16 Jun 2025 21:33:42 +0800 Subject: [PATCH 08/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- .../test/unittest/hyperaio/hyperaio_test.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp index 30e7d4889..f966a16a2 100644 --- a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -343,7 +343,7 @@ namespace OHOS::HyperAio { readInfos[i].fd = 0; readInfos[i].len = len; readInfos[i].offset = 0; - readInfos[i].buf = nullptr; + readInfos[i].buf = nullptr; readInfos[i].userData = userData + i; } ReadReqs readReqs = {batchSize, readInfos.get()}; @@ -373,7 +373,7 @@ namespace OHOS::HyperAio { readInfos[i].fd = 0; readInfos[i].len = len; readInfos[i].offset = 0; - readInfos[i].buf = nullptr; + readInfos[i].buf = nullptr; readInfos[i].userData = userData + i; } ReadReqs readReqs = {Threshold, readInfos.get()}; @@ -501,5 +501,22 @@ namespace OHOS::HyperAio { EXPECT_EQ(result, 0); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0004"; } + + /** + * @tc.name: HyperAio_DestoryCtx_0000 + * @tc.desc: Test function of StartCancelReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_DestoryCtx_0000, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_DestoryCtx_0000"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_DestoryCtx_0000"; + } #endif } -- Gitee From a71742cfc784e77b0b92b2df16b6dfceda06a28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Tue, 17 Jun 2025 10:52:04 +0800 Subject: [PATCH 09/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index c4f16cc46..42a3d8f63 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -267,6 +267,10 @@ void HyperAio::HarvestRes() HILOGI("wait cqe failed, ret = %{public}d", ret); continue; } + if (cqe->res < 0) { + HILOGI("cqe failed, cqe->res = %{public}d", cqe->res); + continue; + } cqeCount_++; auto response = std::make_unique(cqe->user_data, cqe->res, cqe->flags); HyperaioTrace trace("harvest: userdata " + std::to_string(cqe->user_data) -- Gitee From 933d87e139a203969c97be9bd2e1a422b33f0998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 20 Jun 2025 17:00:25 +0800 Subject: [PATCH 10/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 3 +- .../test/unittest/hyperaio/hyperaio_test.cpp | 120 +++++++++++++++++- .../test/unittest/hyperaio/include/liburing.h | 33 ++++- 3 files changed, 146 insertions(+), 10 deletions(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index 42a3d8f63..dbd43039c 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -267,11 +267,10 @@ void HyperAio::HarvestRes() HILOGI("wait cqe failed, ret = %{public}d", ret); continue; } + cqeCount_++; if (cqe->res < 0) { HILOGI("cqe failed, cqe->res = %{public}d", cqe->res); - continue; } - cqeCount_++; auto response = std::make_unique(cqe->user_data, cqe->res, cqe->flags); HyperaioTrace trace("harvest: userdata " + std::to_string(cqe->user_data) + " res " + std::to_string(cqe->res) + "flags " + std::to_string(cqe->flags)); diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp index f966a16a2..f33fbff9e 100644 --- a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -39,6 +39,7 @@ namespace OHOS::HyperAio { HyperAio::ProcessIoResultCallBack callBack = [](std::unique_ptr response) { GTEST_LOG_(INFO) << "HyperAioTest callBack"; }; + /** * @tc.name: HyperAio_SupportIouring_0000 * @tc.desc: Test function of SupportIouring() interface for SUCCESS. @@ -58,6 +59,7 @@ namespace OHOS::HyperAio { } GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_SupportIouring_0000"; } + /** * @tc.name: HyperAio_CtxInit_0000 * @tc.desc: Test function of CtxInit() interface for SUCCESS. @@ -78,6 +80,7 @@ namespace OHOS::HyperAio { hyperAio_->DestroyCtx(); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_CtxInit_0000"; } + /** * @tc.name: HyperAio_CtxInit_0001 * @tc.desc: Test function of CtxInit() interface for SUCCESS. @@ -94,6 +97,7 @@ namespace OHOS::HyperAio { EXPECT_EQ(result, -EINVAL); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_CtxInit_0001"; } + /** * @tc.name: HyperAio_CtxInit_0002 * @tc.desc: Test function of CtxInit() interface for SUCCESS. @@ -111,6 +115,7 @@ namespace OHOS::HyperAio { hyperAio_->DestroyCtx(); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_CtxInit_0002"; } + /** * @tc.name: HyperAio_CtxInit_0003 * @tc.desc: Test function of CtxInit() interface for SUCCESS. @@ -130,6 +135,26 @@ namespace OHOS::HyperAio { hyperAio_->DestroyCtx(); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_CtxInit_0003"; } + + /** + * @tc.name: HyperAio_CtxInit_0004 + * @tc.desc: Test function of CtxInit() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_CtxInit_0004, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_CtxInit_0004"; + std::unique_ptr hyperAio_ = std::make_unique(); + init_flag = false; + int32_t result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, -1); + init_flag = true; + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_CtxInit_0004"; + } + /** * @tc.name: HyperAio_StartOpenReqs_0000 * @tc.desc: Test function of StartOpenReqs() interface for SUCCESS. @@ -223,6 +248,10 @@ namespace OHOS::HyperAio { OpenReqs openReqs = {batchSize, openInfos.get()}; result = hyperAio_->StartOpenReqs(&openReqs); EXPECT_EQ(result, 0); + sqe_flag = false; + result = hyperAio_->StartOpenReqs(&openReqs); + EXPECT_EQ(result, -ENOMEM); + sqe_flag = true; result = hyperAio_->DestroyCtx(); EXPECT_EQ(result, 0); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartOpenReqs_0003"; @@ -258,6 +287,23 @@ namespace OHOS::HyperAio { GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartOpenReqs_0004"; } + /** + * @tc.name: HyperAio_StartOpenReqs_0005 + * @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_StartOpenReqs_0005, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartOpenReqs_0005"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->StartOpenReqs(nullptr); + EXPECT_EQ(result, -EINVAL); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartOpenReqs_0005"; + } + /** * @tc.name: HyperAio_StartReadReqs_0000 * @tc.desc: Test function of StartReadReqs() interface for SUCCESS. @@ -349,6 +395,10 @@ namespace OHOS::HyperAio { ReadReqs readReqs = {batchSize, readInfos.get()}; result = hyperAio_->StartReadReqs(&readReqs); EXPECT_EQ(result, 0); + sqe_flag = false; + result = hyperAio_->StartReadReqs(&readReqs); + EXPECT_EQ(result, -ENOMEM); + sqe_flag = true; result = hyperAio_->DestroyCtx(); EXPECT_EQ(result, 0); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0003"; @@ -383,6 +433,24 @@ namespace OHOS::HyperAio { EXPECT_EQ(result, 0); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0004"; } + + /** + * @tc.name: HyperAio_StartReadReqs_0005 + * @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_0005, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0005"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->StartReadReqs(nullptr); + EXPECT_EQ(result, -EINVAL); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0005"; + } + /** * @tc.name: HyperAio_StartCancelReqs_0000 * @tc.desc: Test function of StartCancelReqs() interface for SUCCESS. @@ -470,6 +538,10 @@ namespace OHOS::HyperAio { CancelReqs cancelReqs = {batchSize, cancelInfos.get()}; result = hyperAio_->StartCancelReqs(&cancelReqs); EXPECT_EQ(result, 0); + sqe_flag = false; + result = hyperAio_->StartCancelReqs(&cancelReqs); + EXPECT_EQ(result, -ENOMEM); + sqe_flag = true; result = hyperAio_->DestroyCtx(); EXPECT_EQ(result, 0); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0003"; @@ -503,20 +575,58 @@ namespace OHOS::HyperAio { } /** - * @tc.name: HyperAio_DestoryCtx_0000 + * @tc.name: HyperAio_StartCancelReqs_0005 * @tc.desc: Test function of StartCancelReqs() interface for SUCCESS. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 * @tc.require: AR000HG8M4 */ - HWTEST_F(HyperAioTest, HyperAio_DestoryCtx_0000, testing::ext::TestSize.Level1) + HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0005, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0005"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->StartCancelReqs(nullptr); + EXPECT_EQ(result, -EINVAL); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0005"; + } + + /** + * @tc.name: HyperAio_HarvestRes_0000 + * @tc.desc: Test function of HarvestRes() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_HarvestRes_0000, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_HarvestRes_0000"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + wait_flag = false; + hyperAio_->pImpl_ = nullptr; + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_HarvestRes_0000"; + } + + /** + * @tc.name: HyperAio_DestroyCtx_0000 + * @tc.desc: Test function of DestoryCtx() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_DestroyCtx_0000, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_DestoryCtx_0000"; + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_DestroyCtx_0000"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->DestroyCtx(); EXPECT_EQ(result, 0); - GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_DestoryCtx_0000"; + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_DestroyCtx_0000"; } -#endif +#endif } diff --git a/interfaces/test/unittest/hyperaio/include/liburing.h b/interfaces/test/unittest/hyperaio/include/liburing.h index de049be01..7c8e3251c 100644 --- a/interfaces/test/unittest/hyperaio/include/liburing.h +++ b/interfaces/test/unittest/hyperaio/include/liburing.h @@ -16,9 +16,14 @@ #ifndef UNITTEST_HYPERAIO_INCLUDE_LIBURING_H #define UNITTEST_HYPERAIO_INCLUDE_LIBURING_H +#include +#include namespace OHOS { namespace HyperAio { #define O_RDWR 02 +inline bool sqe_flag = true; +inline bool init_flag = true; +inline bool wait_flag = true; struct io_uring_sqe { int32_t data; }; @@ -31,12 +36,26 @@ struct io_uring_cqe { }; struct io_uring { - int32_t data; + std::vector> sqe_list; + io_uring() {} + ~io_uring() {} + inline io_uring_cqe *io_uring_get_sqe() { + auto sqe = std::make_shared(); + io_uring_sqe *raw_sqe = sqe.get(); + sqe_list.push_back(std::move(sqe)); + return raw_sqe; + } + void clear_sqes() { + sqe_list.clear(); + } }; inline struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring) { - return new io_uring_sqe(); + if (sqe_flag) { + return ring->io_uring_get_sqe(); + } + return nullptr; } inline int io_uring_submit(struct io_uring *ring) @@ -46,7 +65,10 @@ inline int io_uring_submit(struct io_uring *ring) inline int io_uring_queue_init(unsigned entries, struct io_uring *ring, unsigned flags) { - return 1; + if (init_flag) { + return 1; + } + return -1; } inline void io_uring_sqe_set_data(struct io_uring_sqe *sqe, void *data) @@ -74,6 +96,11 @@ inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, inline int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr) { + std::this_thread::sleep_for(std::chrono:::second(1)); + if (!wait_flag) { + wait_flag = true; + return -1; + } *cqe_ptr = new io_uring_cqe; (*cqe_ptr)->data = 0; (*cqe_ptr)->user_data = 0; -- Gitee From 1f3a70ab0756fb9914fd6871bcda2877e4f040da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 20 Jun 2025 17:08:19 +0800 Subject: [PATCH 11/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- .../test/unittest/hyperaio/hyperaio_test.cpp | 25 +++++++++++++++++-- .../test/unittest/hyperaio/include/liburing.h | 14 ++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp index f33fbff9e..a3a908353 100644 --- a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -612,9 +612,30 @@ namespace OHOS::HyperAio { GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_HarvestRes_0000"; } + /** + * @tc.name: HyperAio_HarvestRes_0001 + * @tc.desc: Test function of HarvestRes() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_HarvestRes_0001, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_HarvestRes_0001"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + cqe_res_flag = false; + std::this_thread::sleep_for(std::chrono::seconds(2)); + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_HarvestRes_0001"; + } + /** * @tc.name: HyperAio_DestroyCtx_0000 - * @tc.desc: Test function of DestoryCtx() interface for SUCCESS. + * @tc.desc: Test function of DestroyCtx() interface for SUCCESS. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 @@ -628,5 +649,5 @@ namespace OHOS::HyperAio { EXPECT_EQ(result, 0); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_DestroyCtx_0000"; } -#endif +#endif } diff --git a/interfaces/test/unittest/hyperaio/include/liburing.h b/interfaces/test/unittest/hyperaio/include/liburing.h index 7c8e3251c..a80649206 100644 --- a/interfaces/test/unittest/hyperaio/include/liburing.h +++ b/interfaces/test/unittest/hyperaio/include/liburing.h @@ -24,6 +24,7 @@ namespace HyperAio { inline bool sqe_flag = true; inline bool init_flag = true; inline bool wait_flag = true; +inline bool cqe_res_flag = true; struct io_uring_sqe { int32_t data; }; @@ -39,8 +40,8 @@ struct io_uring { std::vector> sqe_list; io_uring() {} ~io_uring() {} - inline io_uring_cqe *io_uring_get_sqe() { - auto sqe = std::make_shared(); + inline io_uring_sqe *io_uring_get_sqe() { + auto sqe = std::make_unique(); io_uring_sqe *raw_sqe = sqe.get(); sqe_list.push_back(std::move(sqe)); return raw_sqe; @@ -96,7 +97,7 @@ inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, inline int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr) { - std::this_thread::sleep_for(std::chrono:::second(1)); + std::this_thread::sleep_for(std::chrono::seconds(1)); if (!wait_flag) { wait_flag = true; return -1; @@ -104,8 +105,13 @@ inline int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_pt *cqe_ptr = new io_uring_cqe; (*cqe_ptr)->data = 0; (*cqe_ptr)->user_data = 0; - (*cqe_ptr)->res = 0; (*cqe_ptr)->flags = 0; + if (!cqe_res_flag) { + (*cqe_ptr)->res = -1; + cqe_res_flag = true; + } else { + (*cqe_ptr)->res = 0; + } return 1; } -- Gitee From 4bbc7110c7b0ee651654cdee39ff5afef6febbfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 20 Jun 2025 17:16:00 +0800 Subject: [PATCH 12/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/test/unittest/hyperaio/hyperaio_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp index a3a908353..5c13ced5b 100644 --- a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -68,7 +68,7 @@ namespace OHOS::HyperAio { * @tc.level Level 1 * @tc.require: AR000HG8M4 */ - HWTEST_F(HyperAioTest, HyperAio_CtxInit_0000, testing::ext::TestSize.Level1) + HWTEST_F(HyperAioTest, HyperAio_CtxInit_0000, testing::ext::TestSize.Level0) { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_CtxInit_0000"; std::unique_ptr hyperAio_ = std::make_unique(); @@ -208,7 +208,7 @@ namespace OHOS::HyperAio { * @tc.level Level 1 * @tc.require: AR000HG8M4 */ - HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0002, testing::ext::TestSize.Level1) + HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0002, testing::ext::TestSize.Level0) { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartOpenReqs_0002"; std::unique_ptr hyperAio_ = std::make_unique(); @@ -356,7 +356,7 @@ namespace OHOS::HyperAio { * @tc.level Level 1 * @tc.require: AR000HG8M4 */ - HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0002, testing::ext::TestSize.Level1) + HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0002, testing::ext::TestSize.Level0) { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0002"; std::unique_ptr hyperAio_ = std::make_unique(); @@ -502,7 +502,7 @@ namespace OHOS::HyperAio { * @tc.level Level 1 * @tc.require: AR000HG8M4 */ - HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0002, testing::ext::TestSize.Level1) + HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0002, testing::ext::TestSize.Level0) { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0002"; std::unique_ptr hyperAio_ = std::make_unique(); -- Gitee From 1f8befde61df74af8be4a0f742db6ab01427c5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 20 Jun 2025 17:20:33 +0800 Subject: [PATCH 13/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index dbd43039c..780b21798 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -295,7 +295,7 @@ int32_t HyperAio::DestroyCtx() if (harvestThread_.joinable()) { HILOGI("start harvest thread join"); harvestThread_.join(); - // No print this log means join failed + // This log is only printed after join() completes successfully HILOGI("join success"); } -- Gitee From b884819d49311b35ef254d1748d4077100bc8f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sat, 21 Jun 2025 21:05:28 +0800 Subject: [PATCH 14/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- .../test/unittest/hyperaio/include/liburing.h | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/interfaces/test/unittest/hyperaio/include/liburing.h b/interfaces/test/unittest/hyperaio/include/liburing.h index a80649206..c4ab219bc 100644 --- a/interfaces/test/unittest/hyperaio/include/liburing.h +++ b/interfaces/test/unittest/hyperaio/include/liburing.h @@ -40,13 +40,15 @@ struct io_uring { std::vector> sqe_list; io_uring() {} ~io_uring() {} - inline io_uring_sqe *io_uring_get_sqe() { + inline io_uring_sqe *io_uring_get_sqe() + { auto sqe = std::make_unique(); io_uring_sqe *raw_sqe = sqe.get(); sqe_list.push_back(std::move(sqe)); return raw_sqe; } - void clear_sqes() { + void clear_sqes() + { sqe_list.clear(); } }; @@ -95,23 +97,13 @@ inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, return; } -inline int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr) +inline int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr) { std::this_thread::sleep_for(std::chrono::seconds(1)); - if (!wait_flag) { - wait_flag = true; - return -1; - } - *cqe_ptr = new io_uring_cqe; - (*cqe_ptr)->data = 0; - (*cqe_ptr)->user_data = 0; - (*cqe_ptr)->flags = 0; - if (!cqe_res_flag) { - (*cqe_ptr)->res = -1; - cqe_res_flag = true; - } else { - (*cqe_ptr)->res = 0; - } + if (!wait_flag) return wait_flag = true, -1; + *cqe_ptr = new io_uring_cqe(); + (*cqe_ptr)->res = cqe_res_flag ? 0 : -1; + cqe_res_flag = true; return 1; } -- Gitee From 534ab2e143a2108f9790e8d4880abd76a1ba2621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sat, 21 Jun 2025 21:06:55 +0800 Subject: [PATCH 15/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index 780b21798..1f5dc006d 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -55,7 +55,7 @@ static bool HasAccessIouringPermission() static bool ValidateReqNum(uint32_t reqNum) { - return reqNum > 0 && reqNum <= URING_QUEUE_SIZE; + return reqNum > 0 && reqNum <= URING_QUEUE_SIZE - 1; } uint32_t HyperAio::SupportIouring() -- Gitee From 1022c66504c58b80e953039cf901a8d88977331c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sat, 21 Jun 2025 22:36:56 +0800 Subject: [PATCH 16/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/test/unittest/hyperaio/include/liburing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/test/unittest/hyperaio/include/liburing.h b/interfaces/test/unittest/hyperaio/include/liburing.h index c4ab219bc..a5988e2bc 100644 --- a/interfaces/test/unittest/hyperaio/include/liburing.h +++ b/interfaces/test/unittest/hyperaio/include/liburing.h @@ -97,7 +97,7 @@ inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, return; } -inline int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr) +inline int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr) { std::this_thread::sleep_for(std::chrono::seconds(1)); if (!wait_flag) return wait_flag = true, -1; -- Gitee From 5aa9b9ff2758845f90b1d76223e1b72abffae65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sun, 22 Jun 2025 18:53:56 +0800 Subject: [PATCH 17/17] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- .../test/unittest/hyperaio/hyperaio_test.cpp | 27 ------------------- .../test/unittest/hyperaio/include/liburing.h | 5 +++- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp index 5c13ced5b..b1916adbd 100644 --- a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -46,7 +46,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_SupportIouring_0000, testing::ext::TestSize.Level1) { @@ -66,7 +65,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_CtxInit_0000, testing::ext::TestSize.Level0) { @@ -87,7 +85,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_CtxInit_0001, testing::ext::TestSize.Level1) { @@ -104,7 +101,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_CtxInit_0002, testing::ext::TestSize.Level1) { @@ -122,7 +118,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_CtxInit_0003, testing::ext::TestSize.Level1) { @@ -142,7 +137,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_CtxInit_0004, testing::ext::TestSize.Level1) { @@ -161,7 +155,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0000, testing::ext::TestSize.Level1) { @@ -181,7 +174,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0001, testing::ext::TestSize.Level1) { @@ -206,7 +198,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0002, testing::ext::TestSize.Level0) { @@ -229,7 +220,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0003, testing::ext::TestSize.Level1) { @@ -263,7 +253,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0004, testing::ext::TestSize.Level1) { @@ -293,7 +282,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0005, testing::ext::TestSize.Level1) { @@ -310,7 +298,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0000, testing::ext::TestSize.Level1) { @@ -329,7 +316,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0001, testing::ext::TestSize.Level1) { @@ -354,7 +340,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0002, testing::ext::TestSize.Level0) { @@ -376,7 +361,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0003, testing::ext::TestSize.Level1) { @@ -410,7 +394,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0004, testing::ext::TestSize.Level1) { @@ -440,7 +423,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0005, testing::ext::TestSize.Level1) { @@ -457,7 +439,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0000, testing::ext::TestSize.Level1) { @@ -476,7 +457,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0001, testing::ext::TestSize.Level1) { @@ -500,7 +480,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0002, testing::ext::TestSize.Level0) { @@ -522,7 +501,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0003, testing::ext::TestSize.Level1) { @@ -553,7 +531,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0004, testing::ext::TestSize.Level1) { @@ -580,7 +557,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0005, testing::ext::TestSize.Level1) { @@ -597,7 +573,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_HarvestRes_0000, testing::ext::TestSize.Level1) { @@ -618,7 +593,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_HarvestRes_0001, testing::ext::TestSize.Level1) { @@ -639,7 +613,6 @@ namespace OHOS::HyperAio { * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 - * @tc.require: AR000HG8M4 */ HWTEST_F(HyperAioTest, HyperAio_DestroyCtx_0000, testing::ext::TestSize.Level1) { diff --git a/interfaces/test/unittest/hyperaio/include/liburing.h b/interfaces/test/unittest/hyperaio/include/liburing.h index a5988e2bc..b00112be3 100644 --- a/interfaces/test/unittest/hyperaio/include/liburing.h +++ b/interfaces/test/unittest/hyperaio/include/liburing.h @@ -100,7 +100,10 @@ inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, inline int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr) { std::this_thread::sleep_for(std::chrono::seconds(1)); - if (!wait_flag) return wait_flag = true, -1; + if (!wait_flag) { + wait_flag = true; + return -1; + } *cqe_ptr = new io_uring_cqe(); (*cqe_ptr)->res = cqe_res_flag ? 0 : -1; cqe_res_flag = true; -- Gitee