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 * The function shall destroy the read-write lock object referenced by rwlock 8 * and release any resources used by the lock. 9 * 10 * Note: This case does not test the resources used by the lock has been released. 11 *Steps: 12 * Loop for COUNT times: 13 * 1. Initialize a read-write lock 14 * 2. Destroy it. Should get not error. 15 */ 16 17 #define _XOPEN_SOURCE 600 18 #include <pthread.h> 19 #include <stdio.h> 20 #include "posixtest.h" 21 22 #define COUNT 1000 23 24 int main(void) 25 { 26 pthread_rwlock_t rwlock; 27 int cnt = 0; 28 int rc = 0; 29 30 while (cnt++ < COUNT) { 31 if (pthread_rwlock_init(&rwlock, NULL) != 0) { 32 printf("Error at pthread_rwlock_init()\n"); 33 return PTS_UNRESOLVED; 34 } 35 36 rc = pthread_rwlock_destroy(&rwlock); 37 if (rc != 0) { 38 printf 39 ("Test FAILED: at %d-th pthread_rwlock_destroy(), with Error code=%d\n", 40 cnt, rc); 41 return PTS_FAIL; 42 } 43 } 44 45 printf("Test PASSED\n"); 46 return PTS_PASS; 47 } 48