[haiku-commits] r36294 - haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_cond_timedwait

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 15 Apr 2010 16:20:02 +0200 (CEST)

Author: bonefish
Date: 2010-04-15 16:20:02 +0200 (Thu, 15 Apr 2010)
New Revision: 36294
Changeset: http://dev.haiku-os.org/changeset/36294/haiku

Modified:
   
haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_cond_timedwait/2-3.c
Log:
* Fixed incorrect check: The behavior of pthread_mutex_unlock() is undefined
  when called with a default-type mutex owned by another thread.
* Automatic whitespace cleanup.


Modified: 
haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_cond_timedwait/2-3.c
===================================================================
--- 
haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_cond_timedwait/2-3.c
       2010-04-15 13:54:15 UTC (rev 36293)
+++ 
haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_cond_timedwait/2-3.c
       2010-04-15 14:20:02 UTC (rev 36294)
@@ -2,16 +2,16 @@
  * Copyright (c) 2002, Intel Corporation. All rights reserved.
  * Created by:  bing.wei.liu REMOVE-THIS AT intel DOT com
  * This file is licensed under the GPL license.  For the full content
- * of this license, see the COPYING file at the top level of this 
+ * of this license, see the COPYING file at the top level of this
  * source tree.
 
  * Test that pthread_cond_timedwait()
- *   shall be equivalent to pthread_cond_wait(), except that an error is 
returned 
+ *   shall be equivalent to pthread_cond_wait(), except that an error is 
returned
  *   if the absolute time specified by abstime has already been passed at the 
time
  *   of the call.
- * 
+ *
  */
- 
+
 #define _XOPEN_SOURCE 600
 
 #include <pthread.h>
@@ -37,14 +37,14 @@
        int rc;
        struct timeval  curtime;
        struct timespec timeout;
-       
+
        if (pthread_mutex_lock(&td.mutex) != 0) {
                fprintf(stderr,"Thread1 failed to acquire the mutex\n");
                exit(PTS_UNRESOLVED);
        }
        fprintf(stderr,"Thread1 started\n");
        t1_start = 1;   /* let main thread continue */
-       
+
        if (gettimeofday(&curtime, NULL) !=0 ) {
                fprintf(stderr,"Fail to get current time\n");
                exit(PTS_UNRESOLVED);
@@ -85,7 +85,7 @@
                return PTS_UNRESOLVED;
        }
 
-       /* If the thread hasn't ended in 5 seconds, then most probably 
+       /* If the thread hasn't ended in 5 seconds, then most probably
         * pthread_cond_timedwait is failing to function correctly. */
        alarm(5);
 
@@ -96,29 +96,24 @@
                return PTS_UNRESOLVED;
        }
 
-       /* Make sure pthread_cond_timedwait released and re-acquired the mutex 
+       /* Make sure pthread_cond_timedwait released and re-acquired the mutex
         * as it should. */
        rc=pthread_mutex_trylock(&td.mutex);
-       if (rc == 0) {  
+       if (rc == 0) {
                fprintf(stderr,"Test FAILED: Did not re-acquire mutex after 
timedout out call to pthread_cond_timedwait\n");
                return PTS_FAIL;
        }
 
-       if (pthread_mutex_unlock(&td.mutex) != 0) {
-               fprintf(stderr,"Main failed to release mutex\n");
-               return PTS_UNRESOLVED;
-       }
-
        if(th_ret == PTS_PASS)
        {
-               printf("Test PASSED\n"); 
+               printf("Test PASSED\n");
                return PTS_PASS;
        }
        else if(th_ret == PTS_FAIL)
        {
-               printf("Test FAILED\n"); 
+               printf("Test FAILED\n");
                return PTS_FAIL;
        } else
-               return PTS_UNRESOLVED;  
+               return PTS_UNRESOLVED;
 }
 


Other related posts:

  • » [haiku-commits] r36294 - haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_cond_timedwait - ingo_weinhold