about summary refs log tree commit diff stats
path: root/runTest.cmake
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-02-28 14:19:04 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-02-28 14:19:04 +0100
commite753c19da1b621b1e667de85ce5ef60d186f0684 (patch)
tree9bc80378efbe42ec72678230de2905ab121a4d8f /runTest.cmake
parent7b50468b61b7bdd9a15753c0a28711c1654a8c12 (diff)
downloadbox64-e753c19da1b621b1e667de85ce5ef60d186f0684.tar.gz
box64-e753c19da1b621b1e667de85ce5ef60d186f0684.zip
Added some minimal set of source (now box64 compile and say hello at least)
Diffstat (limited to 'runTest.cmake')
-rwxr-xr-xrunTest.cmake50
1 files changed, 50 insertions, 0 deletions
diff --git a/runTest.cmake b/runTest.cmake
new file mode 100755
index 00000000..cb6706ae
--- /dev/null
+++ b/runTest.cmake
@@ -0,0 +1,50 @@
+# arguments checking
+if( NOT TEST_PROGRAM )
+  message( FATAL_ERROR "Require TEST_PROGRAM to be defined" )
+endif( NOT TEST_PROGRAM )
+if( NOT TEST_ARGS )
+  message( FATAL_ERROR "Require TEST_ARGS to be defined" )
+endif( NOT TEST_ARGS )
+if( NOT TEST_OUTPUT )
+  message( FATAL_ERROR "Require TEST_OUTPUT to be defined" )
+endif( NOT TEST_OUTPUT )
+if( NOT TEST_REFERENCE )
+  message( FATAL_ERROR "Require TEST_REFERENCE to be defined" )
+endif( NOT TEST_REFERENCE )
+
+set(ENV{BOX64_LOG} 0)
+set(ENV{BOX64_NOBANNER} 1)
+if( EXISTS ${CMAKE_SOURCE_DIR}/x64lib )
+  # we are inside box64 folder
+  set(ENV{LD_LIBRARY_PATH} ${CMAKE_SOURCE_DIR}/x64lib)
+else()
+  # we are inside build folder
+  set(ENV{LD_LIBRARY_PATH} ${CMAKE_SOURCE_DIR}/../x64lib)
+endif( EXISTS ${CMAKE_SOURCE_DIR}/x64lib )
+
+# run the test program, capture the stdout/stderr and the result var
+execute_process(
+  COMMAND ${TEST_PROGRAM} ${TEST_ARGS} ${TEST_ARGS2}
+  OUTPUT_FILE ${TEST_OUTPUT}
+  ERROR_VARIABLE TEST_ERROR
+  RESULT_VARIABLE TEST_RESULT
+  )
+
+# if the return value is !=0 bail out
+if( TEST_RESULT )
+  message( FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != 0.\n${TEST_ERROR}" )
+endif( TEST_RESULT )
+
+# now compare the output with the reference
+execute_process(
+  COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_OUTPUT} ${TEST_REFERENCE}
+  RESULT_VARIABLE TEST_RESULT
+  )
+
+# again, if return value is !=0 scream and shout
+if( TEST_RESULT )
+  message( FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not match ${TEST_REFERENCE}")
+endif( TEST_RESULT )
+
+# everything went fine...
+message( "Passed: The output of ${TEST_PROGRAM} matches ${TEST_REFERENCE}" )