| 90 | } |
| 91 | |
| 92 | int libc_mq() |
| 93 | { |
| 94 | mqd_t mq1 = 0, mq2 = 0; |
| 95 | struct mq_attr mqstat; |
| 96 | int oflag = O_CREAT|O_RDWR; |
| 97 | |
| 98 | memset(&mqstat, 0, sizeof(mqstat)); |
| 99 | mqstat.mq_maxmsg = MAX_MSG; |
| 100 | mqstat.mq_msgsize = MSG_SIZE; |
| 101 | mqstat.mq_flags = 0; |
| 102 | |
| 103 | if( ((mqd_t) -1) == (mq1 = mq_open(MQ_NAME_1,oflag,0777, &mqstat)) ) { |
| 104 | printf("mq_open doesn't return success \n"); |
| 105 | return -1; |
| 106 | } |
| 107 | if( ((mqd_t) -1) == (mq2 = mq_open(MQ_NAME_2,oflag,0777, &mqstat)) ) { |
| 108 | printf("mq_open doesn't return success \n"); |
| 109 | return -1; |
| 110 | } |
| 111 | pthread_create(&send1, NULL, (void *)send_1, (void *)&mq1); |
| 112 | pthread_create(&send2, NULL, (void *)send_2, (void *)&mq2); |
| 113 | pthread_create(&rev1, NULL, (void *)receive_1, (void *)&mq1); |
| 114 | pthread_create(&rev2, NULL, (void *)receive_2, (void *)&mq2); |
| 115 | pthread_join(send1, NULL); |
| 116 | pthread_join(send2, NULL); |
| 117 | pthread_join(rev1, NULL); |
| 118 | pthread_join(rev2, NULL); |
| 119 | |
| 120 | mq_close(mq1); |
| 121 | mq_close(mq2); |
| 122 | mq_unlink(MQ_NAME_1); |
| 123 | mq_unlink(MQ_NAME_2); |
| 124 | |
| 125 | printf("PASSED\n"); |
| 126 | return 0; |
| 127 | } |
| 128 | #include <finsh.h> |
| 129 | FINSH_FUNCTION_EXPORT(libc_mq, posix mqueue test); |
nothing calls this directly
no test coverage detected