1/*
2 * Copyright (c) 2003, Intel Corporation. All rights reserved.
3 * Created by:  majid.awad 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 * The process would be blocked, and the timeout parameter is
11 * secified in nanoseconds field value less than zero.  Should
12 * return ERROR (EINVAL).
13 */
14
15#define _XOPEN_SOURCE 600
16
17#include <stdio.h>
18#include <errno.h>
19#include <unistd.h>
20#include <semaphore.h>
21#include <sys/stat.h>
22#include <fcntl.h>
23#include <time.h>
24#include "posixtest.h"
25
26
27#define TEST "6-1"
28#define FUNCTION "sem_timedwait"
29#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "
30
31
32
33int main() {
34	sem_t mysemp;
35	struct timespec ts;
36	int sts;
37
38        if ( sem_init (&mysemp, 0, 0) == -1 ) {
39                perror(ERROR_PREFIX "sem_init");
40                return PTS_UNRESOLVED;
41        }
42	ts.tv_sec=time(NULL);
43        ts.tv_nsec= -3;
44
45	sts = sem_timedwait(&mysemp, &ts);
46
47	if((errno == EINVAL) && ( sts == -1)) {
48		puts("TEST PASSED");
49		sem_destroy(&mysemp);
50		return PTS_PASS;
51	} else {
52		puts("TEST FAILED");
53		return PTS_FAIL;
54	}
55}
56