commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r805529 - in /commons/sandbox/runtime/trunk/src: main/native/os/unix/pmutex.c main/native/test/testcase.c test/org/apache/commons/runtime/TestPrivate.java
Date Tue, 18 Aug 2009 18:35:04 GMT
Author: mturk
Date: Tue Aug 18 18:35:04 2009
New Revision: 805529

URL: http://svn.apache.org/viewvc?rev=805529&view=rev
Log:
Fix mutex close and add test case. That's why we have them

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
    commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c?rev=805529&r1=805528&r2=805529&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c Tue Aug 18 18:35:04 2009
@@ -40,7 +40,7 @@
 
 static int mutex_cleanup(void *mutex, int type, unsigned int flags)
 {
-    if (type != ACR_DT_MUTEX) {
+    if (type == ACR_DT_MUTEX) {
         acr_pmutex_t *m = (acr_pmutex_t *)mutex;
         if (m->filedes > 0) {
             union semun ick;
@@ -98,7 +98,7 @@
 }
 
 ACR_DECLARE(int) ACR_ProcMutexAttach(JNIEnv *_E, const acr_pchar_t *fname)
-{    
+{
     ACR_SET_OS_ERROR(ACR_ENOTIMPL);
     return -1;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=805529&r1=805528&r2=805529&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Tue Aug 18 18:35:04 2009
@@ -29,6 +29,7 @@
 #include "acr_file.h"
 #include "acr_xdr.h"
 #include "acr_shm.h"
+#include "acr_procmutex.h"
 
 #if defined (WIN32)
 #include <io.h>
@@ -728,3 +729,44 @@
 }
 
 #endif
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test071)(ACR_JNISTDARGS, jint d)
+{
+
+    return ACR_ProcMutexCreate(_E, NULL);
+}
+
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test072)(ACR_JNISTDARGS, jint d)
+{
+
+    return ACR_ProcMutexCreate(_E, shr_name);
+}
+
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test073)(ACR_JNISTDARGS, jint m)
+{
+    return ACR_ProcMutexClose(_E, m);
+}
+
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test074)(ACR_JNISTDARGS, jint d)
+{
+#if defined(WIN32)
+    return ACR_ProcMutexAttach(_E, shr_name);
+#else
+    return 0;
+#endif
+}
+
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test075)(ACR_JNISTDARGS, jint m)
+{
+    return ACR_ProcMutexLock(_E, m);
+}
+
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test076)(ACR_JNISTDARGS, jint m)
+{
+    return ACR_ProcMutexTryLock(_E, m);
+}
+
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test077)(ACR_JNISTDARGS, jint m)
+{
+    return ACR_ProcMutexRelease(_E, m);
+}
+

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java?rev=805529&r1=805528&r2=805529&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java Tue
Aug 18 18:35:04 2009
@@ -115,6 +115,13 @@
 
     private static native String test100(String s);
 
+    private static native int      test071(int l);
+    private static native int      test072(int l);
+    private static native int      test073(int d);
+    private static native int      test074(int l);
+    private static native int      test075(int s);
+    private static native int      test076(int s);
+    private static native int      test077(int s);
 
     protected void setUp()
         throws Exception
@@ -959,5 +966,33 @@
 
     }
 
+    public void testPmutexCreateAnon()
+        throws Throwable
+    {
+        int sa = test071(0);
+        assertTrue("Anon Process Mutex", sa > 0);
+
+        int rv = test073(sa);
+        assertEquals("Destroy Anon Process Mutex", 0, rv);
+    }
+
+    public void testPmutexCreate()
+        throws Throwable
+    {
+        int sa = test072(0);
+        assertTrue("Named Process Mutex", sa > 0);
+
+        try {
+            // Second invocation must throw exists.
+            int sb = test072(0);
+            fail("Exception not thrown");
+        } catch (Throwable e) {
+            // Ignore
+        }
+        int rv = test073(sa);
+        assertEquals("Destroy Named Process Mutex", 0, rv);
+    }
+
+
 }
 



Mime
View raw message