提交 ec145c52 编写于 作者: O openharmony_ci 提交者: Gitee

!25 完善用例,适配不同平台recv接口差异

Merge pull request !25 from mlinlmcc/master
......@@ -139,9 +139,18 @@ static void SampleTcpServerTask(void)
waitServer();
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(sfd, buf, sizeof(buf), 0);
printf("[tcp server]recv, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, len * strlen(CLI_MSG));
unsigned int recvSum = 0;
int recvTimes = 50;
while (recvTimes > 0) {
ret = recv(sfd, buf, sizeof(buf), 0);
recvSum += ret;
if (recvSum == (len * strlen(SRV_MSG)) || ret <= 0) {
break;
}
recvTimes--;
}
printf("[tcp server]recv, recvSum=%d,recvTimes=%d\n", recvSum, recvTimes);
TEST_ASSERT_EQUAL_INT(len * strlen(CLI_MSG), recvSum);
ret = shutdown(sfd, SHUT_RDWR);
printf("[tcp server]shutdown, ret=%d\n", ret);
......@@ -226,9 +235,18 @@ static void SampleTcpClientTask(void)
waitClient();
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(sfd, buf, sizeof(buf), 0);
printf("[tcp client]recv, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, len * strlen(SRV_MSG));
unsigned int recvSum = 0;
int recvTimes = 50;
while (recvTimes > 0) {
ret = recv(sfd, buf, sizeof(buf), 0);
recvSum += ret;
if (recvSum == (len * strlen(SRV_MSG)) || ret <= 0) {
break;
}
recvTimes--;
}
printf("[tcp client]recv, recvSum=%d,recvTimes=%d\n", recvSum, recvTimes);
TEST_ASSERT_EQUAL_INT(len * strlen(SRV_MSG), recvSum);
ret = shutdown(sfd, SHUT_RDWR);
printf("[tcp client]shutdown, ret=%d\n", ret);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册