Commit 3e86fa43 authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Add roundtrip integration test

if cmake parameters TEST_SEGY_FILE and TEST_URL with optional
TEST_CONNECTION then the test will used said parameters import the SEGY
file with default parameters, and then export the VDS to a local SEGY
file. It will then do a SHA256 hash of both files and validate that the
hashes er the same.
parent eafe10aa
......@@ -12,6 +12,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
include(GNUInstallDirs)
set (TEST_DATA_PATH "" CACHE PATH "Test data path")
set (TEST_SEGY_FILE "" CACHE FILEPATH "SEGY test file")
set (TEST_URL "" CACHE STRING "Test url for OpenOptions")
set (TEST_CONNECTION "" CACHE STRING "Test connection string for OpenOptions")
......
......@@ -104,6 +104,18 @@ add_test_executable(openvds_mixed_request
OpenVDS/RequestVolumeSubsetAndPageAccessor.cpp
)
if (TEST_SEGY_FILE AND TEST_URL)
add_test(NAME "tools.SegyRoundtrip"
COMMAND ${CMAKE_COMMAND}
-DSEGYImport=$<TARGET_FILE:SEGYImport>
-DSEGYExport=$<TARGET_FILE:SEGYExport>
-DTEST_URL=${TEST_URL}
-DTEST_CONNECTION=${TEST_CONNECTION_ESCAPED}
-DTEST_SEGY_FILE=${TEST_SEGY_FILE}
-P ${CMAKE_CURRENT_SOURCE_DIR}/RunRoundtrip.cmake
)
endif()
if (BUILD_PYTHON)
add_subdirectory(python)
endif()
......
function(check_variable variable)
if (NOT ${variable})
message(FATAL_ERROR "Missing ${variable} variable")
endif()
endfunction()
check_variable(SEGYImport)
check_variable(SEGYExport)
check_variable(TEST_URL)
check_variable(TEST_SEGY_FILE)
set(connection_parameter "--url ${TEST_URL}")
if (TEST_CONNECTION)
set(CONNECTION "--connection")
endif()
execute_process(COMMAND ${SEGYImport} --persistentID roundtrip_test --url "${TEST_URL}" ${CONNECTION} ${TEST_CONNECTION} ${TEST_SEGY_FILE} RESULT_VARIABLE CMD_RESULT)
if (CMD_RESULT)
message(FATAL_ERROR "Failed to run SEGYImport")
endif()
execute_process(COMMAND ${SEGYExport} --persistentID roundtrip_test --url "${TEST_URL}" ${CONNECTION} ${TEST_CONNECTION} roundtrip_test.segy RESULT_VARIABLE CMD_RESULT)
if (CMD_RESULT)
message(FATAL_ERROR "Failed to run SEGYExport")
endif()
file(SHA256 ${TEST_SEGY_FILE} INPUT_SHA)
file(SHA256 roundtrip_test.segy OUTPUT_SHA)
if (INPUT_SHA STREQUAL OUTPUT_SHA)
message("Input segy is equal to output segy. Compared hash is ${INPUT_SHA}")
else()
message(FATAL_ERROR "The generated SEGY file is not equal to the input SEGY file")
endif()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment