diff options
| author | Stephen Hines <srhines@google.com> | 2011-01-18 19:39:29 -0800 |
|---|---|---|
| committer | Stephen Hines <srhines@google.com> | 2011-01-18 21:04:59 -0800 |
| commit | 688de88b65cdafc62a82a4eb2ff182fd320a0e51 (patch) | |
| tree | 62c52dc1dc1d01796740459385515473962b0c0d /libs/rs/java | |
| parent | d63d33581051fdffd16789551852368d21b89fe1 (diff) | |
| download | frameworks_base-688de88b65cdafc62a82a4eb2ff182fd320a0e51.zip frameworks_base-688de88b65cdafc62a82a4eb2ff182fd320a0e51.tar.gz frameworks_base-688de88b65cdafc62a82a4eb2ff182fd320a0e51.tar.bz2 | |
Fix bug in modf library function (plus typos).
Change-Id: I643c905e2e3e2dcf7a61f1d027b749d9a0d6e542
Diffstat (limited to 'libs/rs/java')
3 files changed, 106 insertions, 0 deletions
diff --git a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java index fc3a065..541bf22 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java +++ b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java @@ -68,6 +68,7 @@ public class RSTestCore { unitTests.add(new UT_rsdebug(this, mRes, mCtx)); unitTests.add(new UT_rstime(this, mRes, mCtx)); unitTests.add(new UT_rstypes(this, mRes, mCtx)); + unitTests.add(new UT_math(this, mRes, mCtx)); unitTests.add(new UT_fp_mad(this, mRes, mCtx)); /* unitTests.add(new UnitTest(null, "<Pass>", 1)); diff --git a/libs/rs/java/tests/src/com/android/rs/test/UT_math.java b/libs/rs/java/tests/src/com/android/rs/test/UT_math.java new file mode 100644 index 0000000..bf133be --- /dev/null +++ b/libs/rs/java/tests/src/com/android/rs/test/UT_math.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010 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.*; + +public class UT_math extends UnitTest { + private Resources mRes; + + protected UT_math(RSTestCore rstc, Resources res, Context ctx) { + super(rstc, "Math", ctx); + mRes = res; + } + + public void run() { + RenderScript pRS = RenderScript.create(mCtx); + ScriptC_math s = new ScriptC_math(pRS, mRes, R.raw.math); + pRS.setMessageHandler(mRsMessage); + s.invoke_math_test(0, 0); + pRS.finish(); + waitForMessage(); + pRS.destroy(); + } +} diff --git a/libs/rs/java/tests/src/com/android/rs/test/math.rs b/libs/rs/java/tests/src/com/android/rs/test/math.rs new file mode 100644 index 0000000..5b1ad15 --- /dev/null +++ b/libs/rs/java/tests/src/com/android/rs/test/math.rs @@ -0,0 +1,65 @@ +#include "shared.rsh" + +// Testing math library + +volatile float f1; +volatile float2 f2; +volatile float3 f3; +volatile float4 f4; + +#define TEST_F(fnc, var) \ + rsDebug("Testing " #fnc, 0); \ + var##1 = fnc(var##1); \ + var##2 = fnc(var##2); \ + var##3 = fnc(var##3); \ + var##4 = fnc(var##4); + +#define TEST_FP(fnc, var) \ + rsDebug("Testing " #fnc, 0); \ + var##1 = fnc(var##1, (float*) &f1); \ + var##2 = fnc(var##2, (float2*) &f2); \ + var##3 = fnc(var##3, (float3*) &f3); \ + var##4 = fnc(var##4, (float4*) &f4); + +#define TEST_F2(fnc, var) \ + rsDebug("Testing " #fnc, 0); \ + var##1 = fnc(var##1, var##1); \ + var##2 = fnc(var##2, var##2); \ + var##3 = fnc(var##3, var##3); \ + var##4 = fnc(var##4, var##4); + +static bool test_math(uint32_t index) { + bool failed = false; + start(); + + TEST_F(cos, f); + TEST_FP(modf, f); + TEST_F2(pow, f); + TEST_F(sin, f); + TEST_F(sqrt, f); + + + float time = end(index); + + if (failed) { + rsDebug("test_math FAILED", time); + } + else { + rsDebug("test_math PASSED", time); + } + + return failed; +} + +void math_test(uint32_t index, int test_num) { + bool failed = false; + failed |= test_math(index); + + if (failed) { + rsSendToClientBlocking(RS_MSG_TEST_FAILED); + } + else { + rsSendToClientBlocking(RS_MSG_TEST_PASSED); + } +} + |
