From ce22745620381e452ba260601ac893be5b96f106 Mon Sep 17 00:00:00 2001 From: Daniel Thornburgh Date: Fri, 4 Nov 2022 10:16:42 -0700 Subject: [PATCH] Fill out test. --- CMakeLists.txt | 5 ++++- expected | 1 + test.cmake | 12 +++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 expected diff --git a/CMakeLists.txt b/CMakeLists.txt index cb62bc6..834820c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.18) set(LLVM_MOS_PLATFORM sim) find_package(llvm-mos-sdk REQUIRED) project(smoke-test) +include(CTest) + add_executable(hello hello.c) find_program(SIM mos-sim REQUIRED) @@ -9,5 +11,6 @@ add_test(NAME test COMMAND ${CMAKE_COMMAND} -DSIM=${SIM} -DHELLO=$ - -P test.cmake + -DEXPECTED=${CMAKE_CURRENT_SOURCE_DIR}/expected + -P ${CMAKE_CURRENT_SOURCE_DIR}/test.cmake ) diff --git a/expected b/expected new file mode 100644 index 0000000..af5626b --- /dev/null +++ b/expected @@ -0,0 +1 @@ +Hello, world! diff --git a/test.cmake b/test.cmake index 5262888..0dca0ee 100644 --- a/test.cmake +++ b/test.cmake @@ -1 +1,11 @@ -find_program(SIM mos-sim REQUIRED) +execute_process(COMMAND ${SIM} ${HELLO} + OUTPUT_FILE output RESULT_VARIABLE RESULT) +if (RESULT) + message(FATAL_ERROR "Error running simulated test.") +endif() +execute_process( + COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol output ${EXPECTED} + RESULT_VARIABLE RESULT) +if (RESULT) + message(FATAL_ERROR "Incorrect output.") +endif()