Small test runner improvements (#3761)

* u16 for FunctionTest PARAMETRIZE

* Speed up CB2_TestRunner

* Use DACS to handle illegal instructions

DACS is available in mgba from 44e074a15e
This is not 0.10.2, but will presumably be available in the next
release. Alternatively, a GBA BIOS could be used.

---------

Co-authored-by: DizzyEggg <jajkodizzy@wp.pl>
Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
This commit is contained in:
Martin Griffin 2023-12-20 16:33:45 +00:00 committed by GitHub
parent 3b7782ed49
commit 3a5ca6f8f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 3 deletions

View File

@ -495,7 +495,7 @@ $(OBJ_DIR)/ld_script_test.ld: $(LD_SCRIPT_TEST) $(LD_SCRIPT_DEPS)
$(TESTELF): $(OBJ_DIR)/ld_script_test.ld $(OBJS) $(TEST_OBJS) libagbsyscall tools check-tools
@echo "cd $(OBJ_DIR) && $(LD) -T ld_script_test.ld -o ../../$@ <objects> <test-objects> <lib>"
@cd $(OBJ_DIR) && $(LD) $(TESTLDFLAGS) -T ld_script_test.ld -o ../../$@ $(OBJS_REL) $(TEST_OBJS_REL) $(LIB)
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) -d0 --silent
$(PATCHELF) $(TESTELF) gTestRunnerArgv "$(TESTS)\0"
ifeq ($(GITHUB_REPOSITORY_OWNER),rh-hideout)

View File

@ -59,8 +59,8 @@ extern const struct TestRunner gAssumptionsRunner;
struct FunctionTestRunnerState
{
u8 parameters;
u8 runParameter;
u16 parameters;
u16 runParameter;
};
extern const struct TestRunner gFunctionTestRunner;

View File

@ -109,6 +109,12 @@ SECTIONS {
__rom_end = .;
dacs 0x9FFC000 :
ALIGN(4)
{
test/*.o(.dacs);
} > ROM =0
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */

View File

@ -34,6 +34,8 @@ TEST("Form change tables contain only forms in the form species ID table")
for (i = 0; formChangeTable[i].method != FORM_CHANGE_TERMINATOR; i++)
{
if (formChangeTable[i].targetSpecies == SPECIES_NONE)
continue;
for (j = 0; formSpeciesIdTable[j] != FORM_SPECIES_END; j++)
{
if (formChangeTable[i].targetSpecies == formSpeciesIdTable[j])

View File

@ -106,6 +106,8 @@ static u32 AssignCostToRunner(void)
void CB2_TestRunner(void)
{
top:
switch (gTestRunnerState.state)
{
case STATE_INIT:
@ -361,6 +363,9 @@ void CB2_TestRunner(void)
MgbaExit_(gTestRunnerState.exitCode);
break;
}
if (gMain.callback2 == CB2_TestRunner)
goto top;
}
void Test_ExpectedResult(enum TestResult result)
@ -652,3 +657,25 @@ static s32 MgbaVPrintf_(const char *fmt, va_list va)
}
return i;
}
/* Entry point for the Debugging and Control System. Handles illegal
* instructions, which are typically caused by branching to an invalid
* address. */
__attribute__((naked, section(".dacs"), target("arm")))
void DACSEntry(void)
{
asm(".arm\n\
ldr r0, =(DACSHandle + 1)\n\
bx r0\n");
}
#define DACS_LR (*(vu32 *)0x3007FEC)
void DACSHandle(void)
{
if (gTestRunnerState.state == STATE_RUN_TEST)
gTestRunnerState.state = STATE_REPORT_RESULT;
gTestRunnerState.result = TEST_RESULT_CRASH;
ReinitCallbacks();
DACS_LR = ((uintptr_t)JumpToAgbMainLoop & ~1) + 4;
}