db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1061988 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/store/InterruptResilienceTest.java junit/BaseTestCase.java
Date Fri, 21 Jan 2011 19:59:29 GMT
Author: dag
Date: Fri Jan 21 19:59:29 2011
New Revision: 1061988

URL: http://svn.apache.org/viewvc?rev=1061988&view=rev
Log:
DERBY-4974 InterruptResilienceTest fails on Solaris with Sun VMs prior to 1.6

Patch DERBY-4974, which:

a) skips the tests in InterruptResilienceTest if running with
interruptible IO on Solaris

b) improves the check for interruptible IO to work even if
system/derby.log doesn't yet exist (which would be the case if the
test is run stand-alone).


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java?rev=1061988&r1=1061987&r2=1061988&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java
Fri Jan 21 19:59:29 2011
@@ -74,6 +74,13 @@ public class InterruptResilienceTest ext
             return suite;
         }
 
+        if (hasInterruptibleIO()) {
+            println("Test skipped due to interruptible IO.");
+            println("This is default on Solaris/Sun Java <= 1.6, use " +
+                    "-XX:-UseVMInterruptibleIO if available.");
+            return suite;
+        }
+
         suite.addTest(
             baseSuite("InterruptResilienceTest:embedded"));
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1061988&r1=1061987&r2=1061988&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Fri Jan
21 19:59:29 2011
@@ -601,9 +601,7 @@ public abstract class BaseTestCase
      *
      * @return true if we have old style interruptible IO
      */
-    public static final boolean hasInterruptibleIO()
-            throws Exception {
-
+    public static final boolean hasInterruptibleIO() {
 
         boolean interruptibleIO = false;
 
@@ -617,14 +615,20 @@ public abstract class BaseTestCase
 
                         String sysHome = getSystemProperty("derby.system.home");
 
-                        StringBuffer arbitraryRAFFileName = new StringBuffer();
+                        StringBuffer arbitraryRAFFileNameB = new StringBuffer();
 
-                        arbitraryRAFFileName.append(sysHome);
-                        arbitraryRAFFileName.append(File.separatorChar);
-                        arbitraryRAFFileName.append("derby.log");
+                        arbitraryRAFFileNameB.append(sysHome);
+                        arbitraryRAFFileNameB.append(File.separatorChar);
+                        arbitraryRAFFileNameB.append("derby.log");
+
+                        String arbitraryRAFFileName =
+                            arbitraryRAFFileNameB.toString();
+                        // Create if it does not exist:
+                        new File(sysHome).mkdirs(); // e.g. "system"
+                        new File(arbitraryRAFFileName).createNewFile();
 
                         RandomAccessFile f = new RandomAccessFile(
-                            arbitraryRAFFileName.toString(), "r");
+                            arbitraryRAFFileName, "r");
 
                         try {
                             Thread.currentThread().interrupt();
@@ -640,9 +644,14 @@ public abstract class BaseTestCase
             if (e.getCause() instanceof InterruptedIOException) {
                 interruptibleIO = true;
             } else {
-                throw e;
+                // Better to assume nothing when the test fails. Then, tests
+                // will not be skipped and we would not miss that something is
+                // amiss.
+                println("Could not test for interruptible IO," +
+                        " so assuming we don't have it: " + e);
+                e.getCause().printStackTrace();
+                return false;
             }
-
         }
 
         return interruptibleIO;



Mime
View raw message