eccodes/tests/metar_compare.sh

62 lines
1.9 KiB
Bash
Raw Normal View History

#!/bin/sh
2020-01-28 14:32:34 +00:00
# (C) Copyright 2005- 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.ctest.sh
2023-08-23 21:18:44 +00:00
# Enter data dir
cd ${data_dir}/metar
2023-08-23 21:18:44 +00:00
# Define a common label for all the tmp files
label="metar_compare_test"
2023-08-23 21:18:44 +00:00
# Create log file
fLog=${label}".log"
rm -f $fLog
touch $fLog
2023-08-23 21:18:44 +00:00
# Define tmp METAR file
fMetarTmp=${label}".metar.tmp"
#----------------------------------------------------
# Test: comparing same files
#----------------------------------------------------
metar_file="metar.txt"
echo "Test: comparing the same files" >> $fLog
echo "file: $metar_file" >> $fLog
${tools_dir}/metar_compare $metar_file $metar_file
#----------------------------------------------------
# Test: comparing two different files
#----------------------------------------------------
sed -e 's:^METAR VECC 022350Z 00000KT 1600 BR NSC 15/13 Q1013 NOSIG:METAR VECC 022349Z 00000KT 1600 BR NSC 15/13 Q1013 NOSIG:' < metar.txt > $fMetarTmp
set +e
2023-08-23 21:18:44 +00:00
${tools_dir}/metar_compare -v -d $metar_file $fMetarTmp
status=$?
set -e
if [ $status -eq 0 ]; then
echo "metar_compare should have failed if files are different" >&2
exit 1
fi
2023-08-23 21:18:44 +00:00
# The -d option should have created these two files
[ -f error1_1.metar ]
[ -f error2_1.metar ]
[ -f error1_2.metar ]
[ -f error2_2.metar ]
rm -f error1_1.metar error2_1.metar error1_2.metar error2_2.metar
#----------------------------------------------------
2019-12-27 11:53:03 +00:00
# Test: comparing with and without the -b switch
#----------------------------------------------------
2023-08-23 21:18:44 +00:00
${tools_dir}/metar_compare -b minute,theMessage $metar_file $fMetarTmp
#Clean up
rm -f $fLog $fMetarTmp