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 * Error condition API test of the clock_gettime() function. 9 * Test calling clock_gettime() with the following values: 10 * - Boundary values for integers (TBD if clock_id is an integer) 11 * MIN INT = INT32_MIN 12 * MAX INT = INT32_MAX 13 * MIN INT - 1 = 2147483647 (this is what gcc will set to) 14 * MAX INT + 1 = -2147483647 (this is what gcc will set to) 15 * unassigned value = -1073743192 (ex. of what gcc will set to) 16 * unassigned value = 1073743192 (ex. of what gcc will set to) 17 * -1 18 * 17 (currently not = to any clock) 19 */ 20 #include <stdio.h> 21 #include <time.h> 22 #include <errno.h> 23 #include <stdint.h> 24 #include "posixtest.h" 25 26 #define NUMINVALIDTESTS 8 27 28 static int invalid_tests[NUMINVALIDTESTS] = { 29 INT32_MIN, INT32_MAX, 2147483647, -2147483647, -1073743192, 30 1073743192, -1, 17 31 }; 32 33 int main(void) 34 { 35 struct timespec tp; 36 int i; 37 int failure = 0; 38 39 for (i = 0; i < NUMINVALIDTESTS; i++) { 40 if (clock_gettime(invalid_tests[i], &tp) == 0) { 41 printf("failure: clock_gettime() using %d succeeded\n", 42 invalid_tests[i]); 43 failure = 1; 44 } else { 45 if (EINVAL != errno) { 46 printf("errno not correctly set\n"); 47 failure = 1; 48 } 49 } 50 } 51 52 if (failure) { 53 printf("At least one test FAILED -- see above\n"); 54 return PTS_FAIL; 55 } 56 57 printf("Test PASSED\n"); 58 return PTS_PASS; 59 } 60