1#include "shared.rsh"
2
3int *a;
4int dimX;
5int dimY;
6static bool failed = false;
7
8void root(int *out, uint32_t x, uint32_t y) {
9    *out = x + y * dimX;
10}
11
12void foo(const int *in, int *out, uint32_t x, uint32_t y) {
13    _RS_ASSERT(*in == (x + y * dimX));
14    *out = 99 + x + y * dimX;
15    _RS_ASSERT(*out == (99 + x + y * dimX));
16}
17
18static bool test_root_output() {
19    bool failed = false;
20    int i, j;
21
22    for (j = 0; j < dimY; j++) {
23        for (i = 0; i < dimX; i++) {
24            _RS_ASSERT(a[i + j * dimX] == (i + j * dimX));
25        }
26    }
27
28    if (failed) {
29        rsDebug("test_root_output FAILED", 0);
30    }
31    else {
32        rsDebug("test_root_output PASSED", 0);
33    }
34
35    return failed;
36}
37
38static bool test_foo_output() {
39    bool failed = false;
40    int i, j;
41
42    for (j = 0; j < dimY; j++) {
43        for (i = 0; i < dimX; i++) {
44            _RS_ASSERT(a[i + j * dimX] == (99 + i + j * dimX));
45        }
46    }
47
48    if (failed) {
49        rsDebug("test_foo_output FAILED", 0);
50    }
51    else {
52        rsDebug("test_foo_output PASSED", 0);
53    }
54
55    return failed;
56}
57
58void verify_root() {
59    failed |= test_root_output();
60}
61
62void verify_foo() {
63    failed |= test_foo_output();
64}
65
66void foreach_test() {
67    if (failed) {
68        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
69    }
70    else {
71        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
72    }
73}
74
75