Home | History | Annotate | Download | only in pthread_equal
      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 a thread
     15  * 2.  Call pthread_equal and pass to it the new thread in both parameters.
     16  *     They should both be equal.
     17  *
     18  */
     19 
     20 #include <pthread.h>
     21 #include <stdio.h>
     22 #include "posixtest.h"
     23 
     24 void *a_thread_func()
     25 {
     26 
     27 	pthread_exit(0);
     28 	return NULL;
     29 }
     30 
     31 int main(void)
     32 {
     33 	pthread_t new_th;
     34 
     35 	/* Create a new thread. */
     36 	if (pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) {
     37 		perror("Error creating thread\n");
     38 		return PTS_UNRESOLVED;
     39 	}
     40 
     41 	/* Call pthread_equal() and pass to it the new thread ID in both
     42 	 * parameters.  It should return a non-zero value, indicating that
     43 	 * they are equal. */
     44 	if (pthread_equal(new_th, new_th) == 0) {
     45 		printf("Test FAILED\n");
     46 		return PTS_FAIL;
     47 	} else {
     48 		printf("Test PASSED\n");
     49 		return PTS_PASS;
     50 	}
     51 
     52 }
     53