-
-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
564 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
cmake_policy(SET CMP0110 NEW) | ||
|
||
if (NOT NDS_ROM) | ||
message(WARNING "NDS_ROM must be set to the path of an NDS ROM; tests that require one won't run.") | ||
set(NDS_ROM "NDS_ROM-NOTFOUND" CACHE FILEPATH "Path to an NDS ROM" FORCE) | ||
else() | ||
message(DEBUG "NDS_ROM: ${NDS_ROM}") | ||
endif() | ||
|
||
include(CMakePrintHelpers) | ||
|
||
function(add_melonds_test) | ||
set(options WILL_FAIL ARM7_BIOS ARM9_BIOS ARM7_DSI_BIOS ARM9_DSI_BIOS NDS_FIRMWARE DSI_FIRMWARE DSI_NAND DISABLED) | ||
set(oneValueArgs TARGET NAME ROM) | ||
set(multiValueArgs ARGS LABEL) | ||
cmake_parse_arguments(PARSE_ARGV 0 MELONDS_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}") | ||
|
||
cmake_print_variables(MELONDS_TEST_TARGET MELONDS_TEST_NAME MELONDS_TEST_ROM MELONDS_TEST_ARGS MELONDS_TEST_LABEL MELONDS_TEST_WILL_FAIL MELONDS_TEST_DISABLED) | ||
add_test( | ||
NAME "${MELONDS_TEST_NAME}" | ||
COMMAND "${MELONDS_TEST_TARGET}" | ||
${MELONDS_TEST_ARGS} | ||
COMMAND_EXPAND_LISTS | ||
) | ||
|
||
if (MELONDS_TEST_ROM) | ||
list(APPEND REQUIRED_FILES "${MELONDS_TEST_ROM}") | ||
endif() | ||
|
||
macro(expose_system_file SYSFILE) | ||
if (MELONDS_TEST_${SYSFILE}) | ||
list(APPEND REQUIRED_FILES "${${SYSFILE}}") | ||
list(APPEND ENVIRONMENT "${SYSFILE}=${${SYSFILE}}") | ||
endif() | ||
endmacro() | ||
|
||
expose_system_file(ARM7_BIOS) | ||
expose_system_file(ARM9_BIOS) | ||
expose_system_file(ARM7_DSI_BIOS) | ||
expose_system_file(ARM9_DSI_BIOS) | ||
expose_system_file(NDS_FIRMWARE) | ||
expose_system_file(DSI_FIRMWARE) | ||
expose_system_file(DSI_NAND) | ||
|
||
set_tests_properties("${MELONDS_TEST_NAME}" PROPERTIES LABELS "${MELONDS_TEST_LABEL}") # This is already a list | ||
set_tests_properties("${MELONDS_TEST_NAME}" PROPERTIES ENVIRONMENT "${ENVIRONMENT}") | ||
set_tests_properties("${MELONDS_TEST_NAME}" PROPERTIES REQUIRED_FILES "${REQUIRED_FILES}") | ||
|
||
if (MELONDS_TEST_WILL_FAIL) | ||
set_tests_properties("${MELONDS_TEST_NAME}" PROPERTIES WILL_FAIL TRUE) | ||
endif() | ||
|
||
if (MELONDS_TEST_DISABLED) | ||
set_tests_properties("${MELONDS_TEST_NAME}" PROPERTIES DISABLED TRUE) | ||
endif() | ||
endfunction() | ||
|
||
function(add_test_executable TEST_PROGRAM) | ||
add_executable("${TEST_PROGRAM}" "${TEST_PROGRAM}.cpp") | ||
target_link_libraries("${TEST_PROGRAM}" PRIVATE core melonDS-tests-common) | ||
target_include_directories("${TEST_PROGRAM}" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src") | ||
endfunction() | ||
|
||
add_subdirectory(common) | ||
add_subdirectory(cases) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(basic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Test executables must be defined separately from the actual tests, | ||
# as the same test executable might be used for multiple tests | ||
# (with different parameters each time). | ||
|
||
add_test_executable(NDSCreated) | ||
add_test_executable(MultipleNDSCreated) | ||
add_test_executable(MultipleNDSCreatedInDifferentOrder) | ||
|
||
add_melonds_test( | ||
NAME "NDS is created and destroyed" | ||
TARGET NDSCreated | ||
) | ||
|
||
add_melonds_test( | ||
NAME "Multiple NDS systems are created and destroyed" | ||
TARGET MultipleNDSCreated | ||
) | ||
|
||
add_melonds_test( | ||
NAME "Multiple NDS systems are created and destroyed in different orders" | ||
TARGET MultipleNDSCreatedInDifferentOrder | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Copyright 2016-2023 melonDS team | ||
This file is part of melonDS. | ||
melonDS 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 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. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
|
||
#include "NDS.h" | ||
|
||
int main() | ||
{ | ||
// volatile so it's not optimized out | ||
volatile auto nds1 = std::make_unique<melonDS::NDS>(); | ||
volatile auto nds2 = std::make_unique<melonDS::NDS>(); | ||
volatile auto nds3 = std::make_unique<melonDS::NDS>(); | ||
volatile auto nds4 = std::make_unique<melonDS::NDS>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
Copyright 2016-2023 melonDS team | ||
This file is part of melonDS. | ||
melonDS 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 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. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
|
||
#include <memory> | ||
#include "NDS.h" | ||
|
||
int main() | ||
{ | ||
// volatile so it's not optimized out | ||
auto nds1 = std::make_unique<volatile melonDS::NDS>(); | ||
auto nds2 = std::make_unique<volatile melonDS::NDS>(); | ||
auto nds3 = std::make_unique<volatile melonDS::NDS>(); | ||
auto nds4 = std::make_unique<volatile melonDS::NDS>(); | ||
|
||
nds3 = nullptr; | ||
nds1 = nullptr; | ||
nds4 = nullptr; | ||
nds2 = nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Copyright 2016-2023 melonDS team | ||
This file is part of melonDS. | ||
melonDS 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 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. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
|
||
#include <memory> | ||
#include "NDS.h" | ||
|
||
int main() | ||
{ | ||
// volatile so it's not optimized out | ||
volatile auto nds = std::make_unique<melonDS::NDS>(); | ||
|
||
// NDS is probably waaaay too big for the stack | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
include(FixInterfaceIncludes) | ||
|
||
add_library(melonDS-tests-common STATIC | ||
Platform.cpp | ||
TestCommon.cpp | ||
TestCommon.h | ||
) | ||
|
||
# The test program is built with C++20 so we can use std::counting_semaphore | ||
set_target_properties(melonDS-tests-common PROPERTIES CXX_STANDARD 20) | ||
|
||
target_link_libraries(melonDS-tests-common PRIVATE core) | ||
target_include_directories(melonDS-tests-common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../src") |
Oops, something went wrong.