提交 5ae18cf3 编写于 作者: Z zhangdengyu

feat:修复使用不规范的测试用例

1、接口入参类型为int,用例传入参数为NULL,类型不匹配。
2、ACtsNetTest.cpp中测试musl
c库中herror接口,musl升级之后herror逻辑改变,测试用例需要同步修改

Close: #I6J7QK
Signed-off-by: Nzhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I64efb044f2aacc5373e0b48cb25cd5567ed57262
上级 e6b2581d
......@@ -237,7 +237,7 @@ HWTEST_F(IpcMqTest, testMqOpenENOSPC, Function | MediumTest | Level3)
*/
HWTEST_F(IpcMqTest, testMqCloseEBADF, Function | MediumTest | Level2)
{
ASSERT_TRUE(mq_close(NULL) == -1) << "ERROR: mq_close() != -1";
ASSERT_TRUE(mq_close(0) == -1) << "ERROR: mq_close() != -1";
ASSERT_TRUE(errno == EBADF) << "ERROR: errno != EBADF, errno = " << errno << " EBADF = " << EBADF;
}
......@@ -283,7 +283,7 @@ HWTEST_F(IpcMqTest, testMqSendEBADFEMSGSIZE, Function | MediumTest | Level2)
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
ASSERT_TRUE(queue != (mqd_t)-1) << "ERROR: mq_open() == (mqd_t)-1";
EXPECT_TRUE(mq_send(NULL, MQ_MSG, 1, MQ_MSG_PRIO) == -1) << "ERROR: mq_send() != -1";
EXPECT_TRUE(mq_send(0, MQ_MSG, 1, MQ_MSG_PRIO) == -1) << "ERROR: mq_send() != -1";
EXPECT_TRUE(errno == EBADF) << "ERROR: errno != EBADF, errno = " << errno << " EBADF = " << EBADF;
EXPECT_TRUE(mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO) == -1) << "ERROR: mq_send() != -1";
......@@ -390,7 +390,7 @@ HWTEST_F(IpcMqTest, testMqReceiveEBADFEMSGSIZE, Function | MediumTest | Level2)
EXPECT_TRUE(strncmp(MQ_MSG, rMsg, MQ_MSG_LEN) == 0) << "ERROR: strncmp() != 0, sent != received: sent = " <<
MQ_MSG << ", received = " << rMsg;
EXPECT_TRUE(mq_receive(NULL, rMsg, getAttr.mq_msgsize, &prio) == -1) << "ERROR: mq_receive() != -1";
EXPECT_TRUE(mq_receive(0, rMsg, getAttr.mq_msgsize, &prio) == -1) << "ERROR: mq_receive() != -1";
EXPECT_TRUE(errno == EBADF) << "ERROR: errno != EBADF, errno = " << errno << " EBADF = " << EBADF;
EXPECT_TRUE(mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO) == 0) << "ERROR: mq_send() != 0";
......@@ -469,7 +469,7 @@ HWTEST_F(IpcMqTest, testMqTimedSendEAGAINEBADF, Function | MediumTest | Level2)
EXPECT_TRUE(mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts) == -1) << "ERROR: mq_timedsend() != 0";
EXPECT_TRUE(errno == EAGAIN) << "ERROR: errno != EAGAIN, errno = " << errno << " EAGAIN = " << EAGAIN;
EXPECT_TRUE(mq_timedsend(NULL, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts) == -1) << "ERROR: mq_timedsend() != -1";
EXPECT_TRUE(mq_timedsend(0, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts) == -1) << "ERROR: mq_timedsend() != -1";
EXPECT_TRUE(errno == EBADF) << "ERROR: errno != EBADF, errno = " << errno << " EBADF = " << EBADF;
EXPECT_TRUE(mq_close(queue) == 0) << "ERROR: mq_close() != 0";
......@@ -624,7 +624,7 @@ HWTEST_F(IpcMqTest, testMqTimedReceiveEAGAINEBADF, Function | MediumTest | Level
EXPECT_TRUE(mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &ts) == -1) << "ERROR: mq_timedreceive() != -1";
EXPECT_TRUE(errno == EAGAIN) << "ERROR: errno != EAGAIN, errno = " << errno << " EAGAIN = " << EAGAIN;
EXPECT_TRUE(mq_timedreceive(NULL, rMsg, getAttr.mq_msgsize, &prio, &ts) == -1) << "ERROR: mq_timedreceive() != -1";
EXPECT_TRUE(mq_timedreceive(0, rMsg, getAttr.mq_msgsize, &prio, &ts) == -1) << "ERROR: mq_timedreceive() != -1";
EXPECT_TRUE(errno == EBADF) << "ERROR: errno != EBADF, errno = " << errno << " EBADF = " << EBADF;
EXPECT_TRUE(mq_close(queue) == 0) << "ERROR: mq_close() != 0";
......@@ -635,12 +635,12 @@ HWTEST_F(IpcMqTest, testMqTimedReceiveEAGAINEBADF, Function | MediumTest | Level
queue = mq_open(qName, O_CREAT | O_WRONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
ASSERT_TRUE(queue != (mqd_t)-1) << "ERROR: mq_open() == (mqd_t)-1";
EXPECT_TRUE(mq_timedreceive(NULL, rMsg, getAttr.mq_msgsize, &prio, &ts) == -1) << "ERROR: mq_timedreceive() != -1";
EXPECT_TRUE(mq_timedreceive(0, rMsg, getAttr.mq_msgsize, &prio, &ts) == -1) << "ERROR: mq_timedreceive() != -1";
EXPECT_TRUE(errno == EBADF) << "ERROR: errno != EBADF, errno = " << errno << " EBADF = " << EBADF;
attr.mq_flags |= O_NONBLOCK;
EXPECT_TRUE(mq_setattr(queue, &attr, NULL) == 0) << "ERROR: mq_setattr() != 0";
EXPECT_TRUE(mq_timedreceive(NULL, rMsg, getAttr.mq_msgsize, &prio, &ts) == -1) << "ERROR: mq_timedreceive() != -1";
EXPECT_TRUE(mq_timedreceive(0, rMsg, getAttr.mq_msgsize, &prio, &ts) == -1) << "ERROR: mq_timedreceive() != -1";
EXPECT_TRUE(errno == EBADF) << "ERROR: errno != EBADF, errno = " << errno << " EBADF = " << EBADF;
EXPECT_TRUE(mq_close(queue) == 0) << "ERROR: mq_close() != 0";
......@@ -819,7 +819,7 @@ HWTEST_F(IpcMqTest, testMqGetAttrEBADFEINVAL, Function | MediumTest | Level2)
sprintf(qName, "testMqSendEINVAL_%d", GetRandom(10000));
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL);
ret = mq_getattr(NULL, &mqstat);
ret = mq_getattr(0, &mqstat);
EXPECT_TRUE(ret == -1) << "ERROR: mq_getattr() != -1, ret = " << ret;
EXPECT_TRUE(errno == EBADF) << "ERROR: errno != EBADF, errno = " << errno << " EBADF = " << EBADF;
......@@ -859,7 +859,7 @@ HWTEST_F(IpcMqTest, testMqSetAttrEBADFEINVAL, Function | MediumTest | Level2)
EXPECT_TRUE(gMqstat.mq_flags != sMqstat.mq_flags) << "ERROR: gMqstat != sMqstat, gMqstat.mq_flags = " <<
gMqstat.mq_flags << "sMqstat.mq_flags = " << sMqstat.mq_flags;
EXPECT_TRUE(mq_setattr(NULL, &sMqstat, NULL) == -1) << "ERROR: mq_setattr() != -1";
EXPECT_TRUE(mq_setattr(0, &sMqstat, NULL) == -1) << "ERROR: mq_setattr() != -1";
EXPECT_TRUE(errno == EBADF) << "ERROR: errno != EBADF, errno = " << errno << " EBADF = " << EBADF;
EXPECT_TRUE(mq_setattr(queue, NULL, NULL) == -1) << "ERROR: mq_setattr() != -1";
......
......@@ -3,9 +3,9 @@
* 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.
......@@ -116,7 +116,7 @@ static void* CommTcpClientTask(void *param)
*ret = 0;
int clnFd = socket(AF_INET, SOCK_STREAM, 0);
if (clnFd == -1) {
printf("[@@@][comm client]socket fail\n");
printf("[@@@][comm client]socket fail\n");
*ret = -1;
return ret;
}
......@@ -930,7 +930,7 @@ HWTEST_F(ActsNetTest, testSelectMultiClients, Function | MediumTest | Level2)
sleep(2);
int ret;
pthread_t pCli[4];
int pEroId[4] = {0};
int pEroId[4] = {0};
int interval[4] = {2, 1, 3, 1};
for (int i = 0; i < 4; i++) {
ret = pthread_create(&pCli[i], nullptr, CommTcpClientTask, &interval[i]);
......@@ -1044,7 +1044,7 @@ HWTEST_F(ActsNetTest, testPollMultiClients, Function | MediumTest | Level2)
sleep(2);
int ret;
pthread_t pCli[6];
int pEroId[6] = {0};
int pEroId[6] = {0};
int interval[6] = {2, 1, 3, 1, 2, 1};
for (int i = 0; i < 6; i++)
{
......@@ -1648,9 +1648,9 @@ HWTEST_F(ActsNetTest, testHerror, Function | MediumTest | Level2)
fclose(stderr);
char buffer[256];
const char* expectStr = "herror msg: Unknown errorherror msg: Host not foundherror msg: \
Try againherror msg: Non-recoverable errorherror msg: Address not availableherror msg: \
Address not availableherror msg: Unknown errorherror msg: Unknown errorherror msg: Unknown error";
const char* expectStr = "herror msg: Unknown error\nherror msg: Host not found\nherror msg: \
Try again\nherror msg: Non-recoverable error\nherror msg: Address not available\nherror msg: \
Address not available\nherror msg: Unknown error\nherror msg: Unknown error\nherror msg: Unknown error\n";
FILE* fpRead = fopen(fileName, "rb");
size_t bytes = fread(buffer, 1, sizeof(buffer), fpRead);
buffer[bytes] = 0;
......@@ -1809,7 +1809,7 @@ HWTEST_F(ActsNetTest, testInetPtonIpv6Normal, Function | MediumTest | Level2)
{
int ret;
struct in6_addr rst = {0};
char cpAddrs[6][40] = {"0101:0101:0101:0101:1010:1010:1010:1010", "0:0:0:0:0:0:0:0",
char cpAddrs[6][40] = {"0101:0101:0101:0101:1010:1010:1010:1010", "0:0:0:0:0:0:0:0",
"FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", "::", "1::", "0011:0011:0011:0011:11:11:11:11"};
for (int i = 0; i < 6; i++) {
ret = inet_pton(AF_INET6, cpAddrs[i], &rst);
......@@ -1913,9 +1913,9 @@ HWTEST_F(ActsNetTest, testInetNtopIpv6Normal, Function | MediumTest | Level2)
const char* ret = nullptr;
struct in6_addr inputAddr = {0};
char rstBuff[INET6_ADDRSTRLEN];
char inputAddrs[6][40] = {"0101:0101:0101:0101:1010:1010:1010:1010", "0:0:0:0:0:0:0:0",
char inputAddrs[6][40] = {"0101:0101:0101:0101:1010:1010:1010:1010", "0:0:0:0:0:0:0:0",
"FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", "::", "1::", "0011:0011:0011:0011:11:11:11:11"};
char expectAddrs[6][40] = {"101:101:101:101:1010:1010:1010:1010", "::",
char expectAddrs[6][40] = {"101:101:101:101:1010:1010:1010:1010", "::",
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "::", "1::", "11:11:11:11:11:11:11:11"};
for (int i = 0; i < 6; i++) {
iret = inet_pton(AF_INET6, inputAddrs[i], &inputAddr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册