1#include "shared.rsh" 2 3rs_allocation aRaw; 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 int v = rsGetElementAt_int(aRaw, i, j); 25 _RS_ASSERT(v == (i + j * dimX)); 26 } 27 } 28 29 if (failed) { 30 rsDebug("test_root_output FAILED", 0); 31 } 32 else { 33 rsDebug("test_root_output PASSED", 0); 34 } 35 36 return failed; 37} 38 39static bool test_foo_output() { 40 bool failed = false; 41 int i, j; 42 43 for (j = 0; j < dimY; j++) { 44 for (i = 0; i < dimX; i++) { 45 int v = rsGetElementAt_int(aRaw, i, j); 46 _RS_ASSERT(v == (99 + i + j * dimX)); 47 } 48 } 49 50 if (failed) { 51 rsDebug("test_foo_output FAILED", 0); 52 } 53 else { 54 rsDebug("test_foo_output PASSED", 0); 55 } 56 57 return failed; 58} 59 60void verify_root() { 61 failed |= test_root_output(); 62} 63 64void verify_foo() { 65 failed |= test_foo_output(); 66} 67 68void foreach_test() { 69 if (failed) { 70 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 71 } 72 else { 73 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 74 } 75} 76 77