📄 testosmsgqidget.c
字号:
#include "msgqTest.h"
int testOSMsgIdGet()
{
OS_STATUS status;
unsigned32 MsgQ_id1,MsgQ_id2,MsgQ_id3,MsgQ_id4;
printf("*** test of OSMsgIdGet ***\n");
printf("create three MsgQs\n");
status = OSMsgQCreate("msg1",10,10,OS_DEFAULT,&MsgQ_id1);
if(status != OS_OK)
{
printf("OSMsgQCreate error:[%s]\n",serrno(errno));
return (-1);
}
printf("the id of MsgQ1 is %d\n",MsgQ_id1);
status = OSMsgQCreate("msg2",10,10,OS_DEFAULT,&MsgQ_id2);
if(status != OS_OK)
{
printf("OSMsgQCreate error:[%s]\n",serrno(errno));
return (-1);
}
printf("the id of MsgQ2 is %d\n",MsgQ_id2);
status = OSMsgQCreate("msg3",10,10,OS_DEFAULT,&MsgQ_id3);
if(status != OS_OK)
{
printf("OSMsgQCreate error:[%s]\n",serrno(errno));
return (-1);
}
printf("the id of MsgQ3 is %d\n",MsgQ_id3);
printf("get the id of MsgQ1...\n");
status = OSMsgQIdGet ("msg1",0,&MsgQ_id4);
if(status != OS_OK)
{
printf("OSMsgQIdGet error:[%s]\n",serrno(errno));
return (-1);
}
else
{
if (MsgQ_id1 == MsgQ_id4)
printf("the id of MsgQ1 got by OSMsgQIdGet is right![%d]\n",MsgQ_id4);
else
{
printf("the id of MsgQ1 got by OSMsgQIdGet is wrong![%d]\n",MsgQ_id4);
return -1;
}
}
printf("get the id of MsgQ2...\n");
status = OSMsgQIdGet ("msg2",0,&MsgQ_id4);
if(status != OS_OK)
{
printf("OSMsgQIdGet error:[%s]\n",serrno(errno));
return (-1);
}
else
{
if (MsgQ_id2 == MsgQ_id4)
printf("the id of MsgQ2 got by OSMsgQIdGet is right![%d]\n",MsgQ_id4);
else
{
printf("the id of MsgQ2 got by OSMsgQIdGet is wrong![%d]\n",MsgQ_id4);
return -1;
}
}
printf("get the id of MsgQ3...\n");
status = OSMsgQIdGet ("msg3",0,&MsgQ_id4);
if(status != OS_OK)
{
printf("OSMsgQIdGet error:[%s]\n",serrno(errno));
return (-1);
}
else
{
if (MsgQ_id3 == MsgQ_id4)
printf("the id of MsgQ3 got by OSMsgQIdGet is right![%d]\n",MsgQ_id4);
else
{
printf("the id of MsgQ3 got by OSMsgQIdGet is wrong![%d]\n",MsgQ_id4);
return -1;
}
}
OSMsgQDelete(MsgQ_id1);
OSMsgQDelete(MsgQ_id2);
OSMsgQDelete(MsgQ_id3);
printf("*** OSMsgIdGet test OK! ***\n\n");
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -