Implement a shutdown test, mostly

This commit is contained in:
Jesse Talavera 2024-03-14 15:59:13 -04:00
parent c170081201
commit eae3532bb6
2 changed files with 49 additions and 2 deletions

View File

@ -137,8 +137,13 @@ add_python_test(
)
add_python_test(
NAME "Core can shut down internally"
TEST_MODULE ""
NAME "Core can shut down"
TEST_MODULE basics.core_can_shut_down
NDS_SYSFILES
TIMEOUT 30
DISABLED
# Failure is expected, as the frontend will shut down
# (But segfaults or timeouts are still actual failures)
)
add_python_test(

View File

@ -0,0 +1,42 @@
import itertools
from typing import cast
from libretro import Session
from libretro.api.input import DeviceIdJoypad
from libretro.api.video import SoftwareVideoState
import prelude
def generate_input():
# Wait for intro to finish
yield from itertools.repeat(None, 240)
# Go to NDS main menu and wait for it to appear
yield DeviceIdJoypad.A
yield from itertools.repeat(None, 59)
# Select the options menu and wait for the cursor to move
yield DeviceIdJoypad.DOWN
yield from itertools.repeat(None, 29)
# Go to the options menu and wait for it to appear
yield DeviceIdJoypad.A
yield from itertools.repeat(None, 179)
# Exit the options menu and wait for the window to appear
yield DeviceIdJoypad.B
yield from itertools.repeat(None, 29)
# Confirm the exit (exiting the NDS options menu shuts down the console)
yield DeviceIdJoypad.A
yield from itertools.repeat(None)
session: Session
with prelude.session(input_state=generate_input) as session:
video = cast(SoftwareVideoState, session.video)
for i in range(600):
session.core.run()
assert session.is_shutdown