mirror of
https://github.com/autc04/Retro68.git
synced 2024-10-05 04:55:29 +00:00
add test cases for r_68k_pc32
This commit is contained in:
parent
5fdd7b411f
commit
0b120a722e
@ -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
29
AutomatedTests/PCRel32.c
Normal 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;
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user