mirror of
https://github.com/JesseTG/melonds-ds.git
synced 2024-11-23 14:40:04 +00:00
Add a test for loading subsystems
This commit is contained in:
parent
0ea969271b
commit
8d3e41603f
2
.github/workflows/main.yaml
vendored
2
.github/workflows/main.yaml
vendored
@ -174,6 +174,8 @@ jobs:
|
||||
NDS_FIRMWARE: ${{ secrets.NDS_FIRMWARE }}
|
||||
DSI_FIRMWARE: ${{ secrets.DSI_FIRMWARE }}
|
||||
NDS_ROM: ${{ secrets.NDS_ROM }}
|
||||
GBA_ROM: ${{ secrets.GBA_ROM }}
|
||||
GBA_SRAM: ${{ secrets.GBA_SRAM }}
|
||||
|
||||
create-release:
|
||||
name: Create Release
|
||||
|
6
.github/workflows/test.yaml
vendored
6
.github/workflows/test.yaml
vendored
@ -20,6 +20,10 @@ on:
|
||||
required: true
|
||||
NDS_ROM:
|
||||
required: true
|
||||
GBA_ROM:
|
||||
required: true
|
||||
GBA_SRAM:
|
||||
required: true
|
||||
DSI_NAND_ARCHIVE:
|
||||
required: true
|
||||
DSI_NAND:
|
||||
@ -94,6 +98,8 @@ jobs:
|
||||
-DDSI_FIRMWARE="${{ env.TESTFILE_DIR }}/${{ secrets.DSI_FIRMWARE }}" \
|
||||
-DDSI_NAND="${{ env.TESTFILE_DIR }}/${{ secrets.DSI_NAND }}" \
|
||||
-DNDS_ROM="${{ env.TESTFILE_DIR }}/${{ secrets.NDS_ROM }}" \
|
||||
-DGBA_ROM="${{ env.TESTFILE_DIR }}/${{ secrets.GBA_ROM }}" \
|
||||
-DGBA_SRAM="${{ env.TESTFILE_DIR }}/${{ secrets.GBA_SRAM }}" \
|
||||
${{ inputs.cmake-args }}
|
||||
|
||||
- name: Run Test Suite (Linux)
|
||||
|
@ -22,6 +22,20 @@ else()
|
||||
message(DEBUG "NDS_ROM: ${NDS_ROM}")
|
||||
endif()
|
||||
|
||||
if (NOT GBA_ROM)
|
||||
message(WARNING "GBA_ROM must be set to the path of a GBA ROM")
|
||||
set(GBA_ROM "GBA_ROM-NOTFOUND" CACHE FILEPATH "Path to a GBA ROM" FORCE)
|
||||
else()
|
||||
message(DEBUG "GBA_ROM: ${GBA_ROM}")
|
||||
endif()
|
||||
|
||||
if (NOT GBA_SRAM)
|
||||
message(WARNING "GBA_SRAM must be set to the path of a GBA save file")
|
||||
set(GBA_SRAM "GBA_SRAM-NOTFOUND" CACHE FILEPATH "Path to a GBA save file" FORCE)
|
||||
else()
|
||||
message(DEBUG "GBA_SRAM: ${GBA_SRAM}")
|
||||
endif()
|
||||
|
||||
function(find_bios BIOS_NAME BIOS_FILE EXPECTED_BIOS_SIZES KNOWN_BIOS_HASHES)
|
||||
if (NOT ${BIOS_NAME})
|
||||
find_file(${BIOS_NAME} ${BIOS_FILE} REQUIRED)
|
||||
@ -88,6 +102,7 @@ function(add_python_test)
|
||||
set(oneValueArgs
|
||||
NAME
|
||||
SKIP_RETURN_CODE
|
||||
SUBSYSTEM
|
||||
TEST_MODULE
|
||||
TIMEOUT
|
||||
)
|
||||
@ -103,23 +118,50 @@ function(add_python_test)
|
||||
)
|
||||
cmake_parse_arguments(PARSE_ARGV 0 RETRO "${options}" "${oneValueArgs}" "${multiValueArgs}")
|
||||
|
||||
list(LENGTH RETRO_CONTENT RETRO_CONTENT_LENGTH)
|
||||
if (RETRO_CONTENT_LENGTH GREATER 0)
|
||||
list(GET RETRO_CONTENT 0 NDS_CONTENT)
|
||||
endif()
|
||||
|
||||
if (RETRO_CONTENT_LENGTH GREATER 1)
|
||||
list(GET RETRO_CONTENT 1 GBA_CONTENT)
|
||||
endif()
|
||||
|
||||
if (RETRO_CONTENT_LENGTH GREATER 2)
|
||||
list(GET RETRO_CONTENT 2 GBA_SRAM_CONTENT)
|
||||
endif()
|
||||
|
||||
add_test(
|
||||
NAME "${RETRO_NAME}"
|
||||
COMMAND ${Python_EXECUTABLE}
|
||||
-m "${RETRO_TEST_MODULE}"
|
||||
"$<TARGET_FILE:melondsds_libretro>"
|
||||
"${RETRO_CONTENT}"
|
||||
"${NDS_CONTENT}"
|
||||
"${GBA_CONTENT}"
|
||||
"${GBA_SRAM_CONTENT}"
|
||||
)
|
||||
|
||||
list(APPEND REQUIRED_FILES "$<TARGET_FILE:melondsds_libretro>")
|
||||
if (RETRO_CONTENT)
|
||||
list(APPEND REQUIRED_FILES "${RETRO_CONTENT}")
|
||||
if (NDS_CONTENT)
|
||||
list(APPEND REQUIRED_FILES "${NDS_CONTENT}")
|
||||
endif()
|
||||
|
||||
if (GBA_CONTENT)
|
||||
list(APPEND REQUIRED_FILES "${GBA_CONTENT}")
|
||||
endif()
|
||||
|
||||
if (GBA_SRAM_CONTENT)
|
||||
list(APPEND REQUIRED_FILES "${GBA_SRAM_CONTENT}")
|
||||
endif()
|
||||
|
||||
if (NOT RETRO_NO_SKIP_ERROR_SCREEN)
|
||||
list(APPEND ENVIRONMENT MELONDSDS_SKIP_ERROR_SCREEN=1)
|
||||
endif()
|
||||
|
||||
if (RETRO_SUBSYSTEM)
|
||||
list(APPEND ENVIRONMENT SUBSYSTEM=${RETRO_SUBSYSTEM})
|
||||
endif()
|
||||
|
||||
list(APPEND ENVIRONMENT ${RETRO_CORE_OPTION}) # Not an omission, this is already a list
|
||||
|
||||
macro(expose_system_file SYSFILE)
|
||||
|
@ -230,9 +230,12 @@ add_python_test(
|
||||
|
||||
add_python_test(
|
||||
NAME "Core loads and unloads with subsystem content"
|
||||
TEST_MODULE ""
|
||||
DISABLED
|
||||
) # TODO: Implement this test
|
||||
TEST_MODULE basics.core_loads_subsystems
|
||||
SUBSYSTEM gba
|
||||
CONTENT "${NDS_ROM}"
|
||||
CONTENT "${GBA_ROM}"
|
||||
CONTENT "${GBA_SRAM}"
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
NAME "Core defines controller info"
|
||||
|
40
test/python/basics/core_loads_subsystems.py
Normal file
40
test/python/basics/core_loads_subsystems.py
Normal file
@ -0,0 +1,40 @@
|
||||
from ctypes import CFUNCTYPE, c_bool, c_size_t, c_uint8, c_size_t, POINTER
|
||||
|
||||
from libretro import Session
|
||||
|
||||
import prelude
|
||||
|
||||
assert prelude.subsystem is not None
|
||||
|
||||
session: Session
|
||||
with prelude.session() as session:
|
||||
subsystems = session.subsystems
|
||||
|
||||
assert subsystems is not None
|
||||
subsystem: bytes = prelude.subsystem.encode()
|
||||
idents = [bytes(s.ident) for s in subsystems]
|
||||
assert subsystem in idents, f"Subsystem {subsystem} not found in {idents}"
|
||||
|
||||
proc_address_callback = session.proc_address_callback
|
||||
assert proc_address_callback is not None
|
||||
assert proc_address_callback.get_proc_address is not None
|
||||
|
||||
gba_rom_length = session.get_proc_address(b"melondsds_gba_rom_length", CFUNCTYPE(c_size_t))
|
||||
assert gba_rom_length is not None, "Core needs to define melondsds_gba_rom_length"
|
||||
assert gba_rom_length() > 0, "GBA ROM not installed"
|
||||
|
||||
gba_rom = session.get_proc_address(b"melondsds_gba_rom", CFUNCTYPE(POINTER(c_uint8)))
|
||||
assert gba_rom is not None, "Core needs to define melondsds_gba_rom"
|
||||
|
||||
rom = gba_rom()
|
||||
assert rom, "GBA ROM not loaded"
|
||||
|
||||
gba_sram_length = session.get_proc_address(b"melondsds_gba_sram_length", CFUNCTYPE(c_size_t))
|
||||
assert gba_sram_length is not None, "Core needs to define melondsds_gba_sram_length"
|
||||
assert gba_sram_length() > 0, "GBA SRAM not installed"
|
||||
|
||||
gba_sram = session.get_proc_address(b"melondsds_gba_sram", CFUNCTYPE(POINTER(c_uint8)))
|
||||
assert gba_sram is not None, "Core needs to define melondsds_gba_sram"
|
||||
|
||||
sram = gba_sram()
|
||||
assert sram, "GBA SRAM not loaded"
|
@ -4,6 +4,7 @@ import sys
|
||||
import tempfile
|
||||
|
||||
import libretro
|
||||
from libretro.api.content import SubsystemContent
|
||||
|
||||
if not __debug__:
|
||||
raise RuntimeError("The melonDS DS test suite should not be run with -O")
|
||||
@ -37,8 +38,10 @@ for _f in SYSTEM_FILES:
|
||||
shutil.copyfile(os.environ[_f], targetpath)
|
||||
|
||||
options_string = os.getenv("RETRO_CORE_OPTIONS")
|
||||
subsystem = os.getenv("SUBSYSTEM")
|
||||
core_path = sys.argv[1]
|
||||
content_path = sys.argv[2] if len(sys.argv) > 2 and len(sys.argv[2]) > 0 else None
|
||||
content_path = sys.argv[2] if len(sys.argv) > 2 and sys.argv[2] else None
|
||||
content_paths = tuple(s for s in sys.argv[2:] if s) if len(sys.argv) > 2 else ()
|
||||
|
||||
options = {
|
||||
k.lower().encode(): v.encode()
|
||||
@ -53,7 +56,18 @@ default_args = {
|
||||
|
||||
|
||||
def session(**kwargs) -> libretro.Session:
|
||||
return libretro.default_session(core_path, content_path, **(default_args | kwargs))
|
||||
content = None
|
||||
match content_paths:
|
||||
case [] | None:
|
||||
pass
|
||||
case [path]:
|
||||
content = path
|
||||
case [*paths]:
|
||||
content = SubsystemContent(subsystem, paths)
|
||||
case _:
|
||||
raise TypeError(f"Unexpected content_paths {type(content_paths).__name__}")
|
||||
|
||||
return libretro.default_session(core_path, content, **(default_args | kwargs))
|
||||
|
||||
|
||||
def noload_session(**kwargs) -> libretro.Session:
|
||||
|
Loading…
Reference in New Issue
Block a user