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 if the queue already has room, then mq_timedsend() 11 * does not need to check abs_timeout for validity. 12 * 13 * This is a speculative test because if abs_timeout _is_ checked for 14 * validity, it is not a failure. 15 */ 16 17#include <stdio.h> 18#include <mqueue.h> 19#include <fcntl.h> 20#include <sys/stat.h> 21#include <sys/types.h> 22#include <unistd.h> 23#include <string.h> 24#include <time.h> 25#include "posixtest.h" 26 27#define NAMESIZE 50 28#define MSGSTR "0123456789" 29 30int main() 31{ 32 char qname[NAMESIZE]; 33 const char *msgptr = MSGSTR; 34 struct timespec ts; 35 mqd_t queue; 36 37 sprintf(qname, "/msgqueue_%d", getpid()); 38 39 queue = mq_open(qname, O_CREAT |O_RDWR, S_IRUSR | S_IWUSR, NULL); 40 if (queue == (mqd_t)-1) { 41 perror("mq_open() did not return success"); 42 printf("Test UNRESOLVED\n"); 43 return PTS_UNRESOLVED; 44 } 45 46 ts.tv_sec=time(NULL)-1; 47 ts.tv_nsec=-1; 48 if (mq_timedsend(queue, msgptr, strlen(msgptr), 1, &ts) == -1) { 49 printf("mq_timedsend() did fail on invalid abs_time\n"); 50 mq_close(queue); 51 mq_unlink(qname); 52 return PTS_PASS; 53 } 54 55 mq_close(queue); 56 mq_unlink(qname); 57 58 printf("mq_timedsend() did not fail on invalid abs_time\n"); 59 return PTS_PASS; 60} 61 62