Skip to content

Commit

Permalink
Refactor NES tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterymath committed Oct 27, 2022
1 parent 6df4ccf commit 3db8fe6
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 154 deletions.
File renamed without changes.
30 changes: 2 additions & 28 deletions test/nes-cnrom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
cmake_minimum_required(VERSION 3.18)

project(test-nes-mmc1 LANGUAGES C)
include(CTest)

add_library(test-lib test-lib.c)

function(add_mesen_test name)
add_executable(${name} ${name}.c)
target_link_libraries(${name} test-lib)
add_test(NAME test-${name} COMMAND ${MESEN_COMMAND} --testrunner
$<TARGET_FILE:${name}> ${CMAKE_CURRENT_SOURCE_DIR}/mesen.lua)
endfunction()
include(../test.cmake)

add_mesen_test(minimal)

add_mesen_test(chr-ram)
add_mesen_test(chr-rom)

function(add_no_compile_test target)
add_test(NAME ${target}-no-compile COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/no-compile
${CMAKE_CURRENT_BINARY_DIR}/no-compile/${target}
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-target ${target}
--build-options
-DLLVM_MOS=${LLVM_MOS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
)
set_property(TEST ${target}-no-compile PROPERTY WILL_FAIL YES)
endfunction()

add_no_compile_test(chr-rom-too-big)
add_no_compile_test(chr-rom-non-pow2)
add_subdirectory(no-compile)
8 changes: 3 additions & 5 deletions test/nes-cnrom/no-compile/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
cmake_minimum_required(VERSION 3.18)
set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON)

project(test-nes-mmc1-nocompile LANGUAGES C)

add_executable(chr-rom-too-big chr-rom-too-big.c)
add_executable(chr-rom-non-pow2 chr-rom-non-pow2.c)
add_no_compile_test(chr-rom-too-big)
add_no_compile_test(chr-rom-non-pow2)
35 changes: 2 additions & 33 deletions test/nes-mmc1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
cmake_minimum_required(VERSION 3.18)

project(test-nes-mmc1 LANGUAGES C)
include(CTest)

add_library(test-lib test-lib.c)

function(add_mesen_test name)
add_executable(${name} ${name}.c)
target_link_libraries(${name} test-lib)
add_test(NAME test-${name} COMMAND ${MESEN_COMMAND} --testrunner
$<TARGET_FILE:${name}> ${CMAKE_CURRENT_SOURCE_DIR}/mesen.lua)
endfunction()
include(../test.cmake)

add_mesen_test(minimal)

Expand Down Expand Up @@ -39,27 +31,4 @@ add_mesen_test(prg-ram)
add_mesen_test(prg-ram-c)
target_link_options(prg-ram-c PRIVATE -Tcommon.ld -Tprg-rom-128.ld -Tc-in-prg-ram-0.ld)

function(add_no_compile_test target)
add_test(NAME ${target}-no-compile COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/no-compile
${CMAKE_CURRENT_BINARY_DIR}/no-compile/${target}
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-target ${target}
--build-options
-DLLVM_MOS=${LLVM_MOS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
)
set_property(TEST ${target}-no-compile PROPERTY WILL_FAIL YES)
endfunction()

add_no_compile_test(chr-rom-too-big)
add_no_compile_test(chr-rom-non-pow2)
add_no_compile_test(chr-ram-too-big)
add_no_compile_test(chr-ram-uneven-banks)
add_no_compile_test(chr-nvram-uneven-banks)
add_no_compile_test(prg-ram-too-big)
add_no_compile_test(prg-ram-uneven-banks)
add_no_compile_test(prg-nvram-uneven-banks)
add_subdirectory(no-compile)
22 changes: 10 additions & 12 deletions test/nes-mmc1/no-compile/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
cmake_minimum_required(VERSION 3.18)

project(test-nes-mmc1-nocompile LANGUAGES C)

add_executable(chr-rom-too-big chr-rom-too-big.c)
add_executable(chr-rom-non-pow2 chr-rom-non-pow2.c)

add_executable(chr-ram-too-big chr-ram-too-big.c)
add_executable(chr-ram-uneven-banks chr-ram-uneven-banks.c)
add_executable(chr-nvram-uneven-banks chr-nvram-uneven-banks.c)

add_executable(prg-ram-too-big prg-ram-too-big.c)
add_executable(prg-ram-uneven-banks prg-ram-uneven-banks.c)
add_executable(prg-nvram-uneven-banks prg-nvram-uneven-banks.c)
set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON)

add_no_compile_test(chr-rom-too-big)
add_no_compile_test(chr-rom-non-pow2)
add_no_compile_test(chr-ram-too-big)
add_no_compile_test(chr-ram-uneven-banks)
add_no_compile_test(chr-nvram-uneven-banks)
add_no_compile_test(prg-ram-too-big)
add_no_compile_test(prg-ram-uneven-banks)
add_no_compile_test(prg-nvram-uneven-banks)
28 changes: 1 addition & 27 deletions test/nes-mmc3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
cmake_minimum_required(VERSION 3.18)

project(test-nes-mmc3 LANGUAGES C)
include(CTest)

add_library(test-lib test-lib.c)

function(add_mesen_test name)
add_executable(${name} ${name}.c)
target_link_libraries(${name} test-lib)
add_test(NAME test-${name} COMMAND ${MESEN_COMMAND} --testrunner
$<TARGET_FILE:${name}> ${CMAKE_CURRENT_SOURCE_DIR}/mesen.lua)
endfunction()
include(../test.cmake)

add_mesen_test(minimal)

function(add_no_compile_test target)
add_test(NAME ${target}-no-compile COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/no-compile
${CMAKE_CURRENT_BINARY_DIR}/no-compile/${target}
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-target ${target}
--build-options
-DLLVM_MOS=${LLVM_MOS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
)
set_property(TEST ${target}-no-compile PROPERTY WILL_FAIL YES)
endfunction()

#add_no_compile_test(chr-rom-too-big)
9 changes: 0 additions & 9 deletions test/nes-mmc3/test-lib.c

This file was deleted.

33 changes: 2 additions & 31 deletions test/nes-nrom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
cmake_minimum_required(VERSION 3.18)

project(test-nes-mmc1 LANGUAGES C)
include(CTest)

add_library(test-lib test-lib.c)

function(add_mesen_test name)
add_executable(${name} ${name}.c)
target_link_libraries(${name} test-lib)
add_test(NAME test-${name} COMMAND ${MESEN_COMMAND} --testrunner
$<TARGET_FILE:${name}> ${CMAKE_CURRENT_SOURCE_DIR}/mesen.lua)
endfunction()
include(../test.cmake)

add_mesen_test(minimal)

Expand All @@ -26,25 +18,4 @@ target_link_options(prg-ram-c PRIVATE -Tcommon.ld -Tc-in-prg-ram.ld)

add_mesen_test(zp-data)

function(add_no_compile_test target)
add_test(NAME ${target}-no-compile COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/no-compile
${CMAKE_CURRENT_BINARY_DIR}/no-compile/${target}
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-target ${target}
--build-options
-DLLVM_MOS=${LLVM_MOS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
)
set_property(TEST ${target}-no-compile PROPERTY WILL_FAIL YES)
endfunction()

add_no_compile_test(chr-rom-too-big)
add_no_compile_test(chr-rom-non-pow2)
add_no_compile_test(chr-ram-too-big)

add_no_compile_test(prg-rom-too-big)
add_no_compile_test(prg-ram-too-big)
add_subdirectory(no-compile)
15 changes: 6 additions & 9 deletions test/nes-nrom/no-compile/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
cmake_minimum_required(VERSION 3.18)
set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON)

project(test-nes-mmc1-nocompile LANGUAGES C)

add_executable(chr-rom-too-big chr-rom-too-big.c)
add_executable(chr-rom-non-pow2 chr-rom-non-pow2.c)
add_executable(chr-ram-too-big chr-ram-too-big.c)

add_executable(prg-rom-too-big prg-rom-too-big.c)
add_executable(prg-ram-too-big prg-ram-too-big.c)
add_no_compile_test(chr-ram-too-big)
add_no_compile_test(chr-rom-non-pow2)
add_no_compile_test(chr-rom-too-big)
add_no_compile_test(prg-rom-too-big)
add_no_compile_test(prg-ram-too-big)
File renamed without changes.
34 changes: 34 additions & 0 deletions test/test.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
include(CTest)

add_library(test-lib ${CMAKE_CURRENT_SOURCE_DIR}/../test-lib.c)

function(add_mesen_test name)
add_executable(${name} ${name}.c)
target_link_libraries(${name} test-lib)
add_test(NAME test-${name} COMMAND ${MESEN_COMMAND} --testrunner
$<TARGET_FILE:${name}> ${CMAKE_CURRENT_SOURCE_DIR}/../mesen.lua)
endfunction()

function(add_mesen_test name)
add_executable(${name} ${name}.c)
target_link_libraries(${name} test-lib)
add_test(NAME test-${name} COMMAND ${MESEN_COMMAND} --testrunner
$<TARGET_FILE:${name}> ${CMAKE_CURRENT_SOURCE_DIR}/../mesen.lua)
endfunction()

function(add_no_compile_test target)
add_executable(${target} ${target}.c)
add_test(NAME ${target}-no-compile COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_BINARY_DIR}/${target}
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-target ${target}
--build-options
-DLLVM_MOS=${LLVM_MOS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
)
set_property(TEST ${target}-no-compile PROPERTY WILL_FAIL YES)
endfunction()

0 comments on commit 3db8fe6

Please sign in to comment.