| 217 | struct Test_testDepthOverflow : TestQueue |
| 218 | { |
| 219 | virtual void Run() |
| 220 | { |
| 221 | char *stackMem = new char[32*1024]; |
| 222 | nullcSetJiTStack(stackMem, stackMem + 32*1024, true); |
| 223 | if(Tests::messageVerbose) |
| 224 | printf("Call depth test\r\n"); |
| 225 | { |
| 226 | testsCount[1]++; |
| 227 | nullcSetExecutor(NULLC_X86); |
| 228 | nullres good = nullcBuild(testDepthOverflow); |
| 229 | assert(good); |
| 230 | good = nullcRun(); |
| 231 | if(!good) |
| 232 | { |
| 233 | const char *error = "ERROR: allocated stack overflow"; |
| 234 | char buf[512]; |
| 235 | strcpy(buf, strstr(nullcGetLastError(), "ERROR:")); |
| 236 | if(char *lineEnd = strchr(buf, '\r')) |
| 237 | *lineEnd = 0; |
| 238 | if(strcmp(error, buf) != 0) |
| 239 | { |
| 240 | if(!Tests::messageVerbose) |
| 241 | printf("Call depth test\r\n"); |
| 242 | printf("X86 failed but for wrong reason:\r\n %s\r\nexpected:\r\n %s\r\n", buf, error); |
| 243 | }else{ |
| 244 | testsPassed[1]++; |
| 245 | } |
| 246 | }else{ |
| 247 | if(!Tests::messageVerbose) |
| 248 | printf("Call depth test\r\n"); |
| 249 | printf("Test should have failed.\r\n"); |
| 250 | } |
| 251 | } |
| 252 | nullcSetJiTStack((void*)0x20000000, NULL, false); |
| 253 | delete[] stackMem; |
| 254 | } |
| 255 | }; |
| 256 | Test_testDepthOverflow test_testDepthOverflow; |
| 257 |
nothing calls this directly
no test coverage detected