Home | History | Annotate | Download | only in pthread_mutexattr_getprioceiling
      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_getprioceiling()
      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  * This function shall not return an error code of [EINTR]
     16  *
     17  * Steps:
     18  * 1.  Call pthread_mutexattr_getprioceiling() to obtain the prioceiling for an
     19  *     uninitialized pthread_mutexattr_t object.
     20  *
     21  */
     22 
     23 #include <pthread.h>
     24 #include <stdio.h>
     25 #include <sched.h>
     26 #include <errno.h>
     27 #include "posixtest.h"
     28 
     29 int main(void)
     30 {
     31 
     32 	int prioceiling, ret;
     33 	pthread_mutexattr_t mta;
     34 
     35 	/* Get the prioceiling of an unintialized mutex attr. */
     36 	if ((ret = pthread_mutexattr_getprioceiling(&mta, &prioceiling)) == 0) {
     37 		printf
     38 		    ("Test PASSED: *Note: Returned 0 instead of EINVAL when passed an uninitialized mutex attribute object to pthread_mutexattr_getprioceiling, but standard says 'may' fail.\n");
     39 		return PTS_PASS;
     40 
     41 	} else if (ret != EINVAL) {
     42 		printf
     43 		    ("Test FAILED: Invalid return code %d. Expected EINVAL or 0.\n",
     44 		     ret);
     45 		return PTS_FAIL;
     46 	}
     47 
     48 	printf("Test PASSED\n");
     49 	return PTS_PASS;
     50 }
     51