File: gts_compare.sh

package info (click to toggle)
eccodes 2.46.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 154,956 kB
  • sloc: cpp: 163,970; ansic: 26,310; sh: 22,006; f90: 6,854; perl: 6,361; python: 5,352; java: 2,226; javascript: 1,427; yacc: 854; fortran: 543; lex: 359; makefile: 279; xml: 183; awk: 66
file content (126 lines) | stat: -rwxr-xr-x 3,414 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
# (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

# Enter data dir
cd ${data_dir}/gts

# Define a common label for all the tmp files
label="gts_compare_test"

fLog=${label}".log"
rm -f $fLog
touch $fLog

fGtsTmp=${label}".gts.tmp"
fRules=${label}".filt"

#----------------------------------------------------
# Test: comparing same files
#----------------------------------------------------
gts_file="EGRR20150317121020_00493212.DAT"
echo "Test: comparing the same files" >> $fLog
echo "file: $gts_file" >> $fLog
${tools_dir}/gts_compare $gts_file $gts_file

${tools_dir}/gts_compare -v -c totalLength $gts_file $gts_file > /dev/null

#----------------------------------------------------
# Test: comparing with skip
#----------------------------------------------------
gts_file="EGRR20150317121020_00493212.DAT"
${tools_dir}/gts_compare -w TT=SA $gts_file $gts_file

#----------------------------------------------------
# Test: comparing two different files
#----------------------------------------------------
cat > $fRules<<EOF
 if (count == 1) { set GG="01"; }
 write;
EOF
${tools_dir}/gts_filter -o $fGtsTmp $fRules $gts_file
set +e
${tools_dir}/gts_compare -v -f $gts_file $fGtsTmp
status=$?
set -e
if [ $status -eq 0 ]; then
   echo "ERROR: gts_compare should have failed if files are different" >&2
   exit 1
fi

#----------------------------------------------------
# Test: comparing with and without the -b switch
#----------------------------------------------------
# Add wrong blocklist. Should still fail
set +e
${tools_dir}/gts_compare -b CCCC $gts_file $fGtsTmp
status=$?
set -e
[ $status -eq 1 ]
# Add correct blocklist
${tools_dir}/gts_compare -b GG $gts_file $fGtsTmp
${tools_dir}/gts_compare -b CCCC,GG $gts_file $fGtsTmp

#----------------------------------------------------
# Compare using -c
#----------------------------------------------------
temp1=temp.$label.1.gts
temp2=temp.$label.2.gts
# Pick two messages which do have different contents
${tools_dir}/gts_copy -w count=1 $gts_file $temp1
${tools_dir}/gts_copy -w count=4 $gts_file $temp2
${tools_dir}/gts_compare -c theMessage $temp1 $temp2
${tools_dir}/gts_compare -c theMessage -a $temp1 $temp2

set +e
${tools_dir}/gts_compare -c ls:n $temp1 $temp2 > /dev/null
status=$?
set -e
[ $status -eq 1 ]

set +e
${tools_dir}/gts_compare -c ls:n -a $temp1 $temp2 > /dev/null
status=$?
set -e
[ $status -eq 1 ]

rm -f $temp1 $temp2

#----------------------------------------------------
# Test with file of the same name in a dir
#----------------------------------------------------
tempDir=temp.$label.dir
rm -fr $tempDir
mkdir $tempDir
cp $gts_file $tempDir
${tools_dir}/gts_compare $gts_file $tempDir
rm -r $tempDir

# Options
set +e
${tools_dir}/gts_compare -a $gts_file $gts_file > $fLog 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "option requires" $fLog


# Non-existence
set +e
${tools_dir}/gts_compare non-exist1 non-exist2 > $fLog 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "No such file or directory" $fLog


# Clean up
rm -f $fLog $fGtsTmp $fRules