summaryrefslogtreecommitdiff
path: root/shaping/test/stub.cpp
diff options
context:
space:
mode:
authorliuchang <[email protected]>2023-05-30 02:46:03 +0000
committerliuchang <[email protected]>2023-05-30 02:46:03 +0000
commit452bca1a5a000856c5b0e401c1dd44007a63894d (patch)
tree4add72427a99b52518195d45f5dacb0aec86dfd4 /shaping/test/stub.cpp
parent66ea2254660e40f055668cfe1f8df3dc24e60475 (diff)
modify testcase for new global metric
Diffstat (limited to 'shaping/test/stub.cpp')
-rw-r--r--shaping/test/stub.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/shaping/test/stub.cpp b/shaping/test/stub.cpp
index 07f0935..c04ee13 100644
--- a/shaping/test/stub.cpp
+++ b/shaping/test/stub.cpp
@@ -294,11 +294,15 @@ static void swarmkv_hincrby_cmd_func(char *cmd_str, swarmkv_on_reply_callback_t
int profile_id;
int priority;
int value;
+ struct swarmkv_reply *reply = (struct swarmkv_reply*)calloc(1, sizeof(struct swarmkv_reply));
sscanf(cmd_str, "HINCRBY tsg-shaping-%d priority-%d %d", &profile_id, &priority, &value);
profile_priority_len[profile_id][priority] += value;
- cb(NULL, cb_arg);
+ reply->type = SWARMKV_REPLY_INTEGER;
+ cb(reply, cb_arg);
+
+ free(reply);
return;
}
@@ -320,14 +324,20 @@ static void swarmkv_hmget_cmd_func(char *cmd_str, swarmkv_on_reply_callback_t *
reply->elements = (struct swarmkv_reply**)calloc(priority_num, sizeof(struct swarmkv_reply*));
for (int i = 0; i < priority_num; i++) {
reply->elements[i] = (struct swarmkv_reply*)calloc(1, sizeof(struct swarmkv_reply));
- reply->elements[i]->type = SWARMKV_REPLY_INTEGER;
- reply->elements[i]->integer = profile_priority_len[profile_id][priority[i]];
+ reply->elements[i]->type = SWARMKV_REPLY_STRING;
+
+ char tmp_str[128] = {0};
+ sprintf(tmp_str, "%d", profile_priority_len[profile_id][priority[i]]);
+ reply->elements[i]->str = (char *)calloc(1, strlen(tmp_str));
+ memcpy(reply->elements[i]->str, tmp_str, strlen(tmp_str));
+ reply->elements[i]->len = strlen(tmp_str);
}
cb(reply, cb_arg);
for(unsigned int i = 0; i < reply->n_element; i++) {
if (reply->elements[i]) {
+ free(reply->elements[i]->str);
free(reply->elements[i]);
}
}