1/* 2 * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 * Created by: rolla.n.selbak 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_equal() 9 * shall compare the thread ids t1 and t2. The function shall return a non-zero 10 * value if t1 and t2 are equal, othersise zero shall be returned. 11 * No errors are defined. 12 * 13 * Steps: 14 * 1. Create 2 threads 15 * 2. Call pthread_equal and pass to it the two threads. 16 * They should not be equal. 17 * 18 */ 19 20#include <pthread.h> 21#include <stdio.h> 22#include "posixtest.h" 23 24 25void *a_thread_func() 26{ 27 28 pthread_exit(0); 29 return NULL; 30} 31 32int main() 33{ 34 pthread_t new_th1, new_th2; 35 36 /* Create a new thread. */ 37 if(pthread_create(&new_th1, NULL, a_thread_func, NULL) != 0) 38 { 39 perror("Error creating thread\n"); 40 return PTS_UNRESOLVED; 41 } 42 43 /* Create another new thread. */ 44 if(pthread_create(&new_th2, NULL, a_thread_func, NULL) != 0) 45 { 46 perror("Error creating thread\n"); 47 return PTS_UNRESOLVED; 48 } 49 50 /* Call pthread_equal() and pass to it the 2 new threads. 51 * It should return a zero value, indicating that 52 * they are not equal. */ 53 if(pthread_equal(new_th1, new_th2) != 0) 54 { 55 printf("Test FAILED\n"); 56 return PTS_FAIL; 57 } 58 else 59 { 60 printf("Test PASSED\n"); 61 return PTS_PASS; 62 } 63 64} 65 66 67