changeset 15974:3a537502f40f

HSAIL: prevent failure to loaded native Okra library from causing unit test failure Contributed-by: Eric Caspole <eric.caspole@amd.com>
author Doug Simon <doug.simon@oracle.com>
date Thu, 29 May 2014 16:12:12 +0200
parents b048110014ff
children 0ad889977080
files graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java
diffstat 2 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java	Wed May 28 20:36:10 2014 -0700
+++ b/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java	Thu May 29 16:12:12 2014 +0200
@@ -190,7 +190,7 @@
     @Override
     public void testGeneratedHsail() {
         try (OverrideScope s = getOverrideScope()) {
-            assumeTrue(supportsRequiredCapabilities());
+            assumeTrue(supportsRequiredCapabilities() && okraEnvIsInitialized());
             super.testGeneratedHsail();
         }
     }
@@ -198,7 +198,7 @@
     @Override
     public void testGeneratedHsailUsingLambdaMethod() {
         try (OverrideScope s = getOverrideScope()) {
-            assumeTrue(supportsRequiredCapabilities());
+            assumeTrue(supportsRequiredCapabilities() && okraEnvIsInitialized());
             super.testGeneratedHsailUsingLambdaMethod();
         }
     }
--- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java	Wed May 28 20:36:10 2014 -0700
+++ b/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java	Thu May 29 16:12:12 2014 +0200
@@ -121,10 +121,27 @@
         return onSimulator;
     }
 
+    public boolean okraEnvIsInitialized() {
+        return this.okraLibExists;
+    }
+
     public KernelTester(boolean okraLibExists) {
         dispatchMode = DispatchMode.SEQ;
         hsailMode = HsailMode.COMPILED;
         useLambdaMethod = false;
+
+        if (okraLibExists == false) {
+            // The okra native lib is not loaded yet, try to load the OkraContext
+            // explicitly and report a more useful error if there is a problem
+            try {
+                Class.forName("OkraContext");
+            } catch (Exception e) {
+                logger.info("Okra native library cannot be found or loaded while running" + this.getClass().getSimpleName());
+                this.okraLibExists = false;
+                return;
+            }
+        }
+
         // Control which okra instances can run the tests (is Simulator is static).
         onSimulator = OkraContext.isSimulator();
         this.okraLibExists = okraLibExists;