Home | History | Annotate | Download | only in nanosleep
      1 /*
      2  * Copyright (c) 2002, 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  * Test that nanosleep() returns -1 on failure.
      9  * Simulate failure condition by sending -1 as the nsec to sleep for.
     10  */
     11 #include <stdio.h>
     12 #include <time.h>
     13 #include "posixtest.h"
     14 
     15 int main(void)
     16 {
     17 	struct timespec tssleepfor, tsstorage;
     18 	int sleepnsec = -1;
     19 
     20 	tssleepfor.tv_sec = 0;
     21 	tssleepfor.tv_nsec = sleepnsec;
     22 	if (nanosleep(&tssleepfor, &tsstorage) == -1) {
     23 		printf("Test PASSED\n");
     24 		return PTS_PASS;
     25 	}
     26 
     27 	printf("nanosleep() did not return -1 on failure\n");
     28 	return PTS_FAIL;
     29 }
     30