mirror of
https://github.com/Unidata/netcdf-cxx4.git
synced 2025-02-17 18:59:31 +08:00
Adding more infrastructure for shell testing.
This commit is contained in:
parent
52a03c5afa
commit
268c5ce0b6
@ -123,6 +123,21 @@ EXECUTE_PROCESS(
|
||||
IF(CONFIG_DATE)
|
||||
string(STRIP ${CONFIG_DATE} CONFIG_DATE)
|
||||
ENDIF()
|
||||
|
||||
# Check to see if we have bash.
|
||||
FIND_PROGRAM(HAVE_BASH bash)
|
||||
IF(HAVE_BASH)
|
||||
STRING(COMPARE EQUAL "${HAVE_BASH}" "C:/Windows/System32/bash.exe" IS_BASH_EXE)
|
||||
IF(NOT IS_BASH_EXE)
|
||||
MESSAGE(STATUS "Found bash: ${HAVE_BASH}")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Ignoring ${HAVE_BASH}")
|
||||
SET(HAVE_BASH "")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Bash shell not found; disabling shell script tests.")
|
||||
ENDIF()
|
||||
|
||||
##
|
||||
# Allow for extra dependencies.
|
||||
##
|
||||
@ -194,6 +209,33 @@ MACRO(add_bin_test prefix F)
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
###
|
||||
# A macro to add a shell test.
|
||||
###
|
||||
MACRO(add_sh_test prefix F)
|
||||
IF(HAVE_BASH)
|
||||
ADD_TEST(${prefix}_${F} bash "-c" "export srcdir=${CMAKE_CURRENT_SOURCE_DIR};export TOPSRCDIR=${CMAKE_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}/${F}.sh")
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
# Build a binary used by a script, but don't make a test out of it.
|
||||
MACRO(build_bin_test F)
|
||||
ADD_EXECUTABLE(${F} ${F}.cpp)
|
||||
TARGET_LINK_LIBRARIES(${F} netcdf-cxx4 ${ALL_TLL_LIBS})
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(${F}
|
||||
PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
||||
)
|
||||
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
################################
|
||||
# End Utility Macros
|
||||
################################
|
||||
@ -537,22 +579,12 @@ INSTALL(PROGRAMS ${NCXX_BINARY_DIR}/ncxx4-config
|
||||
#####
|
||||
|
||||
#####
|
||||
# Build cxx4/findplugin.sh
|
||||
# Build test_common.sh
|
||||
#####
|
||||
|
||||
|
||||
|
||||
#####
|
||||
# Build cxx4/findplugin.sh
|
||||
#####
|
||||
IF(NC_HAS_DEF_VAR_FILTER)
|
||||
SET(ISCMAKE "1")
|
||||
configure_file(${CMAKE_SOURCE_DIR}/cxx4/findplugin.in ${CMAKE_BINARY_DIR}/cxx4/findplugin.sh @ONLY NEWLINE_STYLE LF)
|
||||
ENDIF(NC_HAS_DEF_VAR_FILTER)
|
||||
#####
|
||||
# End findplugin.sh
|
||||
#####
|
||||
|
||||
SET(EXTRA_DIST ${EXTRA_DIST} ${CMAKE_SOURCE_DIR}/test_common.in)
|
||||
SET(TOPSRCDIR "${CMAKE_SOURCE_DIR}")
|
||||
SET(TOPBUILDDIR "${CMAKE_BINARY_DIR}")
|
||||
configure_file(${CMAKE_SOURCE_DIR}/test_common.in ${CMAKE_BINARY_DIR}/test_common.sh @ONLY NEWLINE_STYLE LF)
|
||||
|
||||
#####
|
||||
# Options
|
||||
@ -592,6 +624,7 @@ IF(NC_HAS_DEF_VAR_FILTER)
|
||||
#####
|
||||
SET(ISCMAKE "1")
|
||||
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cxx4/findplugin.in ${CMAKE_BINARY_DIR}/cxx4/findplugin.sh @ONLY NEWLINE_STYLE LF)
|
||||
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/examples/findplugin.in ${CMAKE_BINARY_DIR}/examples/findplugin.sh @ONLY NEWLINE_STYLE LF)
|
||||
|
||||
ADD_SUBDIRECTORY(plugins)
|
||||
ENDIF(NC_HAS_DEF_VAR_FILTER)
|
||||
|
@ -281,6 +281,7 @@ AC_SUBST(HAS_NC4,[$nc_build_v4])
|
||||
AC_SUBST(NC_HAS_FILTERS, [$nc_has_filters])
|
||||
|
||||
AC_MSG_NOTICE([generating header files and makefiles])
|
||||
AC_CONFIG_FILES(test_common.sh:test_common.in)
|
||||
AC_CONFIG_FILES([Makefile
|
||||
cxx4/Makefile
|
||||
examples/Makefile
|
||||
@ -293,4 +294,6 @@ if test "x$nc_has_filters" = xyes; then
|
||||
AC_CONFIG_FILES(cxx4/findplugin.sh:cxx4/findplugin.in)
|
||||
fi
|
||||
|
||||
|
||||
|
||||
AC_OUTPUT()
|
||||
|
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
||||
. ../test_common.sh
|
||||
|
||||
# Which test cases to exercise
|
||||
API=1
|
||||
NG=1
|
||||
NCP=1
|
||||
UNK=1
|
||||
NGC=1
|
||||
MISC=1
|
||||
|
||||
# Load the findplugins function
|
||||
. ${builddir}/findplugin.sh
|
||||
echo "findplugin.sh loaded"
|
@ -9,11 +9,18 @@ IF(NCXX_ENABLE_TESTS)
|
||||
add_bin_test(examples sfc_pres_temp_wr)
|
||||
add_bin_test(examples pres_temp_4D_wr)
|
||||
add_bin_test(examples pres_temp_4D_rd)
|
||||
add_bin_test(examples pres_temp_4D_plugin_wr)
|
||||
add_bin_test(examples pres_temp_4D_plugin_rd)
|
||||
add_bin_test(examples simple_xy_rd)
|
||||
add_bin_test(examples sfc_pres_temp_rd)
|
||||
add_bin_test(examples simple_xy_wr_formats)
|
||||
add_bin_test(examples aodhan_trial)
|
||||
build_bin_test(aodhan_trial)
|
||||
|
||||
IF(NC_HAS_DEF_VAR_FILTER)
|
||||
build_bin_test(pres_temp_4D_plugin_wr)
|
||||
build_bin_test(pres_temp_4D_plugin_rd)
|
||||
add_sh_test(examples tst_filter)
|
||||
ENDIF(NC_HAS_DEF_VAR_FILTER)
|
||||
|
||||
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
|
||||
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
|
||||
|
||||
ENDIF()
|
||||
|
107
examples/findplugin.in
Normal file
107
examples/findplugin.in
Normal file
@ -0,0 +1,107 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define a function that attempts to locate a
|
||||
# plugin with a given canonical name.
|
||||
# Assumptions:
|
||||
# 1. plugins is a top-level directory
|
||||
# Inputs:
|
||||
# $1 is the canonical name
|
||||
# $2 is 1 if we are running under cmake
|
||||
# $3 is 1 if we are running using Visual Studio, blank otherwise
|
||||
# $4 is the build type; only used if $3 is 1
|
||||
# Outputs:
|
||||
# return code is 0 is success, 1 if failed
|
||||
# Variable HDF5_PLUGIN_LIB is set to the library file name
|
||||
# Variable HDF5_PLUGIN_PATH is setthe absolute path to the
|
||||
# directory containing the plugin library file
|
||||
# Local variables are prefixed with FP_
|
||||
#
|
||||
# Note: we assume that the use of the CMAKE_BUILD_TYPE
|
||||
# is obviated by setting the LIBRARY_OUTPUT_DIRECTORY
|
||||
# variables: see hdf5plugins/CMakeLists.txt
|
||||
|
||||
findplugin() {
|
||||
|
||||
FP_NAME="$1"
|
||||
|
||||
# Figure out the compiler (some values from ./configure)
|
||||
FP_ISCMAKE=@ISCMAKE@
|
||||
FP_ISMSVC=@MSVC@
|
||||
|
||||
# And topsrcdir
|
||||
topbuilddir='@abs_top_builddir@'
|
||||
|
||||
# Are we operating under OS-X? (test using uname)
|
||||
FP_OS=`uname | cut -d '_' -f 1`
|
||||
if test "x$FP_OS" = xDarwin ; then FP_ISOSX=1; fi
|
||||
|
||||
# Are we operating under CYGWIN? (test using uname)
|
||||
FP_OS=`uname | cut -d '_' -f 1`
|
||||
if test "x$FP_OS" = xCYGWIN ; then FP_ISCYGWIN=1; fi
|
||||
|
||||
FP_PLUGINS="$topbuilddir/plugins"
|
||||
|
||||
FP_PLUGIN_LIB=
|
||||
FP_PLUGIN_PATH=
|
||||
|
||||
# Figure out the plugin file name
|
||||
# Test for visual studio before cygwin since both might be true
|
||||
if test "x$FP_ISMSVC" != x ; then
|
||||
FP_PLUGIN_LIB="${FP_NAME}.dll"
|
||||
elif test "x$FP_ISCYGWIN" != x ; then
|
||||
FP_PLUGIN_LIB="cyg${FP_NAME}.dll"
|
||||
elif test "x$FP_ISOSX" != x ; then
|
||||
FP_PLUGIN_LIB="lib${FP_NAME}.so" # Should this include the version number in the name?
|
||||
else # Presumably some form on *nix"
|
||||
FP_PLUGIN_LIB="lib${FP_NAME}.so"
|
||||
fi
|
||||
|
||||
# Figure out the path to where the lib is stored
|
||||
# This can probably be simplified
|
||||
# Case 1: Cmake with Visual Studio
|
||||
# Do not know where to look for a dylib
|
||||
# Case 1: Cmake with Visual Studio
|
||||
if test "x$FP_ISCMAKE" != x -a "x${FP_ISMSVC}" != x ; then
|
||||
# Case 1a: ignore the build type directory
|
||||
if test -f "${FP_PLUGINS}/${FP_PLUGIN_LIB}" ; then
|
||||
FP_PLUGIN_PATH="${FP_PLUGINS}"
|
||||
fi
|
||||
else # Case 2: automake
|
||||
# Case 2a: look in .libs
|
||||
if test -f "${FP_PLUGINS}/.libs/${FP_PLUGIN_LIB}" ; then
|
||||
FP_PLUGIN_PATH="${FP_PLUGINS}/.libs"
|
||||
else # Case 2: look in FP_PLUGINS directly
|
||||
if test -f "${FP_PLUGINS}/${FP_PLUGIN_LIB}" ; then
|
||||
FP_PLUGIN_PATH="${FP_PLUGINS}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Verify
|
||||
if test "x$FP_PLUGIN_PATH" = x ; then
|
||||
echo "***Fail: Could not locate a usable HDF5_PLUGIN_PATH"
|
||||
return 1
|
||||
fi
|
||||
if ! test -f "$FP_PLUGIN_PATH/$FP_PLUGIN_LIB" ; then
|
||||
echo "***Fail: Could not locate a usable HDF5_PLUGIN_LIB"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If we are operating using both Visual Studio and Cygwin,
|
||||
# then we need to convert the FP_PLUGIN_PATH to windows format
|
||||
if test "x$FP_ISMSVC" != x -a "x$FP_ISCYGWIN" != x ; then
|
||||
FP_PLUGIN_PATH=`cygpath -wl $FP_PLUGIN_PATH`
|
||||
fi
|
||||
|
||||
# Set the final output variables
|
||||
HDF5_PLUGIN_LIB="$FP_PLUGIN_LIB"
|
||||
HDF5_PLUGIN_PATH="$FP_PLUGIN_PATH"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# debug
|
||||
if test "x$1" != x ; then
|
||||
findplugin
|
||||
echo "HDF5_PLUGIN_PATH=|$FP_PLUGIN_PATH|"
|
||||
fi
|
19
examples/tst_filter.sh
Executable file
19
examples/tst_filter.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
||||
. ../test_common.sh
|
||||
|
||||
# Which test cases to exercise
|
||||
API=1
|
||||
NG=1
|
||||
NCP=1
|
||||
UNK=1
|
||||
NGC=1
|
||||
MISC=1
|
||||
|
||||
# Load the findplugins function
|
||||
. ${builddir}/findplugin.sh
|
||||
echo "findplugin.sh loaded"
|
||||
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user