##############################################################################
# @file  CMakeLists.txt
# @brief Build configuration of software testing.
#
# Unit tests test only single functions, classes, and modules of the software.
# System tests, on the other side, execute the programs of this package with
# given test input data and compare the output of the programs to the expected
# results.
#
# The built test executables can be found in @c TESTING_RUNTIME_DIR.
# The test output shall be written to @c TESTING_OUTPUT_DIR. In most cases,
# a subdirectory for each test should be created under this output directory.
#
# Copyright (c) 2012, University of Pennsylvania. All rights reserved.<br />
# See http://www.rad.upenn.edu/sbia/software/license.html or COPYING file.
#
# Contact: SBIA Group <sbia-software at uphs.upenn.edu>
##############################################################################

# ============================================================================
# common settings
# ============================================================================

set (INPUT_DIR    "${PROJECT_TESTING_DIR}/input")
set (BASELINE_DIR "${PROJECT_TESTING_DIR}/baseline")

if (OpenCV_VERSION VERSION_LESS "2.0")
  set (BASELINE_SUFFIX "opencv-1.0")
elseif (OpenCV_VERSION VERSION_GREATER "2.3")
  set (BASELINE_SUFFIX "opencv-2.3")
else ()
  set (BASELINE_SUFFIX "opencv-2.0")
endif ()

# ============================================================================
# tests
# ============================================================================

# ----------------------------------------------------------------------------
# test odvba-index
basis_add_test(test_odvba-index.py)

# ----------------------------------------------------------------------------
# test odvba-ni
basis_add_test (test_odvba-ni.py)

# ----------------------------------------------------------------------------
# test odvba
basis_add_test(
  test_odvba
  COMMAND
    basis.testdriver -v
      # check p-values map
      --intensity-tolerance 0.01
      --compare "p.nii.gz"
                "${BASELINE_DIR}/32_32_32/p-values.n4000_e50_s15_p25.${BASELINE_SUFFIX}.nii.gz"
      # test command
      -- $<TARGET_FILE:odvba> -v -v
          "${INPUT_DIR}/32_32_32/subjects.txt"
          --index "${INPUT_DIR}/32_32_32/index.txt"
          --ni "${INPUT_DIR}/32_32_32/ni_n4000_e50_s15.txt"
          --perms "${INPUT_DIR}/32_32_32/perms_p25.txt"
)
