diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 05872ae69..2aa2a7804 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -41,3 +41,5 @@ add_test_target(nes-unrom) add_test_target(nes-unrom-512) add_test_target(atari2600-4k) add_test_target(atari2600-3e) +add_test_target(atari8-dos) +add_test_target(atari8-stdcart) diff --git a/test/atari8-dos/CMakeLists.txt b/test/atari8-dos/CMakeLists.txt new file mode 100644 index 000000000..92a47a812 --- /dev/null +++ b/test/atari8-dos/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.18) + +project(test-atari8-dos LANGUAGES C) + +include(../test.cmake) + +add_subdirectory(compile) +add_subdirectory(no-compile) diff --git a/test/atari8-dos/compile/CMakeLists.txt b/test/atari8-dos/compile/CMakeLists.txt new file mode 100644 index 000000000..c22ce297a --- /dev/null +++ b/test/atari8-dos/compile/CMakeLists.txt @@ -0,0 +1,3 @@ +set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON) + +add_compile_test(minimal) diff --git a/test/atari8-dos/compile/minimal.c b/test/atari8-dos/compile/minimal.c new file mode 100644 index 000000000..d1f7742ea --- /dev/null +++ b/test/atari8-dos/compile/minimal.c @@ -0,0 +1,6 @@ + +#include + +int main(void) { + printf("hello\n"); +} diff --git a/test/atari8-dos/no-compile/CMakeLists.txt b/test/atari8-dos/no-compile/CMakeLists.txt new file mode 100644 index 000000000..afe98ce28 --- /dev/null +++ b/test/atari8-dos/no-compile/CMakeLists.txt @@ -0,0 +1,3 @@ +set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON) + +add_no_compile_test(ram-too-big) diff --git a/test/atari8-dos/no-compile/ram-too-big.c b/test/atari8-dos/no-compile/ram-too-big.c new file mode 100644 index 000000000..14910479e --- /dev/null +++ b/test/atari8-dos/no-compile/ram-too-big.c @@ -0,0 +1,23 @@ +// ExpectFailure: ld.lld: error: section '.data' will not fit in region 'ram' + +#include + +// atari8-dos; presently we have 40KiB of RAM from 0x2000 to 0xC000, +// array sizes have to be <=32767; use 30+10 +uint8_t ram_too_big0[30 * 1024] = { 0x55 }; +uint8_t ram_too_big1[10 * 1024] = { 0xAA }; + +int main(void) { + asm volatile( + "" + : + : "r"(ram_too_big0) + : + ); + asm volatile( + "" + : + : "r"(ram_too_big1) + : + ); +} diff --git a/test/atari8-stdcart/CMakeLists.txt b/test/atari8-stdcart/CMakeLists.txt new file mode 100644 index 000000000..5dfa76fd3 --- /dev/null +++ b/test/atari8-stdcart/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.18) + +project(test-atari8-stdcart LANGUAGES C) + +include(../test.cmake) + +add_subdirectory(compile) +add_subdirectory(no-compile) diff --git a/test/atari8-stdcart/compile/CMakeLists.txt b/test/atari8-stdcart/compile/CMakeLists.txt new file mode 100644 index 000000000..21d8ee1be --- /dev/null +++ b/test/atari8-stdcart/compile/CMakeLists.txt @@ -0,0 +1,6 @@ +set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON) + +add_compile_test(minimal) +add_compile_test(cart-rom-8-fit-6) +add_compile_test(cart-rom-16-fit-14) +add_compile_test(cart-rom-size-declared) diff --git a/test/atari8-stdcart/compile/cart-rom-16-fit-14.c b/test/atari8-stdcart/compile/cart-rom-16-fit-14.c new file mode 100644 index 000000000..28990a9a8 --- /dev/null +++ b/test/atari8-stdcart/compile/cart-rom-16-fit-14.c @@ -0,0 +1,16 @@ + +#include + +asm(".globl __cart_rom_size \n __cart_rom_size = 16"); + +// atari8-stdcard, 16 KiB +uint8_t data_too_big[14 * 1024] = { 0x55 }; + +int main(void) { + asm volatile( + "" + : + : "r"(data_too_big) + : + ); +} diff --git a/test/atari8-stdcart/compile/cart-rom-8-fit-6.c b/test/atari8-stdcart/compile/cart-rom-8-fit-6.c new file mode 100644 index 000000000..9ec033c95 --- /dev/null +++ b/test/atari8-stdcart/compile/cart-rom-8-fit-6.c @@ -0,0 +1,16 @@ + +#include + +asm(".globl __cart_rom_size \n __cart_rom_size = 8"); + +// atari8-stdcard, 8 KiB +uint8_t data_too_big[6 * 1024] = { 0x55 }; + +int main(void) { + asm volatile( + "" + : + : "r"(data_too_big) + : + ); +} diff --git a/test/atari8-stdcart/compile/cart-rom-size-declared.c b/test/atari8-stdcart/compile/cart-rom-size-declared.c new file mode 100644 index 000000000..1d3832c4d --- /dev/null +++ b/test/atari8-stdcart/compile/cart-rom-size-declared.c @@ -0,0 +1,13 @@ + +#include + +extern int __cart_rom_size; + +int main(void) { + asm volatile( + "" + : + : "r"(__cart_rom_size) + : + ); +} diff --git a/test/atari8-stdcart/compile/minimal.c b/test/atari8-stdcart/compile/minimal.c new file mode 100644 index 000000000..d1f7742ea --- /dev/null +++ b/test/atari8-stdcart/compile/minimal.c @@ -0,0 +1,6 @@ + +#include + +int main(void) { + printf("hello\n"); +} diff --git a/test/atari8-stdcart/no-compile/CMakeLists.txt b/test/atari8-stdcart/no-compile/CMakeLists.txt new file mode 100644 index 000000000..4c9b61549 --- /dev/null +++ b/test/atari8-stdcart/no-compile/CMakeLists.txt @@ -0,0 +1,5 @@ +set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON) + +add_no_compile_test(ram-too-big) +add_no_compile_test(cart-rom-8-too-big) +add_no_compile_test(cart-rom-16-too-big) diff --git a/test/atari8-stdcart/no-compile/cart-rom-16-too-big.c b/test/atari8-stdcart/no-compile/cart-rom-16-too-big.c new file mode 100644 index 000000000..6b1c7194d --- /dev/null +++ b/test/atari8-stdcart/no-compile/cart-rom-16-too-big.c @@ -0,0 +1,17 @@ +// ExpectFailure: ld.lld: error: section '.data' will not fit in region 'cart_rom': overflowed + +#include + +asm(".globl __cart_rom_size \n __cart_rom_size = 16"); + +// atari8-stdcard, 16 KiB, this won't fit +uint8_t data_too_big[16 * 1024] = { 0x55 }; + +int main(void) { + asm volatile( + "" + : + : "r"(data_too_big) + : + ); +} diff --git a/test/atari8-stdcart/no-compile/cart-rom-8-too-big.c b/test/atari8-stdcart/no-compile/cart-rom-8-too-big.c new file mode 100644 index 000000000..b17beaf1e --- /dev/null +++ b/test/atari8-stdcart/no-compile/cart-rom-8-too-big.c @@ -0,0 +1,17 @@ +// ExpectFailure: ld.lld: error: section '.data' will not fit in region 'cart_rom': overflowed + +#include + +asm(".globl __cart_rom_size \n __cart_rom_size = 8"); + +// atari8-stdcard, 8 KiB, this won't fit +uint8_t data_too_big[8 * 1024] = { 0x55 }; + +int main(void) { + asm volatile( + "" + : + : "r"(data_too_big) + : + ); +} diff --git a/test/atari8-stdcart/no-compile/ram-too-big.c b/test/atari8-stdcart/no-compile/ram-too-big.c new file mode 100644 index 000000000..23eac6fab --- /dev/null +++ b/test/atari8-stdcart/no-compile/ram-too-big.c @@ -0,0 +1,15 @@ +// ExpectFailure: ld.lld: error: section '.bss' will not fit in region 'ram': overflowed + +#include + +// atari8-stdcart; we have 14.25 KiB of RAM from 0x700 to 0x4000 +uint8_t ram_too_big[15 * 1024]; + +int main(void) { + asm volatile( + "" + : + : "r"(ram_too_big) + : + ); +} diff --git a/test/test.cmake b/test/test.cmake index 9ed257528..ef25961bf 100644 --- a/test/test.cmake +++ b/test/test.cmake @@ -13,9 +13,9 @@ function(add_emutest_test name binext source_dir libretro_core) -t ${CMAKE_CURRENT_SOURCE_DIR}/../emutest.lua) endfunction() -function(add_no_compile_test target) +function(add_common_compile_test target type) add_executable(${target} ${target}.c) - add_test(NAME ${target}-no-compile COMMAND ${CMAKE_CTEST_COMMAND} + add_test(NAME ${target}-${type} COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/${target} --build-generator ${CMAKE_GENERATOR} @@ -28,6 +28,16 @@ function(add_no_compile_test target) -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_EXPORT_COMPILE_COMMANDS=${CMAKE_EXPORT_COMPILE_COMMANDS} ) +endfunction() + +# negative (failure) compilation test +function(add_compile_test target) + add_common_compile_test(${target} compile) +endfunction() + +# negative (failure) compilation test +function(add_no_compile_test target) + add_common_compile_test(${target} no-compile) set_property(TEST ${target}-no-compile PROPERTY WILL_FAIL YES) endfunction()