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
21struct simpleStruct {
22    int i1;
23    char ignored1;
24    float f1;
25    int i2;
26    char ignored2;
27    float f2;
28};
29
30struct simpleStruct *ain;
31struct simpleStruct *aout;
32int dimX;
33static bool failed = false;
34
35void init_vars(struct simpleStruct *out, uint32_t x) {
36    out->i1 = 0;
37    out->f1 = 0.f;
38    out->i2 = 1;
39    out->f2 = 1.0f;
40}
41
42struct simpleStruct RS_KERNEL
43        root(struct simpleStruct in, uint32_t x) {
44    struct simpleStruct s;
45    s.i1 = in.i1 + x;
46    s.f1 = in.f1 + x;
47    s.i2 = in.i2 + x;
48    s.f2 = in.f2 + x;
49    return s;
50}
51
52static bool test_root_output() {
53    bool failed = false;
54    int i;
55
56    for (i = 0; i < dimX; i++) {
57        _RS_ASSERT(aout[i].i1 == (i + ain[i].i1));
58        _RS_ASSERT(aout[i].f1 == (i + ain[i].f1));
59        _RS_ASSERT(aout[i].i2 == (i + ain[i].i2));
60        _RS_ASSERT(aout[i].f2 == (i + ain[i].f2));
61    }
62
63    if (failed) {
64        rsDebug("test_root_output FAILED", 0);
65    }
66    else {
67        rsDebug("test_root_output PASSED", 0);
68    }
69
70    return failed;
71}
72
73void verify_root() {
74    failed |= test_root_output();
75}
76
77void kernel_struct_test() {
78    if (failed) {
79        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
80    }
81    else {
82        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
83    }
84}
85