Skip to content

Commit fbce17e

Browse files
committed
Testing: Comparing thru indexes
1 parent 4d57fc7 commit fbce17e

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

tests/grib_indexing.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
label="grib_indexing_test"
1414
temp=temp.$label.index.out
1515
infile=${data_dir}/index.grib
16+
sample1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
1617

1718
# Writes to "out.gribidx"
1819
$EXEC ${test_dir}/grib_indexing ${infile} > $temp
@@ -109,9 +110,32 @@ ${tools_dir}/grib_index_build -N -o $tempIndex2 $tempGribFile2
109110
${tools_dir}/grib_compare -v $tempIndex1 $tempIndex2
110111
rm -f $tempIndex1 $tempIndex2 $tempGribFile1 $tempGribFile2
111112

113+
# Indexes containing different keys
114+
${tools_dir}/grib_index_build -k date,time -N -o $tempIndex1 $sample1
115+
${tools_dir}/grib_index_build -k level -N -o $tempIndex2 $sample1
116+
set +e
117+
${tools_dir}/grib_compare -v $tempIndex1 $tempIndex2 2>$tempOut
118+
status=$?
119+
set -e
120+
[ $status -ne 0 ]
121+
cat $tempOut
122+
grep -q "Indexes contained in the input files have different keys" $tempOut
123+
rm -f $tempIndex1 $tempIndex2 $tempOut
124+
125+
126+
${tools_dir}/grib_index_build -k date,time -N -o $tempIndex1 $sample1
127+
${tools_dir}/grib_index_build -k date,time,level -N -o $tempIndex2 $sample1
128+
set +e
129+
${tools_dir}/grib_compare -v $tempIndex2 $tempIndex1 2>$tempOut
130+
status=$?
131+
set -e
132+
[ $status -ne 0 ]
133+
cat $tempOut
134+
grep -q "Indexes contained in the input files have different keys" $tempOut
135+
rm -f $tempIndex1 $tempIndex2 $tempOut
136+
112137
# ECC-1516
113138
# ---------
114-
sample1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
115139
${tools_dir}/grib_index_build -N -o $tempIndex1 $sample1 > /dev/null
116140
${tools_dir}/grib_dump $tempIndex1 >/dev/null
117141

tools/grib_tools.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -511,17 +511,17 @@ static int grib_tool_index(grib_runtime_options* options)
511511
k2 = k2->next;
512512
}
513513
if (!found) {
514-
printf("Indexes contained in the input files have different keys\n");
515-
printf("keys in file %s:\n", f1);
514+
fprintf(stderr, "Indexes contained in the input files have different keys!\n");
515+
fprintf(stderr, "keys in file %s:\n", f1);
516516
k1 = options->index1->keys;
517517
while (k1) {
518-
printf("\t%s\n", k1->name);
518+
fprintf(stderr, "\t%s\n", k1->name);
519519
k1 = k1->next;
520520
}
521-
printf("keys in file %s:\n", f2);
521+
fprintf(stderr, "keys in file %s:\n", f2);
522522
k2 = options->index2->keys;
523523
while (k2) {
524-
printf("\t%s\n", k2->name);
524+
fprintf(stderr, "\t%s\n", k2->name);
525525
k2 = k2->next;
526526
}
527527
exit(1);
@@ -543,17 +543,17 @@ static int grib_tool_index(grib_runtime_options* options)
543543
k1 = k1->next;
544544
}
545545
if (!found) {
546-
printf("Indexes contained in the input files have different keys\n");
547-
printf("keys in file %s:\n", f2);
546+
fprintf(stderr,"Indexes contained in the input files have different keys!\n");
547+
fprintf(stderr, "keys in file %s:\n", f2);
548548
k2 = options->index2->keys;
549549
while (k2) {
550-
printf("\t%s\n", k2->name);
550+
fprintf(stderr, "\t%s\n", k2->name);
551551
k2 = k2->next;
552552
}
553-
printf("keys in file %s:\n", f1);
553+
fprintf(stderr, "keys in file %s:\n", f1);
554554
k1 = options->index1->keys;
555555
while (k1) {
556-
printf("\t%s\n", k1->name);
556+
fprintf(stderr, "\t%s\n", k1->name);
557557
k1 = k1->next;
558558
}
559559

0 commit comments

Comments
 (0)