Fix failing tests: bufr_ls and bufr_read_header

This commit is contained in:
Shahram Najm 2015-01-22 11:55:55 +00:00
parent bd423aa499
commit 8392a110e1
6 changed files with 71 additions and 88 deletions

View File

@ -401,9 +401,9 @@ set(bufr_refs_to_download
tmr7_129.bufr.desc.ref
tros_31.bufr.desc.ref
wavb_134.bufr.desc.ref
aaen_55.bufr.ls.ref
syno_multi.bufr.header.ref
syno_multi.bufr
)
foreach( f ${bufr_files_to_download} ${bufr_refs_to_download} )

View File

@ -493,6 +493,7 @@ files="
bufr/syno_2.bufr
bufr/syno_3.bufr
bufr/syno_4.bufr
bufr/syno_multi.bufr
bufr/temp_101.bufr
bufr/temp_102.bufr
bufr/temp_106.bufr
@ -764,6 +765,8 @@ files="
bufr/tmr7_129.bufr.desc.ref
bufr/tros_31.bufr.desc.ref
bufr/wavb_134.bufr.desc.ref
bufr/aaen_55.bufr.ls.ref
bufr/syno_multi.bufr.header.ref
"
[ -d "${DATA_DIR}/tigge" ] || mkdir "${DATA_DIR}/tigge"

View File

@ -1,5 +1,5 @@
TESTS = definitions.sh calendar.sh \
bufrdc_desc_ref.sh bufrdc_ref.sh bufr_dump.sh bufr_json.sh\
bufrdc_desc_ref.sh bufrdc_ref.sh bufr_dump.sh bufr_json.sh bufr_read_header.sh bufr_ls.sh \
ieee.sh grib1to2.sh \
unit_tests.sh \
grib2to1.sh badgrib.sh ls.sh filter.sh \
@ -16,7 +16,7 @@ TESTS = definitions.sh calendar.sh \
noinst_PROGRAMS = packing_check gauss_sub read_any double_cmp packing pack_unpack \
multi_from_message julian read_index index gribex_perf\
jpeg_perf ccsds_perf so_perf png_perf bpv_limit laplacian \
unit_tests
unit_tests bufr_read_header
multi_from_message_SOURCES = multi_from_message.c
laplacian_SOURCES = laplacian.c
@ -35,6 +35,7 @@ png_perf_SOURCES = png_perf.c
ccsds_perf_SOURCES = ccsds_perf.c
gribex_perf_SOURCES = gribex_perf.c
gauss_sub_SOURCES = gauss_sub.c
bufr_read_header_SOURCES = bufr_read_header.c
LDADD = $(top_builddir)/src/libgrib_api.la $(EMOS_LIB)

View File

@ -10,19 +10,17 @@
. ./include.sh
set -x
#set -x
#Remember work dir
dWork=`pwd`
#Enter data dir
cd ${data_dir}/bufr
fLog="log"
rm -f $fLog | true
fLog="bufr_ls.log"
rm -f $fLog
fTmp="tmp.txt"
rm -f $fTmp | true
fTmp="tmp.bufr_ls.txt"
rm -f $fTmp
#Create log filemore lev
touch $fLog
@ -30,16 +28,14 @@ touch $fLog
#----------------------------------------------
# Test default "ls" on all the bufr data files
#----------------------------------------------
for f in `ls *.bufr` ; do
echo $f >> log
echo $f >> $fLog
${tools_dir}/bufr_ls $f >> $fLog
done
#-------------------------------------------
# Test "-p" switch
#-------------------------------------------
f="aaen_55.bufr"
ref_ls=$f".ls.ref"
res_ls=$f".ls.test"
@ -47,11 +43,8 @@ REDIRECT=/dev/null
${tools_dir}/bufr_ls -p totalLength,centre,subCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,numberOfObservations $f 2> $REDIRECT > $fTmp
#Write the values into a file and compare to ref
#Write the values into a file and compare with ref
awk NR==3 $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_ls
diff $ref_ls $res_ls >$REDIRECT 2> $REDIRECT
[ $? -eq 0 ]
#Go back to workdir
cd $dWork
rm -f $fLog $res_ls $fTmp

View File

@ -15,13 +15,12 @@ void usage(char* prog) {
exit(1);
}
int main(int argc,char* argv[]) {
int main(int argc,char* argv[])
{
char* filename;
FILE* f;
codes_handle* h=NULL;
long longVal;
double doubleVal;
int count;
int err=0;
int header_only=1;
@ -36,10 +35,9 @@ int main(int argc,char* argv[]) {
}
count=1;
while((h=bufr_new_from_file(NULL,f,header_only,&err)) != NULL)
{
/* Check of errors after reading a message. */
/* Check for errors after reading a message. */
if (err != CODES_SUCCESS) CODES_CHECK(err,0);
printf("=======================================\n");
@ -47,27 +45,24 @@ int main(int argc,char* argv[]) {
/*From section 0 */
CODES_CHECK(codes_get_long(h,"totalLength",&longVal),0);
printf("\ttotalLength: %d\n",longVal);
printf("\ttotalLength: %ld\n",longVal);
/*From section 1 */
CODES_CHECK(codes_get_long(h,"centre",&longVal),0);
printf("\tcentre: %d\n",longVal);
printf("\tcentre: %ld\n",longVal);
/*From section 2 */
CODES_CHECK(codes_get_long(h,"rdbtimeDay",&longVal),0);
printf("\trdbtimeDay: %d\n",longVal);
printf("\trdbtimeDay: %ld\n",longVal);
/*From section 3 */
/*CODES_CHECK(codes_get_long(h,"numberOfSubsets",&longVal),0);
printf("\tnumberOfSubsets: %d\n",longVal);*/
count++;
codes_handle_delete(h);
}
fclose(f);
return 0;
}

View File

@ -12,20 +12,13 @@
set -x
#Remember work dir
dWork=`pwd`
#Enter data dir
cd ${data_dir}/bufr
fTmp="tmp.txt"
rm -f $fTmp | true
#-----------------------------------------------------
# Test reading the header only from a
# Test reading the header only from a BUFR
# file with multiple messages
#----------------------------------------------------
f="syno_multi.bufr"
fRef=$f".header.ref"
fRes=$f".header.test"
@ -33,9 +26,7 @@ REDIRECT=/dev/null
${test_dir}/bufr_read_header ${data_dir}/bufr/$f 2> $REDIRECT > $fRes
#Write the values into a file and compare to ref
#Write the values into a file and compare with reference
diff $fRef $fRes >$REDIRECT 2> $REDIRECT
[ $? -eq 0 ]
#Go back to workdir
cd $dWork
rm -f $fRes