Home | History | Annotate | Download | only in mq_open
      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  * Test that if mq_open() is not successful, it will return (mqd_t)-1
     11  * and set errno to indicate the error.
     12  *
     13  * Error case used is when O_CREAT is not set and the named message
     14  * queue does not exist.
     15  * Test that errno is set will be part of assertion 29.
     16  */
     17 
     18 #include <stdio.h>
     19 #include <mqueue.h>
     20 #include <fcntl.h>
     21 #include <sys/stat.h>
     22 #include <sys/types.h>
     23 #include <unistd.h>
     24 #include <string.h>
     25 #include "posixtest.h"
     26 
     27 #define NAMESIZE 50
     28 
     29 int main(void)
     30 {
     31 	char qname[NAMESIZE];
     32 	mqd_t queue;
     33 
     34 	sprintf(qname, "/mq_open_21-1_%d", getpid());
     35 
     36 	queue = mq_open(qname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
     37 	if (queue != (mqd_t) - 1) {
     38 		printf("mq_open() did not return (mqd_t)-1 on error\n");
     39 		mq_close(queue);
     40 		mq_unlink(qname);
     41 		return PTS_FAIL;
     42 	}
     43 
     44 	printf("Test PASSED\n");
     45 	return PTS_PASS;
     46 }
     47