Skip to content

Commit

Permalink
Bug 978: Promote whether a test shall fail due to unavailable CL driv…
Browse files Browse the repository at this point in the history
…er in base UITest class.
  • Loading branch information
sgothel committed May 9, 2014
1 parent f0620f1 commit a503ff7
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 84 deletions.
14 changes: 0 additions & 14 deletions test/com/jogamp/opencl/CLBufferTest.java
Expand Up @@ -68,8 +68,6 @@ public class CLBufferTest extends UITestCase {
public void createBufferTest() {

out.println(" - - - highLevelTest; create buffer test - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CLContext context = CLContext.create();
try{
Expand Down Expand Up @@ -125,8 +123,6 @@ public void createBufferTest() {
public void writeCopyReadBufferTest() {

out.println(" - - - highLevelTest; copy buffer test - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

final int elements = NUM_ELEMENTS;

Expand Down Expand Up @@ -159,8 +155,6 @@ public void writeCopyReadBufferTest() {
public void bufferWithHostPointerTest() {

out.println(" - - - highLevelTest; host pointer test - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

final int elements = NUM_ELEMENTS;

Expand Down Expand Up @@ -205,8 +199,6 @@ public void bufferWithHostPointerTest() {
public void mapBufferTest() {

out.println(" - - - highLevelTest; map buffer test - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

final int elements = NUM_ELEMENTS;
final int sizeInBytes = elements*SIZEOF_INT;
Expand Down Expand Up @@ -260,8 +252,6 @@ public void mapBufferTest() {
public void subBufferTest01ByteBuffer() {

out.println(" - - - subBufferTest - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

@SuppressWarnings("unchecked")
CLPlatform platform = CLPlatform.getDefault(version(CL_1_1));
Expand Down Expand Up @@ -307,8 +297,6 @@ public void subBufferTest01ByteBuffer() {
public void subBufferTest02FloatBuffer() {

out.println(" - - - subBufferTest - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

@SuppressWarnings("unchecked")
CLPlatform platform = CLPlatform.getDefault(version(CL_1_1));
Expand Down Expand Up @@ -358,8 +346,6 @@ public void subBufferTest02FloatBuffer() {
public void destructorCallbackTest() throws InterruptedException {

out.println(" - - - destructorCallbackTest - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

@SuppressWarnings("unchecked")
CLPlatform platform = CLPlatform.getDefault(version(CL_1_1));
Expand Down
12 changes: 0 additions & 12 deletions test/com/jogamp/opencl/CLCommandQueueTest.java
Expand Up @@ -102,8 +102,6 @@ public void enumsTest() {
public void eventsTest() throws IOException {

out.println(" - - - event synchronization test - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CLContext context = CLContext.create();

Expand Down Expand Up @@ -175,8 +173,6 @@ public void eventsTest() throws IOException {
public void eventConditionsTest() throws IOException {

out.println(" - - - event conditions test - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CLPlatform platform = CLPlatform.getDefault(CLPlatformFilters.queueMode(OUT_OF_ORDER_MODE));

Expand Down Expand Up @@ -237,8 +233,6 @@ public void eventConditionsTest() throws IOException {
public void profilingEventsTest() throws IOException {

out.println(" - - - event synchronization test - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CLContext context = CLContext.create();

Expand Down Expand Up @@ -294,8 +288,6 @@ public void profilingEventsTest() throws IOException {
@Test
public void customEventsTest() throws IOException, InterruptedException {
out.println(" - - - user events test - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CLPlatform[] platforms = CLPlatform.listCLPlatforms();
CLPlatform theChosenOne = platforms[0];
Expand Down Expand Up @@ -372,8 +364,6 @@ public void customEventsTest() throws IOException, InterruptedException {
public void eventCallbackTest() throws InterruptedException {

out.println(" - - - event callback test - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CLPlatform platform = CLPlatform.getDefault();

Expand Down Expand Up @@ -414,8 +404,6 @@ public void eventStateChanged(CLEvent event, int status) {
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

Expand Down
11 changes: 0 additions & 11 deletions test/com/jogamp/opencl/CLImageTest.java
Expand Up @@ -84,9 +84,6 @@ public CLDevice getCompatibleDevice() {

@Test
public void supportedImageFormatsTest() {
if(MiscUtils.isOpenCLUnavailable())
return;

CLDevice device = getCompatibleDevice();
if(device == null) {
out.println("WARNING: can not test image api.");
Expand All @@ -109,10 +106,6 @@ public void supportedImageFormatsTest() {

@Test
public void image2dCopyTest() throws IOException {

if(MiscUtils.isOpenCLUnavailable())
return;

CLDevice device = getCompatibleDevice();
if(device == null) {
out.println("WARNING: can not test image api.");
Expand Down Expand Up @@ -148,10 +141,6 @@ public void image2dCopyTest() throws IOException {

@Test
public void image2dKernelCopyTest() throws IOException {

if(MiscUtils.isOpenCLUnavailable())
return;

CLDevice device = getCompatibleDevice();
if(device == null) {
out.println("WARNING: can not test image api.");
Expand Down
13 changes: 0 additions & 13 deletions test/com/jogamp/opencl/CLProgramTest.java
Expand Up @@ -79,8 +79,6 @@ public void enumsTest() {
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"));
Expand Down Expand Up @@ -124,8 +122,6 @@ public void rebuildProgramTest() throws IOException {
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"))
Expand Down Expand Up @@ -207,8 +203,6 @@ public void programBinariesTest() throws IOException {
@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"));
Expand Down Expand Up @@ -290,10 +284,6 @@ public void buildFinished(CLProgram program) {

@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();
Expand Down Expand Up @@ -342,9 +332,6 @@ public void kernelTest() {
@Test
public void createAllKernelsTest() {

if(MiscUtils.isOpenCLUnavailable())
return;

String source = "kernel void foo(int a) { }\n"+
"kernel void bar(float b) { }\n";

Expand Down
10 changes: 0 additions & 10 deletions test/com/jogamp/opencl/HighLevelBindingTest.java
Expand Up @@ -138,8 +138,6 @@ public void enumsTest() {
public void contextlessTest() {

out.println(" - - - highLevelTest; contextless - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

// platform/device info tests
CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms();
Expand Down Expand Up @@ -208,10 +206,6 @@ public void contextlessTest() {

@Test
public void platformTest() {

if(MiscUtils.isOpenCLUnavailable())
return;

@SuppressWarnings("unchecked")
CLPlatform platformGPU = CLPlatform.getDefault(version(CL_1_0), type(GPU));
@SuppressWarnings("unchecked")
Expand All @@ -230,8 +224,6 @@ public void platformTest() {
public void createContextTest() {

out.println(" - - - highLevelTest; create context - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CLPlatform platform = CLPlatform.getDefault();
CLDevice[] devices = platform.listCLDevices();
Expand Down Expand Up @@ -291,8 +283,6 @@ public void createContextTest() {
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]);
Expand Down
6 changes: 0 additions & 6 deletions test/com/jogamp/opencl/LowLevelBindingTest.java
Expand Up @@ -103,8 +103,6 @@ public static void setUpClass() throws Exception {
public void contextlessTest() {

out.println(" - - - lowLevelTest; contextless binding - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CL cl = CLPlatform.getLowLevelCLInterface();

Expand Down Expand Up @@ -177,8 +175,6 @@ public void contextlessTest() {
public void createContextTest() {

out.println(" - - - createContextTest - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CL cl = CLPlatform.getLowLevelCLInterface();

Expand Down Expand Up @@ -224,8 +220,6 @@ public void createContextTest() {
public void lowLevelVectorAddTest() throws InterruptedException {

out.println(" - - - lowLevelTest2; VectorAdd kernel - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

CL cl = CLPlatform.getLowLevelCLInterface();

Expand Down
4 changes: 0 additions & 4 deletions test/com/jogamp/opencl/gl/CLGLTest.java
Expand Up @@ -108,8 +108,6 @@ private void deinitGL() throws GLException {
public void createContextTest() {

out.println(" - - - glcl; createContextTest - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

initGL();

Expand Down Expand Up @@ -154,8 +152,6 @@ public void createContextTest() {
public void vboSharing() {

out.println(" - - - glcl; vboSharing - - - ");
if(MiscUtils.isOpenCLUnavailable())
return;

initGL();
makeGLCurrent();
Expand Down
15 changes: 10 additions & 5 deletions test/com/jogamp/opencl/test/util/MiscUtils.java
Expand Up @@ -29,8 +29,11 @@
package com.jogamp.opencl.test.util;

import java.nio.ByteBuffer;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;

import com.jogamp.common.os.Platform;
import com.jogamp.opencl.llb.impl.CLAbstractImpl;

import static java.lang.System.*;
Expand Down Expand Up @@ -80,16 +83,18 @@ public static final void checkIfEqual(ByteBuffer a, ByteBuffer b, int elements)
b.rewind();
}

private static final Set<Platform.OSType> knownOSWithoutCLImpl;
static {
knownOSWithoutCLImpl = new HashSet<Platform.OSType>();
knownOSWithoutCLImpl.add(Platform.OSType.SUNOS);
}

/**
* @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;
return !CLAbstractImpl.isAvailable() && knownOSWithoutCLImpl.contains(Platform.getOSType());
}
}
15 changes: 12 additions & 3 deletions test/com/jogamp/opencl/test/util/UITestCase.java
Expand Up @@ -34,6 +34,7 @@
import java.util.Iterator;
import java.util.List;

import com.jogamp.common.os.Platform;
import com.jogamp.common.util.locks.SingletonInstance;

import org.junit.Assume;
Expand Down Expand Up @@ -125,9 +126,17 @@ public static void oneTimeTearDown() {
@Before
public void setUp() {
System.err.print("++++ UITestCase.setUp: "+getFullTestName(" - "));
if(!testSupported) {
System.err.println(" - "+unsupportedTestMsg);
Assume.assumeTrue(testSupported); // abort
final boolean isOpenCLUnavailable = MiscUtils.isOpenCLUnavailable();
final boolean abortTest = isOpenCLUnavailable || !testSupported;
if( abortTest ) {
if( isOpenCLUnavailable ) {
System.err.print(" - CL not supported on "+Platform.getOSType());
}
if( !testSupported ) {
System.err.print(" - "+unsupportedTestMsg);
}
System.err.println("");
Assume.assumeTrue(false); // abort
}
System.err.println();
}
Expand Down
Expand Up @@ -49,9 +49,6 @@ public class CLMultiContextTest extends UITestCase {
@Test
public void createMultiContextTest() {

if(MiscUtils.isOpenCLUnavailable())
return;

CLMultiContext mc = CLMultiContext.create(CLPlatform.listCLPlatforms());

try{
Expand Down Expand Up @@ -121,9 +118,6 @@ public Buffer execute(CLSimpleQueueContext qc) {
@Test
public void commandQueuePoolTest() throws InterruptedException, ExecutionException {

if(MiscUtils.isOpenCLUnavailable())
return;

CLMultiContext mc = CLMultiContext.create(CLPlatform.listCLPlatforms());

try {
Expand Down

0 comments on commit a503ff7

Please sign in to comment.