2 * Copyright (c) 2003, Intel Corporation. All rights reserved.
3 * Created by: crystal.xiong 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
10 * mq_timedreceive test plan:
11 * If message can be removed from message queue immediately, the validity
12 * of timout need not be checked.
14 * This is a speculative test because if abs_timeout _is_ checked for
15 * validity, it is not a failure.
22 #include <sys/types.h>
26 #include "posixtest.h"
29 #define FUNCTION "mq_timedreceive"
30 #define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "
37 char mqname[NAMESIZE], msgrv[BUFFER];
38 const char *msgptr = "test message";
40 unsigned rvprio, sdprio = 1;
45 sprintf(mqname, "/" FUNCTION "_" TEST "_%d", getpid());
47 attr.mq_msgsize = BUFFER;
48 attr.mq_maxmsg = BUFFER;
49 mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
50 if (mqdes == (mqd_t)-1) {
51 perror(ERROR_PREFIX "mq_open");
55 if (mq_send(mqdes, msgptr, strlen(msgptr), sdprio) != 0) {
56 perror(ERROR_PREFIX "mq_send");
60 ts.tv_sec = time(NULL) + 1;
62 if (mq_timedreceive(mqdes, msgrv, BUFFER, &rvprio, &ts) == -1) {
63 printf("mq_timedreceive() did fail on invalid abs_time\n");
66 printf("mq_timedreceive() did not fail on invalid abs_time\n");
69 if (mq_close(mqdes) != 0) {
70 perror(ERROR_PREFIX "mq_close");
74 if (mq_unlink(mqname) != 0) {
75 perror(ERROR_PREFIX "mq_unlink");
80 printf("Test UNRESOLVED\n");
81 return PTS_UNRESOLVED;
84 printf("Test PASSED\n");