diff options
author | Wade Walker <[email protected]> | 2014-02-23 18:23:57 -0600 |
---|---|---|
committer | Wade Walker <[email protected]> | 2014-02-23 18:23:57 -0600 |
commit | 54ced2cf5d801470c106275291be17583e5e206d (patch) | |
tree | 3983673d769c898b515c46adf5f058af218b7710 /test | |
parent | 10f9ddfad21c8ab1d4287742d1b524ae11e916c8 (diff) |
Fix OpenCL test failures on Solaris.
Since nobody currently makes an OpenCL driver for Solaris, all the
tests used to fail, which told us nothing. This commit adds code
to check whether OpenCL is unavailable and the OS is Solaris, in
which case the test contents are skipped. If an OpenCL driver ever
appears for Solaris, or if we start testing on another platform
with no OpenCL driver, there's now one single place to add or remove
checks that will allow for this.
Diffstat (limited to 'test')
-rw-r--r-- | test/com/jogamp/opencl/CLBufferTest.java | 13 | ||||
-rw-r--r-- | test/com/jogamp/opencl/CLCommandQueueTest.java | 13 | ||||
-rw-r--r-- | test/com/jogamp/opencl/CLImageTest.java | 10 | ||||
-rw-r--r-- | test/com/jogamp/opencl/CLProgramTest.java | 13 | ||||
-rw-r--r-- | test/com/jogamp/opencl/HighLevelBindingTest.java | 10 | ||||
-rw-r--r-- | test/com/jogamp/opencl/LowLevelBindingTest.java | 7 | ||||
-rw-r--r-- | test/com/jogamp/opencl/gl/CLGLTest.java | 9 | ||||
-rw-r--r-- | test/com/jogamp/opencl/test/util/MiscUtils.java | 15 | ||||
-rw-r--r-- | test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java | 7 |
9 files changed, 95 insertions, 2 deletions
diff --git a/test/com/jogamp/opencl/CLBufferTest.java b/test/com/jogamp/opencl/CLBufferTest.java index 0638844d..3ac1fffe 100644 --- a/test/com/jogamp/opencl/CLBufferTest.java +++ b/test/com/jogamp/opencl/CLBufferTest.java @@ -30,6 +30,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.CLMemory.Mem; import com.jogamp.opencl.CLMemory.Map; +import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; import com.jogamp.common.nio.Buffers; @@ -66,6 +67,8 @@ public class CLBufferTest extends UITestCase { public void createBufferTest() { out.println(" - - - highLevelTest; create buffer test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLContext context = CLContext.create(); try{ @@ -121,6 +124,8 @@ public class CLBufferTest extends UITestCase { public void writeCopyReadBufferTest() { out.println(" - - - highLevelTest; copy buffer test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; final int elements = NUM_ELEMENTS; @@ -153,6 +158,8 @@ public class CLBufferTest extends UITestCase { public void bufferWithHostPointerTest() { out.println(" - - - highLevelTest; host pointer test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; final int elements = NUM_ELEMENTS; @@ -197,6 +204,8 @@ public class CLBufferTest extends UITestCase { public void mapBufferTest() { out.println(" - - - highLevelTest; map buffer test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; final int elements = NUM_ELEMENTS; final int sizeInBytes = elements*SIZEOF_INT; @@ -250,6 +259,8 @@ public class CLBufferTest extends UITestCase { public void subBufferTest() { out.println(" - - - subBufferTest - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLPlatform platform = CLPlatform.getDefault(version(CL_1_1)); if(platform == null) { @@ -313,6 +324,8 @@ public class CLBufferTest extends UITestCase { public void destructorCallbackTest() throws InterruptedException { out.println(" - - - destructorCallbackTest - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLPlatform platform = CLPlatform.getDefault(version(CL_1_1)); if(platform == null) { diff --git a/test/com/jogamp/opencl/CLCommandQueueTest.java b/test/com/jogamp/opencl/CLCommandQueueTest.java index c9b1b567..76260289 100644 --- a/test/com/jogamp/opencl/CLCommandQueueTest.java +++ b/test/com/jogamp/opencl/CLCommandQueueTest.java @@ -35,6 +35,7 @@ import org.junit.runners.MethodSorters; import java.util.concurrent.CountDownLatch; +import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; import com.jogamp.opencl.util.MultiQueueBarrier; import com.jogamp.opencl.CLCommandQueue.Mode; @@ -101,6 +102,8 @@ public class CLCommandQueueTest extends UITestCase { public void eventsTest() throws IOException { out.println(" - - - event synchronization test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLContext context = CLContext.create(); @@ -171,6 +174,8 @@ public class CLCommandQueueTest extends UITestCase { public void eventConditionsTest() throws IOException { out.println(" - - - event conditions test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLPlatform platform = CLPlatform.getDefault(CLPlatformFilters.queueMode(OUT_OF_ORDER_MODE)); @@ -231,6 +236,8 @@ public class CLCommandQueueTest extends UITestCase { public void profilingEventsTest() throws IOException { out.println(" - - - event synchronization test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLContext context = CLContext.create(); @@ -286,6 +293,8 @@ public class CLCommandQueueTest extends UITestCase { @Test public void customEventsTest() throws IOException, InterruptedException { out.println(" - - - user events test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLPlatform[] platforms = CLPlatform.listCLPlatforms(); CLPlatform theChosenOne = platforms[0]; @@ -362,6 +371,8 @@ public class CLCommandQueueTest extends UITestCase { public void eventCallbackTest() throws InterruptedException { out.println(" - - - event callback test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLPlatform platform = CLPlatform.getDefault(); @@ -402,6 +413,8 @@ public class CLCommandQueueTest extends UITestCase { public void concurrencyTest() throws IOException, InterruptedException { out.println(" - - - QueueBarrier test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; final int elements = ONE_MB / SIZEOF_INT * 10; // 20MB per buffer diff --git a/test/com/jogamp/opencl/CLImageTest.java b/test/com/jogamp/opencl/CLImageTest.java index 3141f522..26e53ed2 100644 --- a/test/com/jogamp/opencl/CLImageTest.java +++ b/test/com/jogamp/opencl/CLImageTest.java @@ -40,6 +40,7 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; import static org.junit.Assert.*; @@ -83,6 +84,9 @@ public class CLImageTest extends UITestCase { @Test public void supportedImageFormatsTest() { + if(MiscUtils.isOpenCLUnavailable()) + return; + CLDevice device = getCompatibleDevice(); if(device == null) { out.println("WARNING: can not test image api."); @@ -106,6 +110,9 @@ public class CLImageTest extends UITestCase { @Test public void image2dCopyTest() throws IOException { + if(MiscUtils.isOpenCLUnavailable()) + return; + CLDevice device = getCompatibleDevice(); if(device == null) { out.println("WARNING: can not test image api."); @@ -142,6 +149,9 @@ public class CLImageTest extends UITestCase { @Test public void image2dKernelCopyTest() throws IOException { + if(MiscUtils.isOpenCLUnavailable()) + return; + CLDevice device = getCompatibleDevice(); if(device == null) { out.println("WARNING: can not test image api."); diff --git a/test/com/jogamp/opencl/CLProgramTest.java b/test/com/jogamp/opencl/CLProgramTest.java index eaf954e9..7fb7bc32 100644 --- a/test/com/jogamp/opencl/CLProgramTest.java +++ b/test/com/jogamp/opencl/CLProgramTest.java @@ -28,6 +28,7 @@ package com.jogamp.opencl; +import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; import com.jogamp.opencl.util.CLBuildConfiguration; import com.jogamp.opencl.util.CLProgramConfiguration; @@ -78,6 +79,8 @@ public class CLProgramTest extends UITestCase { public void rebuildProgramTest() throws IOException { out.println(" - - - CLProgramTest; rebuild program test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLContext context = CLContext.create(); CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")); @@ -117,6 +120,8 @@ public class CLProgramTest extends UITestCase { public void programBinariesTest() throws IOException { out.println(" - - - CLProgramTest; down-/upload binaries test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLContext context = CLContext.create(); CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")) @@ -194,6 +199,8 @@ public class CLProgramTest extends UITestCase { @Test public void builderTest() throws IOException, ClassNotFoundException, InterruptedException { out.println(" - - - CLProgramTest; program builder test - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLContext context = CLContext.create(); CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")); @@ -276,6 +283,9 @@ public class CLProgramTest extends UITestCase { @Test public void kernelTest() { + if(MiscUtils.isOpenCLUnavailable()) + return; + String source = "__attribute__((reqd_work_group_size(1, 1, 1))) kernel void foo(float a, int b, short c) { }\n"; CLContext context = CLContext.create(); @@ -324,6 +334,9 @@ public class CLProgramTest extends UITestCase { @Test public void createAllKernelsTest() { + if(MiscUtils.isOpenCLUnavailable()) + return; + String source = "kernel void foo(int a) { }\n"+ "kernel void bar(float b) { }\n"; diff --git a/test/com/jogamp/opencl/HighLevelBindingTest.java b/test/com/jogamp/opencl/HighLevelBindingTest.java index 6dd6a73f..6a003435 100644 --- a/test/com/jogamp/opencl/HighLevelBindingTest.java +++ b/test/com/jogamp/opencl/HighLevelBindingTest.java @@ -40,6 +40,7 @@ import com.jogamp.opencl.CLDevice.LocalMemType; import com.jogamp.opencl.CLDevice.Type; import com.jogamp.opencl.CLDevice.Capabilities; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; import java.io.IOException; @@ -137,6 +138,8 @@ public class HighLevelBindingTest extends UITestCase { public void contextlessTest() { out.println(" - - - highLevelTest; contextless - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; // platform/device info tests CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms(); @@ -205,6 +208,9 @@ public class HighLevelBindingTest extends UITestCase { @Test public void platformTest() { + if(MiscUtils.isOpenCLUnavailable()) + return; + CLPlatform platformGPU = CLPlatform.getDefault(version(CL_1_0), type(GPU)); CLPlatform platformCPU = CLPlatform.getDefault(version(CL_1_0), type(CPU)); @@ -221,6 +227,8 @@ public class HighLevelBindingTest extends UITestCase { public void createContextTest() { out.println(" - - - highLevelTest; create context - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLPlatform platform = CLPlatform.getDefault(); CLDevice[] devices = platform.listCLDevices(); @@ -280,6 +288,8 @@ public class HighLevelBindingTest extends UITestCase { public void vectorAddGMTest() throws IOException { out.println(" - - - highLevelTest; global memory kernel - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms(); CLContext context = CLContext.create(clPlatforms[0]); diff --git a/test/com/jogamp/opencl/LowLevelBindingTest.java b/test/com/jogamp/opencl/LowLevelBindingTest.java index 2780c07a..5381cab0 100644 --- a/test/com/jogamp/opencl/LowLevelBindingTest.java +++ b/test/com/jogamp/opencl/LowLevelBindingTest.java @@ -33,6 +33,7 @@ import java.util.Random; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.llb.impl.BuildProgramCallback; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; import java.io.IOException; @@ -102,6 +103,8 @@ public class LowLevelBindingTest extends UITestCase { public void contextlessTest() { out.println(" - - - lowLevelTest; contextless binding - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CL cl = CLPlatform.getLowLevelCLInterface(); @@ -174,6 +177,8 @@ public class LowLevelBindingTest extends UITestCase { public void createContextTest() { out.println(" - - - createContextTest - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CL cl = CLPlatform.getLowLevelCLInterface(); @@ -219,6 +224,8 @@ public class LowLevelBindingTest extends UITestCase { public void lowLevelVectorAddTest() throws InterruptedException { out.println(" - - - lowLevelTest2; VectorAdd kernel - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; CL cl = CLPlatform.getLowLevelCLInterface(); diff --git a/test/com/jogamp/opencl/gl/CLGLTest.java b/test/com/jogamp/opencl/gl/CLGLTest.java index 19bc1c99..52f0e574 100644 --- a/test/com/jogamp/opencl/gl/CLGLTest.java +++ b/test/com/jogamp/opencl/gl/CLGLTest.java @@ -45,6 +45,7 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLMemory.Mem; import com.jogamp.opencl.CLPlatform; +import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; import com.jogamp.opencl.util.CLDeviceFilters; import com.jogamp.opencl.util.CLPlatformFilters; @@ -106,9 +107,11 @@ public class CLGLTest extends UITestCase { @Test(timeout=15000) public void createContextTest() { - initGL(); - out.println(" - - - glcl; createContextTest - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; + + initGL(); CLPlatform platform = CLPlatform.getDefault(CLPlatformFilters.glSharing()); CLDevice device = platform.getMaxFlopsDevice(CLDeviceFilters.glSharing()); @@ -149,6 +152,8 @@ public class CLGLTest extends UITestCase { public void vboSharing() { out.println(" - - - glcl; vboSharing - - - "); + if(MiscUtils.isOpenCLUnavailable()) + return; initGL(); makeGLCurrent(); diff --git a/test/com/jogamp/opencl/test/util/MiscUtils.java b/test/com/jogamp/opencl/test/util/MiscUtils.java index 8332c24a..a7d54543 100644 --- a/test/com/jogamp/opencl/test/util/MiscUtils.java +++ b/test/com/jogamp/opencl/test/util/MiscUtils.java @@ -31,6 +31,8 @@ package com.jogamp.opencl.test.util; import java.nio.ByteBuffer; import java.util.Random; +import com.jogamp.opencl.llb.impl.CLAbstractImpl; + import static java.lang.System.*; import static org.junit.Assert.*; @@ -77,4 +79,17 @@ public class MiscUtils { a.rewind(); b.rewind(); } + + /** + * @return true if OpenCL is not available for this operating system, CPU architecture, et cetera. + * This is meant to be a check that there can't possibly be a driver installed because + * nobody makes one, not just a check that we didn't see one. + */ + public static final boolean isOpenCLUnavailable() { + if(!CLAbstractImpl.isAvailable() && System.getProperty("os.name").startsWith("SunOS")) { + out.println("OpenCL not available on this operating system. Skipping test."); + return true; + } + return false; + } } diff --git a/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java b/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java index a8c10ed4..b9b0b62d 100644 --- a/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java +++ b/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java @@ -10,6 +10,7 @@ import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLKernel; import com.jogamp.opencl.CLPlatform; +import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; import com.jogamp.opencl.util.concurrent.CLQueueContext.CLSimpleQueueContext; import com.jogamp.opencl.util.concurrent.CLQueueContextFactory.CLSimpleContextFactory; @@ -48,6 +49,9 @@ public class CLMultiContextTest extends UITestCase { @Test public void createMultiContextTest() { + if(MiscUtils.isOpenCLUnavailable()) + return; + CLMultiContext mc = CLMultiContext.create(CLPlatform.listCLPlatforms()); try{ @@ -117,6 +121,9 @@ public class CLMultiContextTest extends UITestCase { @Test public void commandQueuePoolTest() throws InterruptedException, ExecutionException { + if(MiscUtils.isOpenCLUnavailable()) + return; + CLMultiContext mc = CLMultiContext.create(CLPlatform.listCLPlatforms()); try { |