mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Fix test_runner.c modern warning (#3451)
This commit is contained in:
commit
4aabd09ab3
4
Makefile
4
Makefile
@ -85,7 +85,11 @@ ELF = $(ROM:.gba=.elf)
|
|||||||
MAP = $(ROM:.gba=.map)
|
MAP = $(ROM:.gba=.map)
|
||||||
SYM = $(ROM:.gba=.sym)
|
SYM = $(ROM:.gba=.sym)
|
||||||
|
|
||||||
|
ifeq ($(MODERN),0)
|
||||||
TEST_OBJ_DIR_NAME := build/test
|
TEST_OBJ_DIR_NAME := build/test
|
||||||
|
else
|
||||||
|
TEST_OBJ_DIR_NAME := build/modern-test
|
||||||
|
endif
|
||||||
TESTELF = $(ROM:.gba=-test.elf)
|
TESTELF = $(ROM:.gba=-test.elf)
|
||||||
HEADLESSELF = $(ROM:.gba=-test-headless.elf)
|
HEADLESSELF = $(ROM:.gba=-test-headless.elf)
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ struct TestRunnerState
|
|||||||
u8 expectedResult;
|
u8 expectedResult;
|
||||||
bool8 expectLeaks:1;
|
bool8 expectLeaks:1;
|
||||||
bool8 inBenchmark:1;
|
bool8 inBenchmark:1;
|
||||||
|
bool8 tearDown:1;
|
||||||
u32 timeoutSeconds;
|
u32 timeoutSeconds;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,9 +56,10 @@ static bool32 PrefixMatch(const char *pattern, const char *string)
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
STATE_INIT,
|
STATE_INIT,
|
||||||
STATE_NEXT_TEST,
|
STATE_ASSIGN_TEST,
|
||||||
STATE_RUN_TEST,
|
STATE_RUN_TEST,
|
||||||
STATE_REPORT_RESULT,
|
STATE_REPORT_RESULT,
|
||||||
|
STATE_NEXT_TEST,
|
||||||
STATE_EXIT,
|
STATE_EXIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -152,17 +153,15 @@ void CB2_TestRunner(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gTestRunnerState.state = STATE_NEXT_TEST;
|
gTestRunnerState.state = STATE_ASSIGN_TEST;
|
||||||
gTestRunnerState.test = __start_tests - 1;
|
gTestRunnerState.test = __start_tests;
|
||||||
}
|
}
|
||||||
gTestRunnerState.exitCode = 0;
|
gTestRunnerState.exitCode = 0;
|
||||||
gTestRunnerState.skipFilename = NULL;
|
gTestRunnerState.skipFilename = NULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_NEXT_TEST:
|
case STATE_ASSIGN_TEST:
|
||||||
gTestRunnerState.test++;
|
|
||||||
|
|
||||||
if (gTestRunnerState.test == __stop_tests)
|
if (gTestRunnerState.test == __stop_tests)
|
||||||
{
|
{
|
||||||
gTestRunnerState.state = STATE_EXIT;
|
gTestRunnerState.state = STATE_EXIT;
|
||||||
@ -172,6 +171,7 @@ void CB2_TestRunner(void)
|
|||||||
if (gTestRunnerState.test->runner != &gAssumptionsRunner
|
if (gTestRunnerState.test->runner != &gAssumptionsRunner
|
||||||
&& !PrefixMatch(gTestRunnerArgv, gTestRunnerState.test->name))
|
&& !PrefixMatch(gTestRunnerArgv, gTestRunnerState.test->name))
|
||||||
{
|
{
|
||||||
|
gTestRunnerState.state = STATE_NEXT_TEST;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +191,8 @@ void CB2_TestRunner(void)
|
|||||||
sCurrentTest.address = (uintptr_t)gTestRunnerState.test;
|
sCurrentTest.address = (uintptr_t)gTestRunnerState.test;
|
||||||
sCurrentTest.state = CURRENT_TEST_STATE_ESTIMATE;
|
sCurrentTest.state = CURRENT_TEST_STATE_ESTIMATE;
|
||||||
|
|
||||||
|
// If AssignCostToRunner fails, we want to report the failure.
|
||||||
|
gTestRunnerState.state = STATE_REPORT_RESULT;
|
||||||
if (AssignCostToRunner() == gTestRunnerI)
|
if (AssignCostToRunner() == gTestRunnerI)
|
||||||
gTestRunnerState.state = STATE_RUN_TEST;
|
gTestRunnerState.state = STATE_RUN_TEST;
|
||||||
else
|
else
|
||||||
@ -204,7 +206,10 @@ void CB2_TestRunner(void)
|
|||||||
SeedRng(0);
|
SeedRng(0);
|
||||||
SeedRng2(0);
|
SeedRng2(0);
|
||||||
if (gTestRunnerState.test->runner->setUp)
|
if (gTestRunnerState.test->runner->setUp)
|
||||||
|
{
|
||||||
gTestRunnerState.test->runner->setUp(gTestRunnerState.test->data);
|
gTestRunnerState.test->runner->setUp(gTestRunnerState.test->data);
|
||||||
|
gTestRunnerState.tearDown = TRUE;
|
||||||
|
}
|
||||||
// NOTE: Assumes that the compiler interns __FILE__.
|
// NOTE: Assumes that the compiler interns __FILE__.
|
||||||
if (gTestRunnerState.skipFilename == gTestRunnerState.test->filename) // Assumption fails for tests in this file.
|
if (gTestRunnerState.skipFilename == gTestRunnerState.test->filename) // Assumption fails for tests in this file.
|
||||||
{
|
{
|
||||||
@ -216,13 +221,17 @@ void CB2_TestRunner(void)
|
|||||||
gTestRunnerState.test->runner->run(gTestRunnerState.test->data);
|
gTestRunnerState.test->runner->run(gTestRunnerState.test->data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_REPORT_RESULT:
|
case STATE_REPORT_RESULT:
|
||||||
REG_TM2CNT_H = 0;
|
REG_TM2CNT_H = 0;
|
||||||
|
|
||||||
gTestRunnerState.state = STATE_NEXT_TEST;
|
gTestRunnerState.state = STATE_NEXT_TEST;
|
||||||
|
|
||||||
if (gTestRunnerState.test->runner->tearDown)
|
if (gTestRunnerState.tearDown && gTestRunnerState.test->runner->tearDown)
|
||||||
|
{
|
||||||
gTestRunnerState.test->runner->tearDown(gTestRunnerState.test->data);
|
gTestRunnerState.test->runner->tearDown(gTestRunnerState.test->data);
|
||||||
|
gTestRunnerState.tearDown = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (gTestRunnerState.result == TEST_RESULT_PASS
|
if (gTestRunnerState.result == TEST_RESULT_PASS
|
||||||
&& !gTestRunnerState.expectLeaks)
|
&& !gTestRunnerState.expectLeaks)
|
||||||
@ -342,6 +351,11 @@ void CB2_TestRunner(void)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case STATE_NEXT_TEST:
|
||||||
|
gTestRunnerState.state = STATE_ASSIGN_TEST;
|
||||||
|
gTestRunnerState.test++;
|
||||||
|
break;
|
||||||
|
|
||||||
case STATE_EXIT:
|
case STATE_EXIT:
|
||||||
MgbaExit_(gTestRunnerState.exitCode);
|
MgbaExit_(gTestRunnerState.exitCode);
|
||||||
break;
|
break;
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* parses the output to display human-readable progress.
|
* parses the output to display human-readable progress.
|
||||||
*
|
*
|
||||||
* Output lines starting with "GBA Debug: :" are parsed as commands to
|
* Output lines starting with "GBA Debug: :" are parsed as commands to
|
||||||
* Hydra, other output lines starting with "GBA Debug: " are parsed as
|
* Hydra, other output lines starting with "GBA Debug: " or with "GBA: "
|
||||||
* output from the current test, and any other lines are parsed as
|
* are parsed as output from the current test, and any other lines are
|
||||||
* output from the mgba-rom-test process itself.
|
* parsed as output from the mgba-rom-test process itself.
|
||||||
*
|
*
|
||||||
* COMMANDS
|
* COMMANDS
|
||||||
* N: Sets the test name to the remainder of the line.
|
* N: Sets the test name to the remainder of the line.
|
||||||
@ -75,10 +75,17 @@ static void handle_read(int i, struct Runner *runner)
|
|||||||
{
|
{
|
||||||
eol++;
|
eol++;
|
||||||
size_t n = eol - sol;
|
size_t n = eol - sol;
|
||||||
if (runner->input_buffer_size >= strlen("GBA Debug: ")
|
char *soc;
|
||||||
&& !strncmp(sol, "GBA Debug: ", strlen("GBA Debug: ")))
|
if (runner->input_buffer_size >= strlen("GBA: ")
|
||||||
|
&& !strncmp(sol, "GBA: ", strlen("GBA: ")))
|
||||||
{
|
{
|
||||||
char *soc = sol + strlen("GBA Debug: ");
|
soc = sol + strlen("GBA: ");
|
||||||
|
goto buffer_output;
|
||||||
|
}
|
||||||
|
else if (runner->input_buffer_size >= strlen("GBA Debug: ")
|
||||||
|
&& !strncmp(sol, "GBA Debug: ", strlen("GBA Debug: ")))
|
||||||
|
{
|
||||||
|
soc = sol + strlen("GBA Debug: ");
|
||||||
if (soc[0] == ':')
|
if (soc[0] == ':')
|
||||||
{
|
{
|
||||||
switch (soc[1])
|
switch (soc[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user