1 /* 2 * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 * Created by: bing.wei.liu 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 pthread_mutexattr_setprioceiling() 9 * 10 * It MAY fail if: 11 * 12 * [EINVAL] - 'attr' or 'prioceiling' is invalid. 13 * [EPERM] - The caller doesn't have the privilege to perform the operation. 14 * 15 * Steps: 16 * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init() 17 * 2. Call pthread_mutexattr_setprioceiling() to set the prioceiling. 18 * 19 */ 20 21 #include <pthread.h> 22 #include <stdio.h> 23 #include <sched.h> 24 #include <errno.h> 25 #include "posixtest.h" 26 27 int main(void) 28 { 29 30 /* Make sure there is prioceiling capability. */ 31 /* #ifndef _POSIX_PRIORITY_SCHEDULING 32 fprintf(stderr,"prioceiling attribute is not available for testing\n"); 33 return PTS_UNRESOLVED; 34 #endif */ 35 36 pthread_mutexattr_t mta; 37 int prioceiling, ret; 38 39 prioceiling = sched_get_priority_min(SCHED_FIFO); 40 41 /* Set the prioceiling of an unintialized mutex attr. */ 42 if ((ret = pthread_mutexattr_setprioceiling(&mta, prioceiling)) == 0) { 43 printf 44 ("Test PASSED: *Note: Returned 0 instead of EINVAL when passed an uninitialized mutex attribute object to pthread_mutexattr_setprioceiling, but standard says 'may' fail.\n"); 45 return PTS_PASS; 46 } 47 48 if (ret != EINVAL) { 49 printf 50 ("Test FAILED: Invalid return code %d. Expected EINVAL or 0.\n", 51 ret); 52 return PTS_FAIL; 53 } 54 55 printf("Test PASSED\n"); 56 return PTS_PASS; 57 } 58