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 Shall fail if: 11 * [ENOTSUP] The value specified by protocol is an unsupported value. 12 * It may fail if: 13 * [EINVAL] 'protocol' is invalid 14 */ 15 16#include <pthread.h> 17#include <stdio.h> 18#include <sched.h> 19#include <errno.h> 20#include "posixtest.h" 21 22#define INVALID_PROTOCOL -1 23 24int main() 25{ 26 27 pthread_mutexattr_t mta; 28 int protocol = INVALID_PROTOCOL; 29 30 int ret; 31 32 /* Initialize a mutex attributes object */ 33 if(pthread_mutexattr_init(&mta) != 0) 34 { 35 perror("Error at pthread_mutexattr_init()\n"); 36 return PTS_UNRESOLVED; 37 } 38 39 while(protocol == PTHREAD_PRIO_NONE || protocol == PTHREAD_PRIO_INHERIT 40 || protocol == PTHREAD_PRIO_PROTECT){ 41 protocol--; 42 } 43 44 /* Set the protocol to an invalid value. */ 45 ret = pthread_mutexattr_setprotocol(&mta,protocol); 46 if((ret == ENOTSUP) || (ret == EINVAL)) 47 { 48 printf("Test PASSED\n"); 49 return PTS_PASS; 50 } else{ 51 52 printf("Test FAILED: Expected error code ENOTSUP, got %d.\n", ret); 53 return PTS_FAIL; 54 } 55} 56