1 #include "shared.rsh" 2 3 int *a; 4 int dimX; 5 int dimY; 6 static bool failed = false; 7 8 void root(int *out, uint32_t x, uint32_t y) { 9 *out = x + y * dimX; 10 } 11 12 void 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 18 static 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 38 static 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 58 void verify_root() { 59 failed |= test_root_output(); 60 } 61 62 void verify_foo() { 63 failed |= test_foo_output(); 64 } 65 66 void foreach_test() { 67 if (failed) { 68 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 69 } 70 else { 71 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 72 } 73 } 74 75