Merge "Test that rs_script_call_t works properly." into jb-mr1-dev
diff --git a/tests/src/android/renderscript/cts/foreach_bounds_in.rs b/tests/src/android/renderscript/cts/foreach_bounds_in.rs
new file mode 100644
index 0000000..b0851a5
--- /dev/null
+++ b/tests/src/android/renderscript/cts/foreach_bounds_in.rs
@@ -0,0 +1,73 @@
+#include "shared.rsh"
+
+int *a;
+int dimX;
+int dimY;
+int xStart = 0;
+int xEnd = 0;
+int yStart = 0;
+int yEnd = 0;
+
+rs_script s;
+rs_allocation ain;
+rs_allocation aout;
+
+void root(const int *in, uint32_t x, uint32_t y) {
+ a[x + y * dimX] = x + y * dimX + *in; // in will be set to 7
+}
+
+int __attribute__((kernel)) zero() {
+ return 0;
+}
+
+int __attribute__((kernel)) seven() {
+ return 7;
+}
+
+static bool test_root_output() {
+ bool failed = false;
+ int i, j;
+
+ for (j = 0; j < dimY; j++) {
+ for (i = 0; i < dimX; i++) {
+ if (i < xStart || i >= xEnd || j < yStart || j >= yEnd) {
+ _RS_ASSERT(rsGetElementAt_int(aout, i, j) == 0);
+ } else {
+ _RS_ASSERT(rsGetElementAt_int(aout, i, j) ==
+ (i + j * dimX + 7));
+ }
+ }
+ }
+
+ if (failed) {
+ rsDebug("test_root_output FAILED", 0);
+ }
+ else {
+ rsDebug("test_root_output PASSED", 0);
+ }
+
+ return failed;
+}
+
+void foreach_bounds_in_test() {
+ static bool failed = false;
+
+ rs_script_call_t rssc = {0};
+ rssc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ rssc.xStart = xStart;
+ rssc.xEnd = xEnd;
+ rssc.yStart = yStart;
+ rssc.yEnd = yEnd;
+
+ rsForEach(s, ain, aout, NULL, 0, &rssc);
+
+ failed |= test_root_output();
+
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+
diff --git a/tests/src/android/renderscript/cts/foreach_bounds_inout.rs b/tests/src/android/renderscript/cts/foreach_bounds_inout.rs
new file mode 100644
index 0000000..3b5e9c3
--- /dev/null
+++ b/tests/src/android/renderscript/cts/foreach_bounds_inout.rs
@@ -0,0 +1,72 @@
+#include "shared.rsh"
+
+int dimX;
+int dimY;
+int xStart = 0;
+int xEnd = 0;
+int yStart = 0;
+int yEnd = 0;
+
+rs_script s;
+rs_allocation ain;
+rs_allocation aout;
+
+void root(const int *in, int *out, uint32_t x, uint32_t y) {
+ *out = x + y * dimX + *in; // in will be set to 7
+}
+
+int __attribute__((kernel)) zero() {
+ return 0;
+}
+
+int __attribute__((kernel)) seven() {
+ return 7;
+}
+
+static bool test_root_output() {
+ bool failed = false;
+ int i, j;
+
+ for (j = 0; j < dimY; j++) {
+ for (i = 0; i < dimX; i++) {
+ if (i < xStart || i >= xEnd || j < yStart || j >= yEnd) {
+ _RS_ASSERT(rsGetElementAt_int(aout, i, j) == 0);
+ } else {
+ _RS_ASSERT(rsGetElementAt_int(aout, i, j) ==
+ (i + j * dimX + 7));
+ }
+ }
+ }
+
+ if (failed) {
+ rsDebug("test_root_output FAILED", 0);
+ }
+ else {
+ rsDebug("test_root_output PASSED", 0);
+ }
+
+ return failed;
+}
+
+void foreach_bounds_inout_test() {
+ static bool failed = false;
+
+ rs_script_call_t rssc = {0};
+ rssc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ rssc.xStart = xStart;
+ rssc.xEnd = xEnd;
+ rssc.yStart = yStart;
+ rssc.yEnd = yEnd;
+
+ rsForEach(s, ain, aout, NULL, 0, &rssc);
+
+ failed |= test_root_output();
+
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+
diff --git a/tests/src/android/renderscript/cts/foreach_bounds_out.rs b/tests/src/android/renderscript/cts/foreach_bounds_out.rs
new file mode 100644
index 0000000..faba570
--- /dev/null
+++ b/tests/src/android/renderscript/cts/foreach_bounds_out.rs
@@ -0,0 +1,67 @@
+#include "shared.rsh"
+
+int dimX;
+int dimY;
+int xStart = 0;
+int xEnd = 0;
+int yStart = 0;
+int yEnd = 0;
+
+rs_script s;
+rs_allocation ain;
+rs_allocation aout;
+
+void root(int *out, uint32_t x, uint32_t y) {
+ *out = x + y * dimX;
+}
+
+int __attribute__((kernel)) zero() {
+ return 0;
+}
+
+static bool test_root_output() {
+ bool failed = false;
+ int i, j;
+
+ for (j = 0; j < dimY; j++) {
+ for (i = 0; i < dimX; i++) {
+ if (i < xStart || i >= xEnd || j < yStart || j >= yEnd) {
+ _RS_ASSERT(rsGetElementAt_int(aout, i, j) == 0);
+ } else {
+ _RS_ASSERT(rsGetElementAt_int(aout, i, j) == (i + j * dimX));
+ }
+ }
+ }
+
+ if (failed) {
+ rsDebug("test_root_output FAILED", 0);
+ }
+ else {
+ rsDebug("test_root_output PASSED", 0);
+ }
+
+ return failed;
+}
+
+void foreach_bounds_out_test() {
+ static bool failed = false;
+
+ rs_script_call_t rssc = {0};
+ rssc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ rssc.xStart = xStart;
+ rssc.xEnd = xEnd;
+ rssc.yStart = yStart;
+ rssc.yEnd = yEnd;
+
+ rsForEach(s, ain, aout, NULL, 0, &rssc);
+
+ failed |= test_root_output();
+
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ForEachBoundsTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ForEachBoundsTest.java
new file mode 100644
index 0000000..490e4ea
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ForEachBoundsTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * 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 android.renderscript.cts;
+
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.RSRuntimeException;
+import android.renderscript.Type;
+
+public class ForEachBoundsTest extends RSBaseCompute {
+ final int X = 5;
+ final int Y = 7;
+ final int xStart = 3;
+ final int xEnd = 5;
+ final int yStart = 2;
+ final int yEnd = 5;
+
+ public void testForEachBoundsIn() {
+ ScriptC_foreach_bounds_in s = new ScriptC_foreach_bounds_in(mRS);
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
+
+ s.set_dimX(X);
+ s.set_dimY(Y);
+ typeBuilder.setX(X).setY(Y);
+ Allocation Ain = Allocation.createTyped(mRS, typeBuilder.create());
+ Allocation Aout = Allocation.createTyped(mRS, typeBuilder.create());
+ s.bind_a(Aout);
+ s.set_s(s);
+ s.set_ain(Ain);
+ s.set_aout(Aout);
+ s.set_xStart(xStart);
+ s.set_xEnd(xEnd);
+ s.set_yStart(yStart);
+ s.set_yEnd(yEnd);
+ s.forEach_seven(Ain);
+ s.forEach_zero(Aout);
+ s.invoke_foreach_bounds_in_test();
+ mRS.finish();
+ waitForMessage();
+ checkForErrors();
+ }
+
+ public void testForEachBoundsOut() {
+ ScriptC_foreach_bounds_out s = new ScriptC_foreach_bounds_out(mRS);
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
+
+ s.set_dimX(X);
+ s.set_dimY(Y);
+ typeBuilder.setX(X).setY(Y);
+ Allocation Aout = Allocation.createTyped(mRS, typeBuilder.create());
+ s.set_s(s);
+ s.set_aout(Aout);
+ s.set_xStart(xStart);
+ s.set_xEnd(xEnd);
+ s.set_yStart(yStart);
+ s.set_yEnd(yEnd);
+ s.forEach_zero(Aout);
+ s.invoke_foreach_bounds_out_test();
+ mRS.finish();
+ waitForMessage();
+ checkForErrors();
+ }
+
+ public void testForEachBoundsInOut() {
+ ScriptC_foreach_bounds_inout s = new ScriptC_foreach_bounds_inout(mRS);
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
+
+ s.set_dimX(X);
+ s.set_dimY(Y);
+ typeBuilder.setX(X).setY(Y);
+ Allocation Ain = Allocation.createTyped(mRS, typeBuilder.create());
+ Allocation Aout = Allocation.createTyped(mRS, typeBuilder.create());
+ s.set_s(s);
+ s.set_ain(Ain);
+ s.set_aout(Aout);
+ s.set_xStart(xStart);
+ s.set_xEnd(xEnd);
+ s.set_yStart(yStart);
+ s.set_yEnd(yEnd);
+ s.forEach_seven(Ain);
+ s.forEach_zero(Aout);
+ s.invoke_foreach_bounds_inout_test();
+ mRS.finish();
+ waitForMessage();
+ checkForErrors();
+ }
+
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
index f633168..d62f588 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
@@ -478,6 +478,7 @@
s.invoke_foreach_test();
mRS.finish();
waitForMessage();
+ checkForErrors();
}
public void testNoRoot() {
@@ -495,7 +496,7 @@
s.invoke_verify_foo();
s.invoke_noroot_test();
mRS.finish();
- checkForErrors();
waitForMessage();
+ checkForErrors();
}
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java b/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
index 7caacfc..ab5297f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
@@ -478,6 +478,7 @@
s.invoke_foreach_test();
mRS.finish();
waitForMessage();
+ checkForErrors();
}
public void testNoRoot() {
@@ -495,7 +496,7 @@
s.invoke_verify_foo();
s.invoke_noroot_test();
mRS.finish();
- checkForErrors();
waitForMessage();
+ checkForErrors();
}
}