[RenderScript] Add ForEach test to CTS rsCpp tests.
Change-Id: I75d04640a7513928dd2238bd0e430b519e20feda
diff --git a/tests/tests/rscpp/librscpptest/Android.mk b/tests/tests/rscpp/librscpptest/Android.mk
index eaeaa7e..65a5e2a 100644
--- a/tests/tests/rscpp/librscpptest/Android.mk
+++ b/tests/tests/rscpp/librscpptest/Android.mk
@@ -26,6 +26,7 @@
rs_jni.cpp \
rs_jni_allocation.cpp \
rs_jni_element.cpp \
+ rs_jni_foreach.cpp \
rs_jni_script.cpp \
rs_jni_type.cpp \
rs_jni_object.cpp
@@ -34,7 +35,10 @@
setelementat.rs \
primitives.rs \
instance.rs \
- clear_object.rs
+ clear_object.rs \
+ foreach.rs \
+ fe_all.rs \
+ noroot.rs
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
LOCAL_C_INCLUDES += frameworks/rs/cpp
diff --git a/tests/tests/rscpp/librscpptest/fe_all.rs b/tests/tests/rscpp/librscpptest/fe_all.rs
new file mode 100644
index 0000000..dc20ba7
--- /dev/null
+++ b/tests/tests/rscpp/librscpptest/fe_all.rs
@@ -0,0 +1,163 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.cts.rscpp)
+
+void test_i8(const char *ain, uchar *aout) {
+ aout[0] = ain[0] + 1;
+ return;
+}
+
+void test_i8_2(const char2 *ain, uchar2 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ return;
+}
+
+void test_i8_3(const char3 *ain, uchar3 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ aout[0].z = ain[0].z + 1;
+ return;
+}
+
+void test_i8_4(const char4 *ain, uchar4 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ aout[0].z = ain[0].z + 1;
+ aout[0].w = ain[0].w + 1;
+ return;
+}
+
+void test_i16(const short *ain, ushort *aout) {
+ aout[0] = ain[0] + 1;
+ return;
+}
+
+void test_i16_2(const short2 *ain, ushort2 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ return;
+}
+
+void test_i16_3(const short3 *ain, ushort3 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ aout[0].z = ain[0].z + 1;
+ return;
+}
+
+void test_i16_4(const short4 *ain, ushort4 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ aout[0].z = ain[0].z + 1;
+ aout[0].w = ain[0].w + 1;
+ return;
+}
+
+void test_i32(const int *ain, uint *aout) {
+ aout[0] = ain[0] + 1;
+ return;
+}
+
+void test_i32_2(const int2 *ain, uint2 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ return;
+}
+
+void test_i32_3(const int3 *ain, uint3 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ aout[0].z = ain[0].z + 1;
+ return;
+}
+
+void test_i32_4(const int4 *ain, uint4 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ aout[0].z = ain[0].z + 1;
+ aout[0].w = ain[0].w + 1;
+ return;
+}
+
+void test_i64(const long *ain, ulong *aout) {
+ aout[0] = ain[0] + 1;
+ return;
+}
+
+void test_i64_2(const long2 *ain, ulong2 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ return;
+}
+
+void test_i64_3(const long3 *ain, ulong3 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ aout[0].z = ain[0].z + 1;
+ return;
+}
+
+void test_i64_4(const long4 *ain, ulong4 *aout) {
+ aout[0].x = ain[0].x + 1;
+ aout[0].y = ain[0].y + 1;
+ aout[0].z = ain[0].z + 1;
+ aout[0].w = ain[0].w + 1;
+ return;
+}
+
+void test_f32(const float *ain, float *aout) {
+ aout[0] = ain[0] + 1.0f;
+ return;
+}
+
+void test_f32_2(const float2 *ain, float2 *aout) {
+ aout[0].x = ain[0].x + 1.0f;
+ aout[0].y = ain[0].y + 1.0f;
+ return;
+}
+
+void test_f32_3(const float3 *ain, float3 *aout) {
+ aout[0].x = ain[0].x + 1.0f;
+ aout[0].y = ain[0].y + 1.0f;
+ aout[0].z = ain[0].z + 1.0f;
+ return;
+}
+
+void test_f32_4(const float4 *ain, float4 *aout) {
+ aout[0].x = ain[0].x + 1.0f;
+ aout[0].y = ain[0].y + 1.0f;
+ aout[0].z = ain[0].z + 1.0f;
+ aout[0].w = ain[0].w + 1.0f;
+ return;
+}
+
+void test_f64(const double *ain, double *aout) {
+ aout[0] = ain[0] + 1.0;
+ return;
+}
+
+void test_f64_2(const double2 *ain, double2 *aout) {
+ aout[0].x = ain[0].x + 1.0;
+ aout[0].y = ain[0].y + 1.0;
+ return;
+}
+
+void test_f64_3(const double3 *ain, double3 *aout) {
+ aout[0].x = ain[0].x + 1.0;
+ aout[0].y = ain[0].y + 1.0;
+ aout[0].z = ain[0].z + 1.0;
+ return;
+}
+
+void test_f64_4(const double4 *ain, double4 *aout) {
+ aout[0].x = ain[0].x + 1.0;
+ aout[0].y = ain[0].y + 1.0;
+ aout[0].z = ain[0].z + 1.0;
+ aout[0].w = ain[0].w + 1.0;
+ return;
+}
+
+void test_bool(const bool *ain, bool *aout) {
+ aout[0] = !ain[0];
+ return;
+}
diff --git a/tests/tests/rscpp/librscpptest/foreach.rs b/tests/tests/rscpp/librscpptest/foreach.rs
new file mode 100644
index 0000000..08e6bed
--- /dev/null
+++ b/tests/tests/rscpp/librscpptest/foreach.rs
@@ -0,0 +1,76 @@
+#include "shared.rsh"
+
+rs_allocation aRaw;
+int dimX;
+int dimY;
+static bool failed = false;
+
+void root(int *out, uint32_t x, uint32_t y) {
+ *out = x + y * dimX;
+}
+
+void foo(const int *in, int *out, uint32_t x, uint32_t y) {
+ _RS_ASSERT(*in == (x + y * dimX));
+ *out = 99 + x + y * dimX;
+ _RS_ASSERT(*out == (99 + x + y * dimX));
+}
+
+static bool test_root_output() {
+ bool failed = false;
+ int i, j;
+
+ for (j = 0; j < dimY; j++) {
+ for (i = 0; i < dimX; i++) {
+ int v = rsGetElementAt_int(aRaw, i, j);
+ _RS_ASSERT(v == (i + j * dimX));
+ }
+ }
+
+ if (failed) {
+ rsDebug("test_root_output FAILED", 0);
+ }
+ else {
+ rsDebug("test_root_output PASSED", 0);
+ }
+
+ return failed;
+}
+
+static bool test_foo_output() {
+ bool failed = false;
+ int i, j;
+
+ for (j = 0; j < dimY; j++) {
+ for (i = 0; i < dimX; i++) {
+ int v = rsGetElementAt_int(aRaw, i, j);
+ _RS_ASSERT(v == (99 + i + j * dimX));
+ }
+ }
+
+ if (failed) {
+ rsDebug("test_foo_output FAILED", 0);
+ }
+ else {
+ rsDebug("test_foo_output PASSED", 0);
+ }
+
+ return failed;
+}
+
+void verify_root() {
+ failed |= test_root_output();
+}
+
+void verify_foo() {
+ failed |= test_foo_output();
+}
+
+void foreach_test() {
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+
diff --git a/tests/tests/rscpp/librscpptest/noroot.rs b/tests/tests/rscpp/librscpptest/noroot.rs
new file mode 100644
index 0000000..f69effc
--- /dev/null
+++ b/tests/tests/rscpp/librscpptest/noroot.rs
@@ -0,0 +1,46 @@
+#include "shared.rsh"
+
+int *a;
+rs_allocation aRaw;
+int dimX;
+int dimY;
+static bool failed = false;
+
+void foo(const int *in, int *out, uint32_t x, uint32_t y) {
+ *out = 99 + x + y * dimX;
+}
+
+static bool test_foo_output() {
+ bool failed = false;
+ int i, j;
+
+ for (j = 0; j < dimY; j++) {
+ for (i = 0; i < dimX; i++) {
+ int v = rsGetElementAt_int(aRaw, i, j);
+ _RS_ASSERT(v == (99 + i + j * dimX));
+ }
+ }
+
+ if (failed) {
+ rsDebug("test_foo_output FAILED", 0);
+ }
+ else {
+ rsDebug("test_foo_output PASSED", 0);
+ }
+
+ return failed;
+}
+
+void verify_foo() {
+ failed |= test_foo_output();
+}
+
+void noroot_test() {
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+
diff --git a/tests/tests/rscpp/librscpptest/rs_jni_foreach.cpp b/tests/tests/rscpp/librscpptest/rs_jni_foreach.cpp
new file mode 100644
index 0000000..c0c0a13
--- /dev/null
+++ b/tests/tests/rscpp/librscpptest/rs_jni_foreach.cpp
@@ -0,0 +1,344 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+#include <jni.h>
+#include <android/log.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <RenderScript.h>
+
+#define LOG_TAG "rscpptest"
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+#include "ScriptC_foreach.h"
+#include "ScriptC_fe_all.h"
+#include "ScriptC_noroot.h"
+
+using namespace android::RSC;
+
+extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSForEachTest_testForEach(JNIEnv * env,
+ jclass obj,
+ jstring pathObj)
+{
+ const char * path = env->GetStringUTFChars(pathObj, NULL);
+ sp<RS> mRS = new RS();
+ mRS->init(path);
+ env->ReleaseStringUTFChars(pathObj, path);
+
+ bool passed = true;
+ int x = 7;
+
+ sp<ScriptC_fe_all> fe_all = new ScriptC_fe_all(mRS);
+ sp<const Type> t = Type::create(mRS, Element::I8(mRS), x, 0, 0);
+
+ // I8
+ sp<Allocation> in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U8(mRS), x, 0, 0);
+ sp<Allocation> out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i8(in, out);
+ mRS->finish();
+
+ // I8_2
+ t = Type::create(mRS, Element::I8_2(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U8_2(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i8_2(in, out);
+ mRS->finish();
+
+ // I8_3
+ t = Type::create(mRS, Element::I8_3(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U8_3(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i8_3(in, out);
+ mRS->finish();
+
+ // I8_4
+ t = Type::create(mRS, Element::I8_4(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U8_4(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i8_4(in, out);
+ mRS->finish();
+
+ // I16
+ t = Type::create(mRS, Element::I16(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U16(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i16(in, out);
+ mRS->finish();
+
+ // I16_2
+ t = Type::create(mRS, Element::I16_2(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U16_2(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i16_2(in, out);
+ mRS->finish();
+
+ // I16_3
+ t = Type::create(mRS, Element::I16_3(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U16_3(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i16_3(in, out);
+ mRS->finish();
+
+ // I16_4
+ t = Type::create(mRS, Element::I16_4(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U16_4(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i16_4(in, out);
+ mRS->finish();
+
+ // I32
+ t = Type::create(mRS, Element::I32(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U32(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i32(in, out);
+ mRS->finish();
+
+ // I32_2
+ t = Type::create(mRS, Element::I32_2(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U32_2(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i32_2(in, out);
+ mRS->finish();
+
+ // I32_3
+ t = Type::create(mRS, Element::I32_3(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U32_3(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i32_3(in, out);
+ mRS->finish();
+
+ // I32_4
+ t = Type::create(mRS, Element::I32_4(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U32_4(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i32_4(in, out);
+ mRS->finish();
+
+ // I64
+ t = Type::create(mRS, Element::I64(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U64(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i64(in, out);
+ mRS->finish();
+
+ // I64_2
+ t = Type::create(mRS, Element::I64_2(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U64_2(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i64_2(in, out);
+ mRS->finish();
+
+ // I64_3
+ t = Type::create(mRS, Element::I64_3(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U64_3(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i64_3(in, out);
+ mRS->finish();
+
+ // I64_4
+ t = Type::create(mRS, Element::I64_4(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::U64_4(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i64_4(in, out);
+ mRS->finish();
+
+ // F32
+ t = Type::create(mRS, Element::F32(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_f32(in, out);
+ mRS->finish();
+
+ // F32_2
+ t = Type::create(mRS, Element::F32_2(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::F32_2(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_f32_2(in, out);
+ mRS->finish();
+
+ // F32_3
+ t = Type::create(mRS, Element::F32_3(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_f32_3(in, out);
+ mRS->finish();
+
+ // F32_4
+ t = Type::create(mRS, Element::F32_4(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_f32_4(in, out);
+ mRS->finish();
+
+ // F64
+ t = Type::create(mRS, Element::F64(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_f64(in, out);
+ mRS->finish();
+
+ // F64_2
+ t = Type::create(mRS, Element::F64_2(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_f64_2(in, out);
+ mRS->finish();
+
+ // F64_3
+ t = Type::create(mRS, Element::F64_3(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_f64_3(in, out);
+ mRS->finish();
+
+ // F64_4
+ t = Type::create(mRS, Element::F64_4(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_f64_4(in, out);
+ mRS->finish();
+
+ // BOOLEAN
+ t = Type::create(mRS, Element::BOOLEAN(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_bool(in, out);
+ mRS->finish();
+
+ // A_8
+ t = Type::create(mRS, Element::I8(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::A_8(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i8(in, out);
+ mRS->finish();
+
+ // RGBA_8888
+ t = Type::create(mRS, Element::I8_4(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::RGBA_8888(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i8_4(in, out);
+ mRS->finish();
+
+ // RGB_888
+ t = Type::create(mRS, Element::I8_3(mRS), x, 0, 0);
+ in = Allocation::createTyped(mRS, t);
+ t = Type::create(mRS, Element::RGB_888(mRS), x, 0, 0);
+ out = Allocation::createTyped(mRS, t);
+ fe_all->forEach_test_i8_3(in, out);
+ mRS->finish();
+
+ return passed;
+}
+
+#define RS_MSG_TEST_PASSED 100
+#define RS_MSG_TEST_FAILED 101
+
+static int result = 0;
+static void rsMsgHandler(uint32_t msgNum, const void *msgData, size_t msgLen) {
+ if (result == 0) {
+ result = msgNum;
+ }
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSForEachTest_testMultipleForEach(JNIEnv * env,
+ jclass obj,
+ jstring pathObj)
+{
+ const char * path = env->GetStringUTFChars(pathObj, NULL);
+ sp<RS> mRS = new RS();
+ mRS->init(path);
+ env->ReleaseStringUTFChars(pathObj, path);
+ MessageHandlerFunc_t mHandler = rsMsgHandler;
+ mRS->setMessageHandler(mHandler);
+
+ bool passed = true;
+ sp<ScriptC_foreach> s = new ScriptC_foreach(mRS);
+
+ int X = 5;
+ int Y = 7;
+ s->set_dimX(X);
+ s->set_dimY(Y);
+ sp<const Type> t = Type::create(mRS, Element::I32(mRS), X, Y, 0);
+ sp<Allocation> A = Allocation::createTyped(mRS, t);
+ s->set_aRaw(A);
+ s->forEach_root(A);
+ s->invoke_verify_root();
+ s->forEach_foo(A, A);
+ s->invoke_verify_foo();
+ s->invoke_foreach_test();
+ mRS->finish();
+ if (result == RS_MSG_TEST_FAILED) {
+ passed = false;
+ }
+ result = 0;
+ return passed;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSForEachTest_testNoRoot(JNIEnv * env,
+ jclass obj,
+ jstring pathObj)
+{
+ const char * path = env->GetStringUTFChars(pathObj, NULL);
+ sp<RS> mRS = new RS();
+ mRS->init(path);
+ env->ReleaseStringUTFChars(pathObj, path);
+ MessageHandlerFunc_t mHandler = rsMsgHandler;
+ mRS->setMessageHandler(mHandler);
+
+ bool passed = true;
+ sp<ScriptC_noroot> s = new ScriptC_noroot(mRS);
+
+ int X = 5;
+ int Y = 7;
+ s->set_dimX(X);
+ s->set_dimY(Y);
+ sp<const Type> t = Type::create(mRS, Element::I32(mRS), X, Y, 0);
+ sp<Allocation> A = Allocation::createTyped(mRS, t);
+ s->set_aRaw(A);
+ s->forEach_foo(A, A);
+ s->invoke_verify_foo();
+ s->invoke_noroot_test();
+ mRS->finish();
+ if (result == RS_MSG_TEST_FAILED) {
+ passed = false;
+ }
+ result = 0;
+ return passed;
+}
+
diff --git a/tests/tests/rscpp/src/android/cts/rscpp/RSForEachTest.java b/tests/tests/rscpp/src/android/cts/rscpp/RSForEachTest.java
new file mode 100644
index 0000000..3f497bb
--- /dev/null
+++ b/tests/tests/rscpp/src/android/cts/rscpp/RSForEachTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2015 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.cts.rscpp;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.test.AndroidTestCase;
+import android.renderscript.*;
+import android.util.Log;
+
+public class RSForEachTest extends RSCppTest {
+ static {
+ System.loadLibrary("rscpptest_jni");
+ }
+
+ native boolean testForEach(String path);
+ public void testRSForEachTestForEach() {
+ assertTrue(testForEach(this.getContext().getCacheDir().toString()));
+ }
+
+ native boolean testMultipleForEach(String path);
+ public void testRSForEachTestMultipleForEach() {
+ assertTrue(testMultipleForEach(this.getContext().getCacheDir().toString()));
+ }
+
+ native boolean testNoRoot(String path);
+ public void testRSForEachTestNoRoot() {
+ assertTrue(testNoRoot(this.getContext().getCacheDir().toString()));
+ }
+}