1 /* 2 * Copyright (c) 2003, Intel Corporation. All rights reserved. 3 * Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com 4 * This file is licensed under the GPL license. For the full content 5 * of this license, see the COPYING file at the top level of this 6 * source tree. 7 */ 8 9 /* 10 * Basic test that O_NONBLOCK can be set. The functionality of O_NONBLOCK 11 * is tested in the mq_send and mq_receive test cases. 12 */ 13 14 #include <stdio.h> 15 #include <mqueue.h> 16 #include <fcntl.h> 17 #include <sys/stat.h> 18 #include <sys/types.h> 19 #include <unistd.h> 20 #include <string.h> 21 #include "posixtest.h" 22 23 #define NAMESIZE 50 24 #define MSGSTR "O123456789" 25 26 int main(void) 27 { 28 char qname[NAMESIZE]; 29 const char *msgptr = MSGSTR; 30 mqd_t queue; 31 32 sprintf(qname, "/mq_open_18-1_%d", getpid()); 33 34 queue = mq_open(qname, O_CREAT | O_RDWR | O_NONBLOCK, 35 S_IRUSR | S_IWUSR, NULL); 36 if (queue == (mqd_t) - 1) { 37 perror("mq_open() did not return success w/O_NONBLOCK set"); 38 printf("Test FAILED\n"); 39 return PTS_FAIL; 40 } 41 42 if (mq_send(queue, msgptr, strlen(msgptr), 1) != 0) { 43 perror("mq_send() did not return success"); 44 printf("Test FAILED\n"); 45 /* close queue and exit */ 46 mq_close(queue); 47 mq_unlink(qname); 48 return PTS_FAIL; 49 } 50 51 mq_close(queue); 52 mq_unlink(qname); 53 54 printf("Test PASSED\n"); 55 return PTS_PASS; 56 } 57