Migrate more tests to libretro.py

This commit is contained in:
Jesse Talavera 2024-03-21 17:06:18 -04:00
parent f225eb2a55
commit ccff012b1a
7 changed files with 66 additions and 62 deletions

View File

@ -1,68 +1,68 @@
add_emutest_test(
add_python_test(
NAME "Homebrew SD card image is not created if loading a retail ROM"
CONTENT "${NDS_ROM}"
TEST_SCRIPT "homebrew-sdcard-exists.lua"
CORE_OPTION melonds_console_mode="ds"
CORE_OPTION melonds_homebrew_sdcard="enabled"
CORE_OPTION melonds_homebrew_sync_sdcard_to_host="disabled"
TEST_MODULE save.homebrew_sd_card_exists
CORE_OPTION "melonds_console_mode=ds"
CORE_OPTION "melonds_homebrew_sdcard=enabled"
CORE_OPTION "melonds_homebrew_sync_sdcard_to_host=disabled"
WILL_FAIL
)
add_emutest_test(
add_python_test(
NAME "Homebrew SD card image is not created if disabled and loading a retail ROM"
CONTENT "${NDS_ROM}"
TEST_SCRIPT "homebrew-sdcard-exists.lua"
CORE_OPTION melonds_console_mode="ds"
CORE_OPTION melonds_homebrew_sdcard="disabled"
CORE_OPTION melonds_homebrew_sync_sdcard_to_host="disabled"
TEST_MODULE save.homebrew_sd_card_exists
CORE_OPTION "melonds_console_mode=ds"
CORE_OPTION "melonds_homebrew_sdcard=disabled"
CORE_OPTION "melonds_homebrew_sync_sdcard_to_host=disabled"
WILL_FAIL
)
add_emutest_test(
add_python_test(
NAME "Homebrew SD card image is created if enabled and loading a homebrew ROM"
CONTENT "${GODMODE9I_ROM}"
TEST_SCRIPT "homebrew-sdcard-exists.lua"
CORE_OPTION melonds_console_mode="ds"
CORE_OPTION melonds_homebrew_sdcard="enabled"
CORE_OPTION melonds_homebrew_sync_sdcard_to_host="disabled"
TEST_MODULE save.homebrew_sd_card_exists
CORE_OPTION "melonds_console_mode=ds"
CORE_OPTION "melonds_homebrew_sdcard=enabled"
CORE_OPTION "melonds_homebrew_sync_sdcard_to_host=disabled"
)
add_emutest_test(
add_python_test(
NAME "Homebrew SD card image is not created if disabled and loading a homebrew ROM"
CONTENT "${GODMODE9I_ROM}"
TEST_SCRIPT "homebrew-sdcard-exists.lua"
CORE_OPTION melonds_console_mode="ds"
CORE_OPTION melonds_homebrew_sdcard="disabled"
CORE_OPTION melonds_homebrew_sync_sdcard_to_host="disabled"
TEST_MODULE save.homebrew_sd_card_exists
CORE_OPTION "melonds_console_mode=ds"
CORE_OPTION "melonds_homebrew_sdcard=disabled"
CORE_OPTION "melonds_homebrew_sync_sdcard_to_host=disabled"
WILL_FAIL
)
add_emutest_test(
add_python_test(
NAME "Homebrew SD card sync folder is not created if SD card is enabled and loading a retail ROM"
CONTENT "${NDS_ROM}"
TEST_SCRIPT "homebrew-sdcard-sync-exists.lua"
CORE_OPTION melonds_console_mode="ds"
CORE_OPTION melonds_homebrew_sdcard="enabled"
CORE_OPTION melonds_homebrew_sync_sdcard_to_host="enabled"
TEST_MODULE save.homebrew_sd_card_sync_exists
CORE_OPTION "melonds_console_mode=ds"
CORE_OPTION "melonds_homebrew_sdcard=enabled"
CORE_OPTION "melonds_homebrew_sync_sdcard_to_host=enabled"
WILL_FAIL
)
add_emutest_test(
add_python_test(
NAME "Homebrew SD card sync folder is not created if SD card sync is disabled and loading a retail ROM"
CONTENT "${NDS_ROM}"
TEST_SCRIPT "homebrew-sdcard-sync-exists.lua"
CORE_OPTION melonds_console_mode="ds"
CORE_OPTION melonds_homebrew_sdcard="enabled"
CORE_OPTION melonds_homebrew_sync_sdcard_to_host="disabled"
TEST_MODULE save.homebrew_sd_card_sync_exists
CORE_OPTION "melonds_console_mode=ds"
CORE_OPTION "melonds_homebrew_sdcard=enabled"
CORE_OPTION "melonds_homebrew_sync_sdcard_to_host=disabled"
WILL_FAIL
)
add_emutest_test(
add_python_test(
NAME "Homebrew SD card sync folder is not created if SD card sync is disabled and loading a homebrew ROM"
CONTENT "${GODMODE9I_ROM}"
TEST_SCRIPT "homebrew-sdcard-sync-exists.lua"
CORE_OPTION melonds_console_mode="ds"
CORE_OPTION melonds_homebrew_sdcard="enabled"
CORE_OPTION melonds_homebrew_sync_sdcard_to_host="disabled"
TEST_MODULE save.homebrew_sd_card_sync_exists
CORE_OPTION "melonds_console_mode=ds"
CORE_OPTION "melonds_homebrew_sdcard=enabled"
CORE_OPTION "melonds_homebrew_sync_sdcard_to_host=disabled"
WILL_FAIL
)

View File

@ -1,13 +0,0 @@
local preamble = dofile(os.getenv("PREAMBLE"))
set_options_string(preamble.options_string)
load_core(corepath)
load_game(rompath)
run()
local homebrew_sd_card, sdcard_err = io.open(preamble.core_save_dir .. "/dldi_sd_card.bin", "rb")
if homebrew_sd_card == nil or sdcard_err ~= nil then
print(get_logs())
error("Failed to open homebrew SD card: " .. sdcard_err)
end

View File

@ -1,14 +0,0 @@
local preamble = dofile(os.getenv("PREAMBLE"))
set_options_string(preamble.options_string)
load_core(corepath)
load_game(rompath)
run()
local cmake = os.getenv("CMAKE")
local ok, reason, code = os.execute(string.format('"%s" -E chdir "%s" true', cmake, preamble.core_save_dir .. "/dldi_sd_card"))
if ok ~= true then
print(get_logs())
error("Failed to open homebrew SD card sync directory")
end

View File

@ -17,6 +17,8 @@ savestate_directory = os.path.join(testdir.name, "states")
core_system_dir = os.path.join(system_dir, "melonDS DS")
core_save_dir = os.path.join(save_dir, "melonDS DS")
wfcsettings_path = os.path.join(core_system_dir, "wfcsettings.bin")
dldi_sd_card_path = os.path.join(core_save_dir, "dldi_sd_card.bin")
dldi_sd_card_sync_path = os.path.join(core_save_dir, "dldi_sd_card")
print("Test dir:", testdir.name)
print("System dir:", system_dir)

View File

View File

@ -0,0 +1,15 @@
import os
import stat
from libretro import Session
import prelude
session: Session
with prelude.session() as session:
session.core.run()
dldi_sdcard_stat = os.stat(prelude.dldi_sd_card_path)
assert stat.S_ISREG(dldi_sdcard_stat.st_mode), "dldi_sd_card.bin should be a regular file"
assert dldi_sdcard_stat.st_size > 0, "dldi_sd_card.bin should exist and be non-empty"

View File

@ -0,0 +1,14 @@
import os
import stat
from libretro import Session
import prelude
session: Session
with prelude.session() as session:
session.core.run()
dldi_sdcard_stat = os.stat(prelude.dldi_sd_card_sync_path)
assert stat.S_ISDIR(dldi_sdcard_stat.st_mode), "dldi_sd_card should be a directory"