diff --git a/AutomatedTests/CMakeLists.txt b/AutomatedTests/CMakeLists.txt index 957b25280a..3e670a38a0 100644 --- a/AutomatedTests/CMakeLists.txt +++ b/AutomatedTests/CMakeLists.txt @@ -75,6 +75,10 @@ if(CMAKE_SYSTEM_NAME MATCHES Retro68) LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/Segments.segmap") add_test(NAME ${TESTCASE_PREFIX}Segments COMMAND ${LAUNCH_APPL} ${LAUNCH_METHOD_FLAG} ${RETRO68_TEST_CONFIG} Segments.bin) + + + test(PCRel32.c PROPERTIES PASS_REGULAR_EXPRESSION "OK") + target_compile_options(PCRel32 PRIVATE -march=68020) endif() test(Exceptions.cc PROPERTIES PASS_REGULAR_EXPRESSION "OK") diff --git a/AutomatedTests/PCRel32.c b/AutomatedTests/PCRel32.c new file mode 100644 index 0000000000..3e040fad4f --- /dev/null +++ b/AutomatedTests/PCRel32.c @@ -0,0 +1,29 @@ +#include "Test.h" +#include + +__attribute__((noinline)) static void* foo(size_t x) +{ + return malloc(x); +} + +int main() +{ + if(*(short*)&foo != 0x60FF) + { + TEST_LOG_NO(); + return 0; + } + + uint32_t offset = *(uint32_t*) ((char*)&foo + 2); + if(((char*)&foo + 2) + offset != (char*)&malloc) + { + TEST_LOG_NO(); + return 0; + } + + char *p = foo(42); + strcpy(p, "OK"); + TestLog(p); + free(p); + return 0; +} diff --git a/AutomatedTests/Test.h b/AutomatedTests/Test.h index ad84002808..05cd052d99 100644 --- a/AutomatedTests/Test.h +++ b/AutomatedTests/Test.h @@ -87,8 +87,8 @@ void TestLog(const char *str); #define TEST_LOG_NO() \ do { \ char no[3]; \ - no[0] = 'O'; \ - no[1] = 'K'; \ + no[0] = 'N'; \ + no[1] = 'O'; \ no[2] = '\0'; \ TEST_LOG_SIZED(no, 2); \ } while(0)