1// This file is automatically generated from 2// frameworks/rs/tests/java_api/RSUnitTests/RSUnitTests.py 3/* 4 * Copyright (C) 2017 The Android Open Source Project 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19#include "shared.rsh" 20 21rs_allocation A; 22rs_allocation B; 23uint32_t gDimX, gDimY; 24static bool failed = false; 25 26void init_vars(int *out) { 27 *out = 7; 28} 29 30int RS_KERNEL root(int ain, rs_kernel_context context, uint32_t x, uint32_t y) { 31 if (!_RS_ASSERT_EQU(ain, 7)) 32 rsDebug("root at x, y", x, y); 33 uint32_t dimX = rsGetDimX(context); 34 uint32_t dimY = rsGetDimY(context); 35 _RS_ASSERT_EQU(dimX, gDimX); 36 _RS_ASSERT_EQU(dimY, gDimY); 37 return ain + x + dimX * y; 38} 39 40static bool test_root_output() { 41 bool failed = false; 42 int i, j; 43 44 for (i = 0; i < gDimX; i++) { 45 for (j = 0; j < gDimY; j++) { 46 int bElt = rsGetElementAt_int(B, i, j); 47 int aElt = rsGetElementAt_int(A, i, j); 48 if (!_RS_ASSERT_EQU(bElt, (aElt + i + gDimX * j))) 49 rsDebug("test_root_output at i, j", i, j); 50 } 51 } 52 53 if (failed) { 54 rsDebug("kernel2d test_root_output FAILED", 0); 55 } 56 else { 57 rsDebug("kernel2d test_root_output PASSED", 0); 58 } 59 60 return failed; 61} 62 63void verify_root() { 64 failed |= test_root_output(); 65} 66 67void kernel_test() { 68 if (failed) { 69 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 70 } 71 else { 72 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 73 } 74} 75