From 6e655176cbcd17437ceacbb6b90f38a50026b64c Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 27 Oct 2017 14:31:33 +0100 Subject: [PATCH] ECC-567: codes_split_file test added --- tests/CMakeLists.txt | 1 + tests/codes_split_file.sh | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100755 tests/codes_split_file.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7e44e19e5..943442cc3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -134,6 +134,7 @@ list( APPEND tests_data_reqd grib_util_set_spec local_MeteoFrance grib_neg_fctime + codes_split_file ) if( HAVE_FORTRAN AND ENABLE_EXTRA_TESTS ) list(APPEND tests_data_reqd bufr_dump_encode_fortran) diff --git a/tests/codes_split_file.sh b/tests/codes_split_file.sh new file mode 100755 index 000000000..477edaea7 --- /dev/null +++ b/tests/codes_split_file.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Copyright 2005-2017 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.sh + +#Define a common label for all the tmp files +label="codes_split_file" + +# Do all the work in a temporary directory +temp_dir=tempdir.${label} +mkdir -p $temp_dir + +# Test 1: File with 3 messages +# ----------------------------- +cp ${data_dir}/mixed.grib $temp_dir +input=$temp_dir/mixed.grib +${tools_dir}/codes_split_file 3 $input +# There should now be 3 new files. Make sure they are valid +${tools_dir}/grib_ls $temp_dir/mixed.grib_1 +${tools_dir}/grib_ls $temp_dir/mixed.grib_2 +${tools_dir}/grib_ls $temp_dir/mixed.grib_3 + +total=`${tools_dir}/codes_count $temp_dir/mixed.grib_[1-3]` +[ $total -eq 14 ] + +# Test 2: File with 248 messages +# ----------------------------- +cp ${data_dir}/tigge_ecmwf.grib2 $temp_dir +input=$temp_dir/tigge_ecmwf.grib2 +${tools_dir}/codes_split_file 10 $input +total=`${tools_dir}/codes_count $temp_dir/tigge_ecmwf.grib2_[0-9]*` +[ $total -eq 248 ] + + +# Clean up +rm -fr $temp_dir