diff --git a/src/test/java/com/aparapi/runtime/Issue55Test.java b/src/test/java/com/aparapi/runtime/Issue55Test.java new file mode 100644 index 0000000000000000000000000000000000000000..b46348c027f6bc5a58fe13efe999e51756726140 --- /dev/null +++ b/src/test/java/com/aparapi/runtime/Issue55Test.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.runtime; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + +import com.aparapi.Kernel; +import com.aparapi.device.Device; +import com.aparapi.internal.kernel.KernelManager; +import com.aparapi.internal.kernel.KernelManagers; + +public class Issue55Test { + private Kernel testKernel; + + @Before + public void setUp() { + testKernel = new Kernel() { + + @Override + public void run() { + } + }; + } + + @After + public void tearDown() { + testKernel.dispose(); + } + + @AfterClass + public static void tearDownClass() { + // reset the KernelManager after we are done, as some tests expect a openCL device + KernelManager.setKernelManager(new KernelManager() {}); + } + + @Test + public void testUseJTP_ONLY() { + KernelManager.setKernelManager(KernelManagers.JTP_ONLY); + + Device device = KernelManager.instance().getDefaultPreferences().getPreferredDevice(testKernel); + + assertThat(device.getType(), is(Device.TYPE.JTP)); + } + + @Test + public void testUseSEQUENTIAL_ONLY() { + KernelManager.setKernelManager(KernelManagers.SEQUENTIAL_ONLY); + + Device device = KernelManager.instance().getDefaultPreferences().getPreferredDevice(testKernel); + + assertThat(device.getType(), is(Device.TYPE.SEQ)); + } +}