Rename MgbaPrintf_ to Test_MgbaPrintf (#4642)

This commit is contained in:
Bassoonian 2024-05-31 17:54:25 +02:00 committed by GitHub
parent e869aaf70b
commit e3959a764b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 31 deletions

View File

@ -92,9 +92,9 @@ void *AllocInternal(void *heapStart, u32 size, const char *location)
{
const char *location = MemBlockLocation(block);
if (location)
MgbaPrintf_("%s: %d bytes allocated", location, block->size);
Test_MgbaPrintf("%s: %d bytes allocated", location, block->size);
else
MgbaPrintf_("<unknown>: %d bytes allocated", block->size);
Test_MgbaPrintf("<unknown>: %d bytes allocated", block->size);
}
block = block->next;
}

View File

@ -75,7 +75,7 @@ void Test_ExpectedResult(enum TestResult);
void Test_ExpectLeaks(bool32);
void Test_ExitWithResult(enum TestResult, const char *fmt, ...);
s32 MgbaPrintf_(const char *fmt, ...);
s32 Test_MgbaPrintf(const char *fmt, ...);
#define TEST(_name) \
static void CAT(Test, __LINE__)(void); \
@ -193,7 +193,7 @@ static inline struct Benchmark BenchmarkStop(void)
do \
{ \
u32 a_ = (a).ticks; u32 b_ = (b).ticks; \
MgbaPrintf_(#a ": %d ticks, " #b ": %d ticks", a_, b_); \
Test_MgbaPrintf(#a ": %d ticks, " #b ": %d ticks", a_, b_); \
if (((a_ - BENCHMARK_ABS) * BENCHMARK_REL) >= (b_ * 100)) \
Test_ExitWithResult(TEST_RESULT_FAIL, "%s:%d: EXPECT_FASTER(" #a ", " #b ") failed", gTestRunnerState.test->filename, __LINE__); \
} while (0)
@ -202,7 +202,7 @@ static inline struct Benchmark BenchmarkStop(void)
do \
{ \
u32 a_ = (a).ticks; u32 b_ = (b).ticks; \
MgbaPrintf_(#a ": %d ticks, " #b ": %d ticks", a_, b_); \
Test_MgbaPrintf(#a ": %d ticks, " #b ": %d ticks", a_, b_); \
if ((a_ * 100) <= ((b_ - BENCHMARK_ABS) * BENCHMARK_REL)) \
Test_ExitWithResult(TEST_RESULT_FAIL, "%s:%d: EXPECT_SLOWER(" #a ", " #b ") failed", gTestRunnerState.test->filename, __LINE__); \
} while (0)
@ -215,7 +215,7 @@ static inline struct Benchmark BenchmarkStop(void)
#define PARAMETRIZE if (gFunctionTestRunnerState->parameters++ == gFunctionTestRunnerState->runParameter)
#define PARAMETRIZE_LABEL(f, label) if (gFunctionTestRunnerState->parameters++ == gFunctionTestRunnerState->runParameter && (MgbaPrintf_(":N%s: " f " (%d/%d)", gTestRunnerState.test->name, label, gFunctionTestRunnerState->runParameter + 1, gFunctionTestRunnerState->parameters), 1))
#define PARAMETRIZE_LABEL(f, label) if (gFunctionTestRunnerState->parameters++ == gFunctionTestRunnerState->runParameter && (Test_MgbaPrintf(":N%s: " f " (%d/%d)", gTestRunnerState.test->name, label, gFunctionTestRunnerState->runParameter + 1, gFunctionTestRunnerState->parameters), 1))
#define TO_DO \
do { \

View File

@ -3156,7 +3156,7 @@ static s32 AI_CompareDamagingMoves(u32 battlerAtk, u32 battlerDef, u32 currId)
isTwoTurnNotSemiInvulnerableMove[i] = FALSE;
}
/*
MgbaPrintf_("%S: required hits: %d Dmg: %d", gMoveNames[moves[i]], noOfHits[i], AI_DATA->simulatedDmg[battlerAtk][battlerDef][i]);
Test_MgbaPrintf("%S: required hits: %d Dmg: %d", gMoveNames[moves[i]], noOfHits[i], AI_DATA->simulatedDmg[battlerAtk][battlerDef][i]);
*/
}

View File

@ -180,7 +180,7 @@ top:
break;
}
MgbaPrintf_(":N%s", gTestRunnerState.test->name);
Test_MgbaPrintf(":N%s", gTestRunnerState.test->name);
gTestRunnerState.result = TEST_RESULT_PASS;
gTestRunnerState.expectedResult = TEST_RESULT_PASS;
gTestRunnerState.expectLeaks = FALSE;
@ -249,7 +249,7 @@ top:
|| !(EWRAM_START <= (uintptr_t)block->next && (uintptr_t)block->next < EWRAM_END)
|| (block->next <= block && block->next != head))
{
MgbaPrintf_("gHeap corrupted block at 0x%p", block);
Test_MgbaPrintf("gHeap corrupted block at 0x%p", block);
gTestRunnerState.result = TEST_RESULT_ERROR;
break;
}
@ -258,9 +258,9 @@ top:
{
const char *location = MemBlockLocation(block);
if (location)
MgbaPrintf_("%s: %d bytes not freed", location, block->size);
Test_MgbaPrintf("%s: %d bytes not freed", location, block->size);
else
MgbaPrintf_("<unknown>: %d bytes not freed", block->size);
Test_MgbaPrintf("<unknown>: %d bytes not freed", block->size);
gTestRunnerState.result = TEST_RESULT_FAIL;
}
block = block->next;
@ -283,7 +283,7 @@ top:
if (gTestRunnerState.result == gTestRunnerState.expectedResult)
{
color = "\e[32m";
MgbaPrintf_(":N%s", gTestRunnerState.test->name);
Test_MgbaPrintf(":N%s", gTestRunnerState.test->name);
}
else if (gTestRunnerState.result != TEST_RESULT_ASSUMPTION_FAIL || gTestRunnerSkipIsFail)
{
@ -342,18 +342,18 @@ top:
if (gTestRunnerState.result == TEST_RESULT_PASS)
{
if (gTestRunnerState.result != gTestRunnerState.expectedResult)
MgbaPrintf_(":U%s%s\e[0m", color, result);
Test_MgbaPrintf(":U%s%s\e[0m", color, result);
else
MgbaPrintf_(":P%s%s\e[0m", color, result);
Test_MgbaPrintf(":P%s%s\e[0m", color, result);
}
else if (gTestRunnerState.result == TEST_RESULT_ASSUMPTION_FAIL)
MgbaPrintf_(":A%s%s\e[0m", color, result);
Test_MgbaPrintf(":A%s%s\e[0m", color, result);
else if (gTestRunnerState.result == TEST_RESULT_TODO)
MgbaPrintf_(":T%s%s\e[0m", color, result);
Test_MgbaPrintf(":T%s%s\e[0m", color, result);
else if (gTestRunnerState.expectedResult == gTestRunnerState.result)
MgbaPrintf_(":K%s%s\e[0m", color, result);
Test_MgbaPrintf(":K%s%s\e[0m", color, result);
else
MgbaPrintf_(":F%s%s\e[0m", color, result);
Test_MgbaPrintf(":F%s%s\e[0m", color, result);
}
break;
@ -395,7 +395,7 @@ static void FunctionTest_Run(void *data)
do
{
if (gFunctionTestRunnerState->parameters)
MgbaPrintf_(":N%s %d/%d", gTestRunnerState.test->name, gFunctionTestRunnerState->runParameter + 1, gFunctionTestRunnerState->parameters);
Test_MgbaPrintf(":N%s %d/%d", gTestRunnerState.test->name, gFunctionTestRunnerState->runParameter + 1, gFunctionTestRunnerState->parameters);
gFunctionTestRunnerState->parameters = 0;
function();
} while (++gFunctionTestRunnerState->runParameter < gFunctionTestRunnerState->parameters);
@ -517,7 +517,7 @@ static void MgbaExit_(u8 exitCode)
asm("swi 0x3" :: "r" (_exitCode));
}
s32 MgbaPrintf_(const char *fmt, ...)
s32 Test_MgbaPrintf(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);

View File

@ -208,20 +208,20 @@ static void PrintTestName(void)
if (STATE->trials && STATE->parameters)
{
if (STATE->trials == 1)
MgbaPrintf_(":N%s %d/%d (%d/?)", gTestRunnerState.test->name, STATE->runParameter + 1, STATE->parameters, STATE->runTrial + 1);
Test_MgbaPrintf(":N%s %d/%d (%d/?)", gTestRunnerState.test->name, STATE->runParameter + 1, STATE->parameters, STATE->runTrial + 1);
else
MgbaPrintf_(":N%s %d/%d (%d/%d)", gTestRunnerState.test->name, STATE->runParameter + 1, STATE->parameters, STATE->runTrial + 1, STATE->trials);
Test_MgbaPrintf(":N%s %d/%d (%d/%d)", gTestRunnerState.test->name, STATE->runParameter + 1, STATE->parameters, STATE->runTrial + 1, STATE->trials);
}
else if (STATE->trials)
{
if (STATE->trials == 1)
MgbaPrintf_(":N%s (%d/?)", gTestRunnerState.test->name, STATE->runTrial + 1);
Test_MgbaPrintf(":N%s (%d/?)", gTestRunnerState.test->name, STATE->runTrial + 1);
else
MgbaPrintf_(":N%s (%d/%d)", gTestRunnerState.test->name, STATE->runTrial + 1, STATE->trials);
Test_MgbaPrintf(":N%s (%d/%d)", gTestRunnerState.test->name, STATE->runTrial + 1, STATE->trials);
}
else if (STATE->parameters)
{
MgbaPrintf_(":N%s %d/%d", gTestRunnerState.test->name, STATE->runParameter + 1, STATE->parameters);
Test_MgbaPrintf(":N%s %d/%d", gTestRunnerState.test->name, STATE->runParameter + 1, STATE->parameters);
}
}
@ -956,7 +956,7 @@ static void PrintAiMoveLog(u32 battlerId, u32 moveSlot, u32 moveId, s32 totalSco
if (DATA.aiLogPrintedForMove[battlerId] & gBitTable[moveSlot]) return;
DATA.aiLogPrintedForMove[battlerId] |= gBitTable[moveSlot];
MgbaPrintf_("Score Log for move %S:\n", GetMoveName(moveId));
Test_MgbaPrintf("Score Log for move %S:\n", GetMoveName(moveId));
for (i = 0; i < MAX_AI_LOG_LINES; i++)
{
struct AILogLine *log = &DATA.aiLogLines[battlerId][moveSlot][i];
@ -965,17 +965,17 @@ static void PrintAiMoveLog(u32 battlerId, u32 moveSlot, u32 moveId, s32 totalSco
if (log->set)
{
scoreFromLogs = log->score;
MgbaPrintf_("%s:%d: = %d\n", log->file, log->line, log->score);
Test_MgbaPrintf("%s:%d: = %d\n", log->file, log->line, log->score);
}
else if (log->score > 0)
{
scoreFromLogs += log->score;
MgbaPrintf_("%s:%d: +%d\n", log->file, log->line, log->score);
Test_MgbaPrintf("%s:%d: +%d\n", log->file, log->line, log->score);
}
else
{
scoreFromLogs += log->score;
MgbaPrintf_("%s:%d: %d\n", log->file, log->line, log->score);
Test_MgbaPrintf("%s:%d: %d\n", log->file, log->line, log->score);
}
}
else
@ -987,7 +987,7 @@ static void PrintAiMoveLog(u32 battlerId, u32 moveSlot, u32 moveId, s32 totalSco
{
Test_ExitWithResult(TEST_RESULT_ERROR, "Warning! Score from logs(%d) is different than actual score(%d). Make sure all of the score adjustments use the ADJUST_SCORE macro\n", scoreFromLogs, totalScore);
}
MgbaPrintf_("Total: %d\n", totalScore);
Test_MgbaPrintf("Total: %d\n", totalScore);
}
static void ClearAiLog(u32 battlerId)
@ -1163,7 +1163,7 @@ static s32 TryMessage(s32 i, s32 n, const u8 *string)
continue;
event = &DATA.queuedEvents[i].as.message;
// MgbaPrintf_("Looking for: %S Found: %S\n", event->pattern, string); // Useful for debugging.
// Test_MgbaPrintf("Looking for: %S Found: %S\n", event->pattern, string); // Useful for debugging.
for (j = k = 0; ; j++, k++)
{
if (event->pattern[k] == CHAR_SPACE)