Made memory integrity checks run betweeen PARAMETRIZE runs (#6462)
Co-authored-by: Hedara <hedara90@gmail.com>
This commit is contained in:
parent
71a5542168
commit
b0c7d1a8ee
@ -20,6 +20,7 @@ void TestRunner_Battle_CheckAiMoveScores(u32 battlerId);
|
|||||||
void TestRunner_Battle_AISetScore(const char *file, u32 line, u32 battlerId, u32 moveIndex, s32 score);
|
void TestRunner_Battle_AISetScore(const char *file, u32 line, u32 battlerId, u32 moveIndex, s32 score);
|
||||||
void TestRunner_Battle_AIAdjustScore(const char *file, u32 line, u32 battlerId, u32 moveIndex, s32 score);
|
void TestRunner_Battle_AIAdjustScore(const char *file, u32 line, u32 battlerId, u32 moveIndex, s32 score);
|
||||||
void TestRunner_Battle_InvalidNoHPMon(u32 battlerId, u32 partyIndex);
|
void TestRunner_Battle_InvalidNoHPMon(u32 battlerId, u32 partyIndex);
|
||||||
|
void TestRunner_CheckMemory(void);
|
||||||
|
|
||||||
void TestRunner_Battle_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 actionType);
|
void TestRunner_Battle_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 actionType);
|
||||||
|
|
||||||
|
|||||||
@ -104,6 +104,62 @@ static u32 AssignCostToRunner(void)
|
|||||||
return minCostProcess;
|
return minCostProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestRunner_CheckMemory(void)
|
||||||
|
{
|
||||||
|
if (gTestRunnerState.result == TEST_RESULT_PASS
|
||||||
|
&& !gTestRunnerState.expectLeaks)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
const struct MemBlock *head = HeapHead();
|
||||||
|
const struct MemBlock *block = head;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (block->magic != MALLOC_SYSTEM_ID
|
||||||
|
|| !(EWRAM_START <= (uintptr_t)block->next && (uintptr_t)block->next < EWRAM_END)
|
||||||
|
|| (block->next <= block && block->next != head))
|
||||||
|
{
|
||||||
|
Test_MgbaPrintf("gHeap corrupted block at %p", block);
|
||||||
|
gTestRunnerState.result = TEST_RESULT_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block->allocated)
|
||||||
|
{
|
||||||
|
const char *location = MemBlockLocation(block);
|
||||||
|
if (location)
|
||||||
|
{
|
||||||
|
const char *cmpString = "src/generational_changes.c";
|
||||||
|
for (u32 charIndex = 0; charIndex < 26; charIndex++)
|
||||||
|
{
|
||||||
|
if (cmpString[charIndex] != location[charIndex])
|
||||||
|
{
|
||||||
|
Test_MgbaPrintf("%s: %d bytes not freed", location, block->size);
|
||||||
|
gTestRunnerState.result = TEST_RESULT_FAIL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Test_MgbaPrintf("<unknown>: %d bytes not freed", block->size);
|
||||||
|
gTestRunnerState.result = TEST_RESULT_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
block = block->next;
|
||||||
|
}
|
||||||
|
while (block != head);
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_TASKS; i++)
|
||||||
|
{
|
||||||
|
if (gTasks[i].isActive)
|
||||||
|
{
|
||||||
|
Test_MgbaPrintf(":L%s:%d - %p: task not freed", gTestRunnerState.test->filename, SourceLine(0), gTasks[i].func);
|
||||||
|
gTestRunnerState.result = TEST_RESULT_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CB2_TestRunner(void)
|
void CB2_TestRunner(void)
|
||||||
{
|
{
|
||||||
top:
|
top:
|
||||||
@ -242,45 +298,7 @@ top:
|
|||||||
gTestRunnerState.tearDown = FALSE;
|
gTestRunnerState.tearDown = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gTestRunnerState.result == TEST_RESULT_PASS
|
TestRunner_CheckMemory();
|
||||||
&& !gTestRunnerState.expectLeaks)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
const struct MemBlock *head = HeapHead();
|
|
||||||
const struct MemBlock *block = head;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (block->magic != MALLOC_SYSTEM_ID
|
|
||||||
|| !(EWRAM_START <= (uintptr_t)block->next && (uintptr_t)block->next < EWRAM_END)
|
|
||||||
|| (block->next <= block && block->next != head))
|
|
||||||
{
|
|
||||||
Test_MgbaPrintf("gHeap corrupted block at %p", block);
|
|
||||||
gTestRunnerState.result = TEST_RESULT_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (block->allocated)
|
|
||||||
{
|
|
||||||
const char *location = MemBlockLocation(block);
|
|
||||||
if (location)
|
|
||||||
Test_MgbaPrintf("%s: %d bytes not freed", location, block->size);
|
|
||||||
else
|
|
||||||
Test_MgbaPrintf("<unknown>: %d bytes not freed", block->size);
|
|
||||||
gTestRunnerState.result = TEST_RESULT_FAIL;
|
|
||||||
}
|
|
||||||
block = block->next;
|
|
||||||
}
|
|
||||||
while (block != head);
|
|
||||||
|
|
||||||
for (i = 0; i < NUM_TASKS; i++)
|
|
||||||
{
|
|
||||||
if (gTasks[i].isActive)
|
|
||||||
{
|
|
||||||
Test_MgbaPrintf(":L%s:%d - %p: task not freed", gTestRunnerState.test->filename, SourceLine(0), gTasks[i].func);
|
|
||||||
gTestRunnerState.result = TEST_RESULT_FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gTestRunnerState.test->runner == &gAssumptionsRunner)
|
if (gTestRunnerState.test->runner == &gAssumptionsRunner)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1347,6 +1347,7 @@ static void TearDownBattle(void)
|
|||||||
|
|
||||||
static void CB2_BattleTest_NextParameter(void)
|
static void CB2_BattleTest_NextParameter(void)
|
||||||
{
|
{
|
||||||
|
TestRunner_CheckMemory();
|
||||||
if (++STATE->runParameter >= STATE->parameters)
|
if (++STATE->runParameter >= STATE->parameters)
|
||||||
{
|
{
|
||||||
SetMainCallback2(CB2_TestRunner);
|
SetMainCallback2(CB2_TestRunner);
|
||||||
|
|||||||
@ -111,6 +111,8 @@ static const struct Symbol *lookup_address(uint32_t address)
|
|||||||
// available by default.
|
// available by default.
|
||||||
void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen)
|
void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen)
|
||||||
{
|
{
|
||||||
|
if (haystacklen < needlelen)
|
||||||
|
return NULL;
|
||||||
const char *haystack_ = haystack;
|
const char *haystack_ = haystack;
|
||||||
const char *needle_ = needle;
|
const char *needle_ = needle;
|
||||||
for (size_t i = 0; i < haystacklen - needlelen; i++)
|
for (size_t i = 0; i < haystacklen - needlelen; i++)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user