mirror of
https://github.com/JesseTG/melonds-ds.git
synced 2024-11-27 08:41:08 +00:00
Implement or update some tests
This commit is contained in:
parent
5b0ed4a8d8
commit
9f432f7b00
@ -30,6 +30,8 @@ add_library(melondsds_libretro MODULE
|
||||
core/core.cpp
|
||||
core/core.hpp
|
||||
core/tasks.cpp
|
||||
core/test.cpp
|
||||
core/test.hpp
|
||||
environment.cpp
|
||||
environment.hpp
|
||||
exceptions.cpp
|
||||
|
31
src/libretro/core/test.cpp
Normal file
31
src/libretro/core/test.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2024 Jesse Talavera
|
||||
|
||||
melonDS DS is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS DS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS DS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include "test.hpp"
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
extern "C" int libretropy_add_integers(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
retro_proc_address_t MelonDsDs::GetProcAddress(const char* sym) noexcept {
|
||||
if (string_is_equal(sym, "libretropy_add_integers"))
|
||||
return reinterpret_cast<retro_proc_address_t>(libretropy_add_integers);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
25
src/libretro/core/test.hpp
Normal file
25
src/libretro/core/test.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
Copyright 2024 Jesse Talavera
|
||||
|
||||
melonDS DS is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS DS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS DS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <libretro.h>
|
||||
|
||||
namespace MelonDsDs
|
||||
{
|
||||
// test functions for the test suite
|
||||
retro_proc_address_t GetProcAddress(const char* sym) noexcept;
|
||||
}
|
@ -37,6 +37,7 @@
|
||||
#include "info.hpp"
|
||||
#include "libretro.hpp"
|
||||
#include "config/config.hpp"
|
||||
#include "core/test.hpp"
|
||||
#include "tracy.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
|
@ -333,16 +333,4 @@ void Platform::WriteFirmware(const Firmware& firmware, u32 writeoffset, u32 writ
|
||||
ZoneScopedN(TracyFunction);
|
||||
|
||||
MelonDsDs::Core.WriteFirmware(firmware, writeoffset, writelen);
|
||||
}
|
||||
|
||||
extern "C" int libretropy_add_integers(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
retro_proc_address_t MelonDsDs::GetProcAddress(const char* sym) noexcept {
|
||||
if (sym == "libretropy_add_integers")
|
||||
return reinterpret_cast<retro_proc_address_t>(libretropy_add_integers);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
@ -39,7 +39,6 @@ namespace MelonDsDs {
|
||||
void HardwareContextReset() noexcept;
|
||||
void HardwareContextDestroyed() noexcept;
|
||||
bool UpdateOptionVisibility() noexcept;
|
||||
retro_proc_address_t GetProcAddress(const char* sym) noexcept;
|
||||
}
|
||||
|
||||
#endif //MELONDS_DS_LIBRETRO_HPP
|
||||
|
@ -138,12 +138,14 @@ add_python_test(
|
||||
|
||||
add_python_test(
|
||||
NAME "Core sets pixel format to XRGB8888"
|
||||
TEST_MODULE ""
|
||||
TEST_MODULE basics.core_sets_pixel_format
|
||||
CONTENT "${NDS_ROM}"
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
NAME "Core sets input descriptors"
|
||||
TEST_MODULE ""
|
||||
TEST_MODULE basics.core_defines_input_descriptors
|
||||
NDS_SYSFILES
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
@ -163,21 +165,19 @@ add_python_test(
|
||||
|
||||
add_python_test(
|
||||
NAME "Core registers support for no-content mode"
|
||||
TEST_MODULE "basics.core_registers_no_content_support"
|
||||
TEST_MODULE basics.core_registers_no_content_support
|
||||
CONTENT "${NDS_ROM}"
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
NAME "Core loads and unloads without content"
|
||||
TEST_MODULE "basics.core_loads_unloads_without_content"
|
||||
TEST_MODULE basics.core_loads_unloads_without_content
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
NAME "Core logs output"
|
||||
TEST_MODULE "basics.core_logs_output"
|
||||
ARM7_BIOS
|
||||
ARM9_BIOS
|
||||
NDS_FIRMWARE
|
||||
TEST_MODULE basics.core_logs_output
|
||||
NDS_SYSFILES
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
@ -187,13 +187,14 @@ add_python_test(
|
||||
|
||||
add_python_test(
|
||||
NAME "Core sets retro_get_proc_address_interface"
|
||||
TEST_MODULE "basics.core_get_proc_address"
|
||||
CONTENT "${NDS_ROM}"
|
||||
TEST_MODULE basics.core_get_proc_address
|
||||
NDS_SYSFILES
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
NAME "Core defines subsystems"
|
||||
TEST_MODULE ""
|
||||
TEST_MODULE basics.core_defines_subsystems
|
||||
NDS_SYSFILES
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
@ -203,7 +204,8 @@ add_python_test(
|
||||
|
||||
add_python_test(
|
||||
NAME "Core defines controller info"
|
||||
TEST_MODULE ""
|
||||
TEST_MODULE basics.core_defines_controller_info
|
||||
NDS_SYSFILES
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
@ -213,7 +215,8 @@ add_python_test(
|
||||
|
||||
add_python_test(
|
||||
NAME "Core registers support for achievements"
|
||||
TEST_MODULE ""
|
||||
TEST_MODULE basics.core_registers_achievement_support
|
||||
NDS_SYSFILES
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
@ -253,7 +256,8 @@ add_python_test(
|
||||
|
||||
add_python_test(
|
||||
NAME "Core sets content info overrides"
|
||||
TEST_MODULE ""
|
||||
TEST_MODULE basics.core_defines_content_info_overrides
|
||||
NDS_SYSFILES
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
|
10
test/python/basics/core_defines_content_info_overrides.py
Normal file
10
test/python/basics/core_defines_content_info_overrides.py
Normal file
@ -0,0 +1,10 @@
|
||||
from libretro import default_session
|
||||
|
||||
import prelude
|
||||
|
||||
with default_session(prelude.core_path) as session:
|
||||
overrides = session.content_info_overrides
|
||||
|
||||
assert overrides is not None
|
||||
assert len(overrides) > 0
|
||||
assert all(o.extensions for o in overrides)
|
9
test/python/basics/core_defines_controller_info.py
Normal file
9
test/python/basics/core_defines_controller_info.py
Normal file
@ -0,0 +1,9 @@
|
||||
from libretro import default_session
|
||||
|
||||
import prelude
|
||||
|
||||
with default_session(prelude.core_path) as session:
|
||||
info = session.controller_info
|
||||
|
||||
assert info is not None
|
||||
assert info.num_types > 0
|
11
test/python/basics/core_defines_input_descriptors.py
Normal file
11
test/python/basics/core_defines_input_descriptors.py
Normal file
@ -0,0 +1,11 @@
|
||||
from ctypes import *
|
||||
from libretro import default_session, retro_get_proc_address_t
|
||||
|
||||
import prelude
|
||||
|
||||
with default_session(prelude.core_path) as session:
|
||||
descriptors = session.input_descriptors
|
||||
|
||||
assert descriptors is not None
|
||||
assert len(descriptors) > 0
|
||||
assert all(d.description for d in descriptors)
|
10
test/python/basics/core_defines_subsystems.py
Normal file
10
test/python/basics/core_defines_subsystems.py
Normal file
@ -0,0 +1,10 @@
|
||||
from libretro import default_session
|
||||
|
||||
import prelude
|
||||
|
||||
with default_session(prelude.core_path) as session:
|
||||
subsystems = session.subsystems
|
||||
|
||||
assert subsystems is not None
|
||||
assert len(subsystems) > 0
|
||||
assert all(s.desc for s in subsystems)
|
@ -1,17 +1,19 @@
|
||||
from ctypes import *
|
||||
from sys import argv
|
||||
from libretro import default_session, retro_get_proc_address_t
|
||||
|
||||
with default_session(argv[1]) as env:
|
||||
proc_address_callback = env.proc_address_callback
|
||||
import prelude
|
||||
|
||||
with default_session(prelude.core_path) as session:
|
||||
proc_address_callback = session.proc_address_callback
|
||||
assert proc_address_callback is not None
|
||||
|
||||
get_proc_address: retro_get_proc_address_t = proc_address_callback.get_proc_address
|
||||
assert get_proc_address is not None
|
||||
|
||||
add_integers = get_proc_address("libretropy_add_integers")
|
||||
add_integers = get_proc_address(b"libretropy_add_integers")
|
||||
assert add_integers is not None
|
||||
|
||||
add_integers_callable = cast(add_integers, CFUNCTYPE(c_int, c_int, c_int))
|
||||
|
||||
assert add_integers_callable is not None
|
||||
assert add_integers_callable(1, 2) == 3
|
||||
|
@ -1,11 +1,10 @@
|
||||
from sys import argv
|
||||
from typing import cast
|
||||
from libretro import default_session
|
||||
from libretro.callback.log import StandardLogger
|
||||
|
||||
import prelude
|
||||
|
||||
with default_session(argv[1], system_dir=prelude.core_system_dir) as session:
|
||||
with default_session(prelude.core_path, system_dir=prelude.core_system_dir) as session:
|
||||
log: StandardLogger = cast(StandardLogger, session.log)
|
||||
assert log is not None
|
||||
assert log.records is not None
|
||||
|
6
test/python/basics/core_registers_achievement_support.py
Normal file
6
test/python/basics/core_registers_achievement_support.py
Normal file
@ -0,0 +1,6 @@
|
||||
from libretro import default_session
|
||||
|
||||
import prelude
|
||||
|
||||
with default_session(prelude.core_path, prelude.content_path) as env:
|
||||
assert env.support_achievements is True
|
8
test/python/basics/core_sets_pixel_format.py
Normal file
8
test/python/basics/core_sets_pixel_format.py
Normal file
@ -0,0 +1,8 @@
|
||||
from sys import argv
|
||||
from libretro import default_session
|
||||
from libretro.defs import PixelFormat
|
||||
|
||||
import prelude
|
||||
|
||||
with default_session(prelude.core_path) as session:
|
||||
assert session.video.pixel_format == PixelFormat.XRGB8888
|
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
if not __debug__:
|
||||
@ -30,3 +31,5 @@ for _f in SYSTEM_FILES:
|
||||
shutil.copyfile(os.environ[_f], targetpath)
|
||||
|
||||
options_string = os.getenv("RETRO_CORE_OPTIONS")
|
||||
core_path = sys.argv[1]
|
||||
content_path = sys.argv[2] if len(sys.argv) > 2 else None
|
||||
|
Loading…
Reference in New Issue
Block a user