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_setprotocol() 9 * 10 * It may fail if: 11 * [EINVAL] The value specified by 'attr' is invalid. 12 * 13 * Steps: 14 * 1. Call pthread_mutexattr_setprotocol with an uninitialized pthread_mutexattr_t object. 15 */ 16 17 #include <pthread.h> 18 #include <stdio.h> 19 #include <sched.h> 20 #include <errno.h> 21 #include "posixtest.h" 22 23 int main(void) 24 { 25 26 pthread_mutexattr_t mta; 27 int ret; 28 29 /* Set the protocol to an invalid value. */ 30 ret = pthread_mutexattr_setprotocol(&mta, PTHREAD_PRIO_NONE); 31 if (ret == EINVAL) { 32 printf("Test PASSED\n"); 33 return PTS_PASS; 34 } else if (ret == 0) { 35 printf 36 ("Test PASSED: NOTE*: Expected error code EINVAL, got %d, though standard states 'may' fail.\n", 37 ret); 38 return PTS_PASS; 39 } else { 40 printf 41 ("Test FAILED: Incorrect return code %d. Expected EINVAL or 0.\n", 42 ret); 43 return PTS_FAIL; 44 } 45 } 46