1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "shared.rsh" 18 19rs_allocation aRaw; 20int dimX; 21int dimY; 22static bool failed = false; 23 24void root(int *out, uint32_t x, uint32_t y) { 25 *out = x + y * dimX; 26} 27 28void foo(const int *in, int *out, uint32_t x, uint32_t y) { 29 _RS_ASSERT(*in == (x + y * dimX)); 30 *out = 99 + x + y * dimX; 31 _RS_ASSERT(*out == (99 + x + y * dimX)); 32} 33 34static bool test_root_output() { 35 bool failed = false; 36 int i, j; 37 38 for (j = 0; j < dimY; j++) { 39 for (i = 0; i < dimX; i++) { 40 int v = rsGetElementAt_int(aRaw, i, j); 41 _RS_ASSERT(v == (i + j * dimX)); 42 } 43 } 44 45 if (failed) { 46 rsDebug("test_root_output FAILED", 0); 47 } 48 else { 49 rsDebug("test_root_output PASSED", 0); 50 } 51 52 return failed; 53} 54 55static bool test_foo_output() { 56 bool failed = false; 57 int i, j; 58 59 for (j = 0; j < dimY; j++) { 60 for (i = 0; i < dimX; i++) { 61 int v = rsGetElementAt_int(aRaw, i, j); 62 _RS_ASSERT(v == (99 + i + j * dimX)); 63 } 64 } 65 66 if (failed) { 67 rsDebug("test_foo_output FAILED", 0); 68 } 69 else { 70 rsDebug("test_foo_output PASSED", 0); 71 } 72 73 return failed; 74} 75 76void verify_root() { 77 failed |= test_root_output(); 78} 79 80void verify_foo() { 81 failed |= test_foo_output(); 82} 83 84void foreach_test() { 85 if (failed) { 86 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 87 } 88 else { 89 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 90 } 91} 92 93