ECC-431: bufr_compare two way. Added test

This commit is contained in:
Shahram Najm 2018-03-13 11:46:39 +00:00
parent d1439b61e0
commit eb697ebd2d
1 changed files with 25 additions and 8 deletions

View File

@ -35,7 +35,7 @@ fRules=${label}.filter
f="syno_1.bufr" f="syno_1.bufr"
echo "Test: comparing the same files" >> $fLog echo "Test: comparing the same files" >> $fLog
echo "file: $f" >> $fLog echo "file: $f" >> $fLog
${tools_dir}//bufr_compare $f $f >> $fLog ${tools_dir}/bufr_compare $f $f >> $fLog
#---------------------------------------------------- #----------------------------------------------------
# Test: comparing two completely different files # Test: comparing two completely different files
@ -45,7 +45,7 @@ f1="syno_1.bufr"
f2="aaen_55.bufr" f2="aaen_55.bufr"
echo "Test: comparing two completely different files" >> $fLog echo "Test: comparing two completely different files" >> $fLog
echo "file: $f" >> $fLog echo "file: $f" >> $fLog
${tools_dir}//bufr_compare $f1 $f2 >> $fLog ${tools_dir}/bufr_compare $f1 $f2 >> $fLog
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "bufr_compare should have failed if files are completely different" >&2 echo "bufr_compare should have failed if files are completely different" >&2
exit 1 exit 1
@ -60,10 +60,10 @@ echo "Test: comparing with and witout the -b switch" >> $fLog
echo "file: $f" >> $fLog echo "file: $f" >> $fLog
#Alter a key in the file #Alter a key in the file
${tools_dir}//bufr_set -s dataCategory=2 $f ${fBufrTmp} >> $fLog ${tools_dir}/bufr_set -s dataCategory=2 $f ${fBufrTmp} >> $fLog
set +e set +e
${tools_dir}//bufr_compare $f ${fBufrTmp}>> $fLog ${tools_dir}/bufr_compare $f ${fBufrTmp}>> $fLog
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "bufr_compare should have failed if files are different" >&2 echo "bufr_compare should have failed if files are different" >&2
exit 1 exit 1
@ -71,7 +71,7 @@ fi
set -e set -e
# Now compare with -b switch. No difference should be found. # Now compare with -b switch. No difference should be found.
${tools_dir}//bufr_compare -b dataCategory $f ${fBufrTmp}>> $fLog ${tools_dir}/bufr_compare -b dataCategory $f ${fBufrTmp}>> $fLog
#---------------------------------------------------- #----------------------------------------------------
# Test: comparing with the -r switch # Test: comparing with the -r switch
@ -81,13 +81,13 @@ ${tools_dir}//bufr_compare -b dataCategory $f ${fBufrTmp}>> $fLog
#cat temp_101.bufr syno_multi.bufr > $fBufrInput2 #cat temp_101.bufr syno_multi.bufr > $fBufrInput2
#set +e #set +e
#${tools_dir}//bufr_compare ${fBufrInput1} ${fBufrInput2} >> $fLog #${tools_dir}/bufr_compare ${fBufrInput1} ${fBufrInput2} >> $fLog
#if [ $? -eq 0 ]; then #if [ $? -eq 0 ]; then
# echo "bufr_compare should have failed if the message order in the files is different" >&2 # echo "bufr_compare should have failed if the message order in the files is different" >&2
# exit 1 # exit 1
#fi #fi
#set -e #set -e
#${tools_dir}//bufr_compare -r ${fBufrInput1} ${fBufrInput2}>> $fLog #${tools_dir}/bufr_compare -r ${fBufrInput1} ${fBufrInput2}>> $fLog
#---------------------------------------------------- #----------------------------------------------------
# Change subCentre and compare # Change subCentre and compare
@ -138,5 +138,22 @@ ${tools_dir}/codes_bufr_filter -o $fBufrTmp $fRules $f
# Header keys have not changed # Header keys have not changed
${tools_dir}/bufr_compare -H $f $fBufrTmp ${tools_dir}/bufr_compare -H $f $fBufrTmp
#Clean up #----------------------------------------------------
# Compare two-way (symmetric mode)
#----------------------------------------------------
f=$ECCODES_SAMPLES_PATH/BUFR3.tmpl
# Add a local section
${tools_dir}/bufr_set -s section2Present=1 $f $fBufrTmp
# Compare A with B will pass
${tools_dir}/bufr_compare $f $fBufrTmp
# Compare with -2 option
set +e
${tools_dir}/bufr_compare -2 $f $fBufrTmp > $fLog 2>&1
status=$?
set -e
[ $status -eq 1 ]
# Clean up
# -------------
rm -f $fLog $fBufrTmp $fBufrInput1 $fBufrInput2 $fRules rm -f $fLog $fBufrTmp $fBufrInput1 $fBufrInput2 $fRules