eccodes/tests/bufr_count.sh

46 lines
1.1 KiB
Bash
Raw Normal View History

2015-02-03 09:14:05 +00:00
#!/bin/sh
2020-01-28 14:32:34 +00:00
# (C) Copyright 2005- ECMWF.
2015-02-03 09:14:05 +00:00
#
# 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.ctest.sh
2015-02-03 09:14:05 +00:00
label="bufr_count_test"
temp=temp.$label.truncated.bufr
# Enter data dir
2015-02-03 09:14:05 +00:00
cd ${data_dir}/bufr
input=syno_multi.bufr
2015-02-03 09:14:05 +00:00
# Counting valid messages
# ------------------------
count=`${tools_dir}/bufr_count $input`
[ "$count" = "3" ]
count=`${tools_dir}/codes_count $input`
2015-02-03 09:14:05 +00:00
[ "$count" = "3" ]
# Files with invalid (unreadable) messages
# -----------------------------------------
# BUFR file size = 660 bytes. Write out only the first 640 bytes
# thereby creating an unreadable final message
head -c 640 $input > $temp
set +e
# Without -f, bufr_count should fail
${tools_dir}/bufr_count $temp
status=$?
set -e
[ $status -ne 0 ]
# With -f should count the valid messages
vcount=`${tools_dir}/bufr_count -f $temp`
[ "$vcount" = "2" ]
# Clean up
rm -f $temp