CMake tests for python

This commit is contained in:
Shahram Najm 2014-03-31 17:15:20 +01:00
parent 31f0e88a45
commit 7330411051
8 changed files with 54 additions and 97 deletions

View File

@ -32,7 +32,6 @@ list( APPEND test_bins
clone
)
foreach( tool ${test_bins} )
# here we use the fact that each tool has only one C file that matches its name
ecbuild_add_executable( TARGET ${tool}
NOINSTALL
SOURCES ${tool}.c
@ -42,79 +41,29 @@ endforeach()
# Now add each test
#################################################
ecbuild_add_test( TARGET c_iterator
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/iterator.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_get
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_print_data
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/print_data.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_set
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/set.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_keys_iterator
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/keys_iterator.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_multi
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/multi.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_multi_write
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/multi_write.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_precision
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/precision.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_list
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/list.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_large_grib1
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/large_grib1.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_get_data
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get_data.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_set_missing
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/set_missing.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_clone
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/clone.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET c_sections_copy
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/sections_copy.sh
RESOURCES include.sh
list( APPEND tests
iterator
get
print_data
set
keys_iterator
multi
multi_write
precision
list
large_grib1
get_data
set_missing
clone
sections_copy
)
foreach (test ${tests})
ecbuild_add_test( TARGET c_${test}
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh
RESOURCES include.sh
)
endforeach()
#############################################
@ -123,5 +72,6 @@ ecbuild_add_test( TARGET c_new_sample
SOURCES new_sample.c
LIBS grib_api
ARGS "out.grib"
ENVIRONMENT "GRIB_SAMPLES_PATH=${PROJECT_SOURCE_DIR}/samples" "GRIB_DEFINITION_PATH=${PROJECT_SOURCE_DIR}/definitions" )
ENVIRONMENT "GRIB_SAMPLES_PATH=${PROJECT_SOURCE_DIR}/samples" "GRIB_DEFINITION_PATH=${PROJECT_SOURCE_DIR}/definitions"
)

View File

@ -1,3 +1,4 @@
add_subdirectory(C)
add_subdirectory(F90)
add_subdirectory(python)

View File

@ -5,11 +5,11 @@ TESTS = clone.sh count_messages.sh get.sh index.sh iterator.sh keys_iterator.sh
samples.sh set.sh set_missing.sh binary_message.sh set_bitmap.sh
TESTS_ENVIRONMENT = TOPBUILDDIR=$(top_builddir) PYTHON=$(PYTHON)
noinst_PROGRAMS = keys_iterator print_data iterator count_messages
keys_iterator_SOURCES = keys_iterator.c
print_data_SOURCES = print_data.c
iterator_SOURCES = iterator.c
count_messages_SOURCES = count_messages.c
noinst_PROGRAMS = p_keys_iterator p_print_data p_iterator p_count_messages
p_keys_iterator_SOURCES = keys_iterator.c
p_print_data_SOURCES = print_data.c
p_iterator_SOURCES = iterator.c
p_count_messages_SOURCES = count_messages.c
INCLUDES = -I$(top_builddir)/src
LDADD = $(top_builddir)/src/libgrib_api.la
DEPENDENCIES = $(LDADD)

View File

@ -6,7 +6,7 @@ TEMP1=temp1
TEMP2=temp2
$PYTHON count_messages.py 2> $TEMP1 > $TEMP1
./count_messages ../../data/tigge_pf_ecmwf.grib2 2> $TEMP2 > $TEMP2
./p_count_messages ../../data/tigge_pf_ecmwf.grib2 2> $TEMP2 > $TEMP2
diff $TEMP1 $TEMP2
rm $TEMP1 $TEMP2 || true

View File

@ -1,19 +1,25 @@
set -ea
CMAKE_INCLUDE_FILE=include.ctest.sh
if [ -f "$CMAKE_INCLUDE_FILE" ]; then
# This is the config file for Cmake tests
. ./$CMAKE_INCLUDE_FILE
echo
echo "TEST: $0"
else
set -ea
echo
echo "TEST: $0"
cpath=$TOPBUILDDIR
GRIB_DEFINITION_PATH=$cpath/definitions
export GRIB_DEFINITION_PATH
GRIB_SAMPLES_PATH=$cpath/samples
export GRIB_SAMPLES_PATH
tools_dir=$cpath/tools/
examples_dir=$cpath/examples/python
data_dir=$cpath/data
cpath=$TOPBUILDDIR
GRIB_DEFINITION_PATH=$cpath/definitions
export GRIB_DEFINITION_PATH
GRIB_SAMPLES_PATH=$cpath/samples
export GRIB_SAMPLES_PATH
tools_dir=$cpath/tools/
examples_dir=$cpath/examples/python
data_dir=$cpath/data
PYTHONPATH=$cpath/python:$cpath/python/.libs:$PYTHONPATH
export PYTHONPATH
PYTHONPATH=$cpath/python:$cpath/python/.libs:$PYTHONPATH
export PYTHONPATH
set -u
set -u
fi

View File

@ -6,7 +6,7 @@ TEMP1=temp1
TEMP2=temp2
$PYTHON iterator.py 2> $TEMP1 > $TEMP1
./iterator ../../data/reduced_latlon_surface.grib1 2> $TEMP2 > $TEMP2
./p_iterator ../../data/reduced_latlon_surface.grib1 2> $TEMP2 > $TEMP2
diff $TEMP1 $TEMP2
rm $TEMP1 $TEMP2 || true

View File

@ -6,7 +6,7 @@ TEMP1=temp1
TEMP2=temp2
$PYTHON keys_iterator.py 2> $TEMP1 > $TEMP1
./keys_iterator ../../data/reduced_latlon_surface.grib1 2> $TEMP2 > $TEMP2
./p_keys_iterator ../../data/reduced_latlon_surface.grib1 2> $TEMP2 > $TEMP2
diff $TEMP1 $TEMP2
rm $TEMP1 $TEMP2 || true

View File

@ -6,7 +6,7 @@ TEMP1=temp1
TEMP2=temp2
$PYTHON print_data.py 2> $TEMP1 > $TEMP1
./print_data ../../data/regular_latlon_surface.grib1 2> $TEMP2 > $TEMP2
./p_print_data ../../data/regular_latlon_surface.grib1 2> $TEMP2 > $TEMP2
diff $TEMP1 $TEMP2
rm $TEMP1 $TEMP2 || true