51 lines
1.5 KiB
Diff
51 lines
1.5 KiB
Diff
|
|
From 61a06b548e05edb3892eb08e1028ef71b41ee332 Mon Sep 17 00:00:00 2001
|
||
|
|
From: haozi007 <liuhao27@huawei.com>
|
||
|
|
Date: Fri, 2 Dec 2022 15:35:52 +0800
|
||
|
|
Subject: [PATCH 56/65] add ut test for retry macro
|
||
|
|
|
||
|
|
Signed-off-by: haozi007 <liuhao27@huawei.com>
|
||
|
|
---
|
||
|
|
test/cutils/utils_utils/utils_utils_ut.cc | 27 +++++++++++++++++++++++
|
||
|
|
1 file changed, 27 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/test/cutils/utils_utils/utils_utils_ut.cc b/test/cutils/utils_utils/utils_utils_ut.cc
|
||
|
|
index 531947d2..5bd98d47 100644
|
||
|
|
--- a/test/cutils/utils_utils/utils_utils_ut.cc
|
||
|
|
+++ b/test/cutils/utils_utils/utils_utils_ut.cc
|
||
|
|
@@ -269,4 +269,31 @@ TEST(utils_utils, test_convert_v2_runtime)
|
||
|
|
ASSERT_EQ(convert_v2_runtime(nullptr, buff), -1);
|
||
|
|
ASSERT_EQ(convert_v2_runtime(valid_str.c_str(), nullptr), -1);
|
||
|
|
ASSERT_EQ(convert_v2_runtime(valid_str.c_str(), buff), 0);
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+int global_total = 0;
|
||
|
|
+int retry_call_test(int success_idx) {
|
||
|
|
+ if (global_total == success_idx) {
|
||
|
|
+ return 0;
|
||
|
|
+ }
|
||
|
|
+ global_total++;
|
||
|
|
+ return -1;
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+TEST(utils_utils, test_do_retry_call)
|
||
|
|
+{
|
||
|
|
+ int nret;
|
||
|
|
+
|
||
|
|
+ global_total = 0;
|
||
|
|
+ DO_RETYR_CALL(10, 100, nret, retry_call_test, 0);
|
||
|
|
+ ASSERT_EQ(nret, 0);
|
||
|
|
+ ASSERT_EQ(global_total, 0);
|
||
|
|
+ global_total = 0;
|
||
|
|
+ DO_RETYR_CALL(10, 100, nret, retry_call_test, 5);
|
||
|
|
+ ASSERT_EQ(nret, 0);
|
||
|
|
+ ASSERT_EQ(global_total, 5);
|
||
|
|
+ global_total = 0;
|
||
|
|
+ DO_RETYR_CALL(10, 100, nret, retry_call_test, 11);
|
||
|
|
+ ASSERT_EQ(global_total, 10);
|
||
|
|
+ ASSERT_EQ(nret, -1);
|
||
|
|
}
|
||
|
|
\ No newline at end of file
|
||
|
|
--
|
||
|
|
2.25.1
|
||
|
|
|