foreach_bounds.rs revision 025b5f82971c431eb22df3c9d0f00b3cbe426bdb
1#include "shared.rsh"
2
3int dimX;
4int dimY;
5int xStart = 0;
6int xEnd = 0;
7int yStart = 0;
8int yEnd = 0;
9
10static bool failed = false;
11
12rs_script s;
13rs_allocation aRaw;
14rs_allocation ain;
15rs_allocation aout;
16
17void root(int *out, uint32_t x, uint32_t y) {
18    *out = x + y * dimX;
19}
20
21int RS_KERNEL zero() {
22    return 0;
23}
24
25static bool test_root_output() {
26    bool failed = false;
27    int i, j;
28
29    for (j = 0; j < dimY; j++) {
30        for (i = 0; i < dimX; i++) {
31            int v = rsGetElementAt_int(aRaw, i, j);
32            if (i < xStart || i >= xEnd || j < yStart || j >= yEnd) {
33                _RS_ASSERT(v == 0);
34            } else {
35                _RS_ASSERT(v == (i + j * dimX));
36            }
37        }
38    }
39
40    if (failed) {
41        rsDebug("test_root_output FAILED", 0);
42    }
43    else {
44        rsDebug("test_root_output PASSED", 0);
45    }
46
47    return failed;
48}
49
50void verify_root() {
51    failed |= test_root_output();
52}
53
54void foreach_bounds_test() {
55    if (failed) {
56        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
57    }
58    else {
59        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
60    }
61}
62
63