1/* 2 * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 * This file is licensed under the GPL license. For the full content 4 * of this license, see the COPYING file at the top level of this 5 * source tree. 6 7 * Test pthread_spin_trylock(pthread_spinlock_t *lock) 8 * 9 * Note: This case will always pass 10 * 11 * These functions may fail if: 12 * [EINVAL] The value specified by lock does not refer to an initialized spin lock object. 13 * 14 */ 15 16#define _XOPEN_SOURCE 600 17#include <pthread.h> 18#include <stdio.h> 19#include <stdlib.h> 20#include <unistd.h> 21#include <signal.h> 22#include <errno.h> 23#include <string.h> 24#include "posixtest.h" 25 26 27int main() 28{ 29 30 pthread_spinlock_t spinlock; 31 int rc; 32 33 /* attemp to lock an uninitalized spin lock */ 34 35 rc = pthread_spin_trylock(&spinlock); 36 if(rc == EINVAL) 37 { 38 printf("Correctly got EINVAL at pthread_spin_trylock()\n"); 39 printf("Test PASSED\n"); 40 } 41 else 42 { 43 printf("Expected EINVAL, but get return code: %d,%s\n", rc, strerror(rc)); 44 printf("Test PASSED: *Note: Returned incorrect value, but standard says 'may' fail\n"); 45 } 46 47 return PTS_PASS; 48} 49