summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-02-26 03:22:49 +0100
committerMichael Bien <[email protected]>2010-02-26 03:22:49 +0100
commit4d348191412077970954f3bc6e672a34f4a7980b (patch)
tree8a0e43cb5e5252fc79963865523d684e2513486d /test
parent0857dbb04fe9259f1076e9559b822c5032c23461 (diff)
implemented Serialization for CLProgramBuilder.
CLProgram.getBinaries() is now ordered. updated junit to 4.8.1. javadoc fixes.
Diffstat (limited to 'test')
-rw-r--r--test/com/mbien/opencl/CLProgramTest.java40
1 files changed, 33 insertions, 7 deletions
diff --git a/test/com/mbien/opencl/CLProgramTest.java b/test/com/mbien/opencl/CLProgramTest.java
index a1392bfc..16684738 100644
--- a/test/com/mbien/opencl/CLProgramTest.java
+++ b/test/com/mbien/opencl/CLProgramTest.java
@@ -1,9 +1,16 @@
package com.mbien.opencl;
import com.mbien.opencl.CLProgram.Status;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.Map;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import static org.junit.Assert.*;
import static java.lang.System.*;
@@ -15,6 +22,10 @@ import static com.mbien.opencl.CLProgram.CompilerOptions.*;
*/
public class CLProgramTest {
+ @Rule
+ public TemporaryFolder tmpFolder = new TemporaryFolder();
+
+
@Test
public void enumsTest() {
@@ -143,8 +154,8 @@ public class CLProgramTest {
}
@Test
- public void builderTest() throws IOException {
- out.println(" - - - CLProgramTest; builder test - - - ");
+ public void builderTest() throws IOException, ClassNotFoundException {
+ out.println(" - - - CLProgramTest; program builder test - - - ");
CLContext context = CLContext.create();
CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl"));
@@ -153,7 +164,6 @@ public class CLProgramTest {
program.prepare().build();
assertTrue(program.isExecutable());
-// program.release();
// complex build
@@ -164,18 +174,34 @@ public class CLProgramTest {
.build();
assertTrue(program.isExecutable());
-// program.release();
// reusable builder
CLBuildConfiguration builder = CLProgramBuilder.createConfiguration()
.withOption(ENABLE_MAD)
- .forDevice(context.getMaxFlopsDevice())
+ .forDevices(context.getDevices())
.withDefine("RADIUS", 5)
.withDefine("ENABLE_FOOBAR");
- builder.build(program);
+
+ builder.setProgram(program).build();
+ assertTrue(program.isExecutable());
+ // serialization test
+ File file = tmpFolder.newFile("foobar.builder");
+ ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
+ builder.save(oos);
+ oos.close();
+
+ ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
+ CLBuildConfiguration builder2 = builder.load(ois);
+ ois.close();
+
+ assertEquals(builder, builder2);
+
+ builder2.build(program);
assertTrue(program.isExecutable());
-// program.release();
+
+ // cloneing
+ assertEquals(builder, builder.clone());
}