add test cases for r_68k_pc32

This commit is contained in:
Wolfgang Thaller 2020-12-28 19:35:51 +01:00
parent 5fdd7b411f
commit 0b120a722e
3 changed files with 35 additions and 2 deletions

View File

@ -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")

29
AutomatedTests/PCRel32.c Normal file
View File

@ -0,0 +1,29 @@
#include "Test.h"
#include <stdlib.h>
__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;
}

View File

@ -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)