diff options
author | Stephen Hines <srhines@google.com> | 2012-09-26 19:03:57 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-26 19:04:48 -0700 |
commit | 0b1711582ff07d6d1e8e4de6c057eaf6a3473ac3 (patch) | |
tree | 444bbccc1a2464a40b492ad234a3bb235a1e67fd /tests | |
parent | c49c71a5c600485c395d95fd02fabde082e30177 (diff) | |
parent | d895d37e273503ae334dfd7a5ba60be49fe241bd (diff) | |
download | frameworks_base-0b1711582ff07d6d1e8e4de6c057eaf6a3473ac3.zip frameworks_base-0b1711582ff07d6d1e8e4de6c057eaf6a3473ac3.tar.gz frameworks_base-0b1711582ff07d6d1e8e4de6c057eaf6a3473ac3.tar.bz2 |
Merge "RS char bug repro case" into jb-mr1-dev
Diffstat (limited to 'tests')
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 83fadcb..7662007 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); + } +} + |