summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2012-07-20 18:13:08 -0700
committerStephen Hines <srhines@google.com>2012-09-25 20:47:09 -0700
commitd895d37e273503ae334dfd7a5ba60be49fe241bd (patch)
treeac06a011a848b4c797bff2097eb8fea5298ce612 /tests
parent26c5686b7e3bf0ba238c55caa3e86447bab7cc61 (diff)
downloadframeworks_base-d895d37e273503ae334dfd7a5ba60be49fe241bd.zip
frameworks_base-d895d37e273503ae334dfd7a5ba60be49fe241bd.tar.gz
frameworks_base-d895d37e273503ae334dfd7a5ba60be49fe241bd.tar.bz2
RS char bug repro case
Bug: 6865598 Change-Id: Ic43002e0b0646af7eda1b2283e4df7db8dfcf68b
Diffstat (limited to 'tests')
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java1
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java89
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs47
3 files changed, 137 insertions, 0 deletions
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
index 2a06491..143abae 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
@@ -72,6 +72,7 @@ public class RSTestCore {
unitTests.add(new UT_array_alloc(this, mRes, mCtx));
unitTests.add(new UT_kernel(this, mRes, mCtx));
unitTests.add(new UT_kernel_struct(this, mRes, mCtx));
+ unitTests.add(new UT_bug_char(this, mRes, mCtx));
unitTests.add(new UT_clamp(this, mRes, mCtx));
unitTests.add(new UT_clamp_relaxed(this, mRes, mCtx));
unitTests.add(new UT_convert(this, mRes, mCtx));
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java
new file mode 100644
index 0000000..faf3a31
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java
@@ -0,0 +1,89 @@
+/*
+ * 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 com.android.rs.test;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.renderscript.*;
+import android.util.Log;
+import java.util.Arrays;
+
+public class UT_bug_char extends UnitTest {
+ private Resources mRes;
+
+ protected UT_bug_char(RSTestCore rstc, Resources res, Context ctx) {
+ super(rstc, "Bug Char", ctx);
+ mRes = res;
+ }
+
+ // packing functions
+ private Byte2 pack_b2(byte[] val) {
+ assert val.length == 2;
+ Log.i("bug_char", "pack_b2 " + val[0] + " " + val[1]);
+ return new Byte2(val[0], val[1]);
+ }
+
+ private byte min(byte v1, byte v2) {
+ return v1 < v2 ? v1 : v2;
+ }
+ private byte[] min(byte[] v1, byte[] v2) {
+ assert v1.length == v2.length;
+ byte[] rv = new byte[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = min(v1[i], v2[i]);
+ return rv;
+ }
+
+ private void initializeValues(ScriptC_bug_char s) {
+ byte rand_sc1_0 = (byte)7;
+ byte[] rand_sc2_0 = new byte[2];
+ rand_sc2_0[0] = 11;
+ rand_sc2_0[1] = 21;
+ Log.i("bug_char", "Generated sc2_0 to " + Arrays.toString(rand_sc2_0));
+ byte rand_sc1_1 = (byte)10;
+ byte[] rand_sc2_1 = new byte[2];
+ rand_sc2_1[0] = 13;
+ rand_sc2_1[1] = 15;
+ Log.i("bug_char", "Generated sc2_1 to " + Arrays.toString(rand_sc2_1));
+
+ s.set_rand_sc1_0(rand_sc1_0);
+ s.set_rand_sc2_0(pack_b2(rand_sc2_0));
+ s.set_rand_sc1_1(rand_sc1_1);
+ s.set_rand_sc2_1(pack_b2(rand_sc2_1));
+ // Set results for min
+ s.set_min_rand_sc1_sc1(min(rand_sc1_0, rand_sc1_1));
+ byte[] min_rand_sc2_raw = min(rand_sc2_0, rand_sc2_1);
+ Log.i("bug_char", "Generating min_rand_sc2_sc2 to " +
+ Arrays.toString(min_rand_sc2_raw));
+ Byte2 min_rand_sc2 = pack_b2(min_rand_sc2_raw);
+ Log.i("bug_char", "Setting min_rand_sc2_sc2 to [" + min_rand_sc2.x +
+ ", " + min_rand_sc2.y + "]");
+ s.set_min_rand_sc2_sc2(min_rand_sc2);
+ }
+
+ public void run() {
+ RenderScript pRS = RenderScript.create(mCtx);
+ ScriptC_bug_char s = new ScriptC_bug_char(pRS, mRes,
+ R.raw.bug_char);
+ pRS.setMessageHandler(mRsMessage);
+ initializeValues(s);
+ s.invoke_bug_char_test();
+ pRS.finish();
+ waitForMessage();
+ pRS.destroy();
+ }
+}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs
new file mode 100644
index 0000000..dcd7b72
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs
@@ -0,0 +1,47 @@
+#include "shared.rsh"
+
+char rand_sc1_0, rand_sc1_1;
+char2 rand_sc2_0, rand_sc2_1;
+
+char min_rand_sc1_sc1;
+char2 min_rand_sc2_sc2;
+
+static bool test_bug_char() {
+ bool failed = false;
+
+ rsDebug("rand_sc2_0.x: ", rand_sc2_0.x);
+ rsDebug("rand_sc2_0.y: ", rand_sc2_0.y);
+ rsDebug("rand_sc2_1.x: ", rand_sc2_1.x);
+ rsDebug("rand_sc2_1.y: ", rand_sc2_1.y);
+ char temp_sc1;
+ char2 temp_sc2;
+
+ temp_sc1 = min( rand_sc1_0, rand_sc1_1 );
+ if (temp_sc1 != min_rand_sc1_sc1) {
+ rsDebug("temp_sc1", temp_sc1);
+ failed = true;
+ }
+ rsDebug("broken", 'y');
+
+ temp_sc2 = min( rand_sc2_0, rand_sc2_1 );
+ if (temp_sc2.x != min_rand_sc2_sc2.x
+ || temp_sc2.y != min_rand_sc2_sc2.y) {
+ failed = true;
+ }
+
+
+ return failed;
+}
+
+void bug_char_test() {
+ bool failed = false;
+ failed |= test_bug_char();
+
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+