+ echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..."
+ test_multifile $input_type ogg no_sector_align "--serial-number=321 --verify"
+ fi
+done
+
+
+############################################################################
+# test the metadata-handling properties of flac-to-flac encoding
+############################################################################
+
+echo "Testing the metadata-handling properties of flac-to-flac encoding..."
+
+testdir="flac-to-flac-metadata-test-files"
+filter ()
+{
+ # minor danger, changing vendor strings might change the length of the
+ # VORBIS_COMMENT block, but if we add "^ length: " to the patterns,
+ # we lose info about PADDING size that we need
+ grep -Ev '^ vendor string: |^ m..imum .....size: ' | sed -e 's/, stream_offset.*//'
+}
+flac2flac ()
+{
+ file="$1"
+ case="$2"
+ args="$3"
+ expect="$case-expect.meta"
+ echo -n "$case... "
+ run_flac $SILENT -f -o out.flac $args $file || die "ERROR encoding FLAC file"
+ run_metaflac --list out.flac | filter > out.meta || die "ERROR listing metadata of output FLAC file"
+ diff -q -w $expect out.meta 2>/dev/null || die "ERROR: metadata does not match expected $expect"
+ echo OK
+}
+
+#filter=', stream_offset.*|^ vendor string: |^ length: |^ m..imum .....size: '
+cd $testdir || die "ERROR changing to directory $testdir"
+
+# case 00a: no alterations on a file with all metadata types, keep all metadata, in same order
+flac2flac input-SCVAUP.flac case00a ""
+# case 01a: on file with multiple PADDING blocks, they should be aggregated into one at the end
+flac2flac input-SCVPAP.flac case01a ""
+# case 01b: on file with multiple PADDING blocks and --no-padding specified, they should all be deleted
+flac2flac input-SCVPAP.flac case01b "--no-padding"
+# case 01c: on file with multiple PADDING blocks and -P specified, they should all be overwritten with -P value
+flac2flac input-SCVPAP.flac case01c "-P 1234"
+# case 01d: on file with no PADDING blocks, use -P setting
+flac2flac input-SCVA.flac case01d "-P 1234"
+# case 01e: on file with no PADDING blocks and no -P given, use default padding
+flac2flac input-SCVA.flac case01e ""
+# case 02a: on file with no VORBIS_COMMENT block, add new VORBIS_COMMENT
+flac2flac input-SCPAP.flac case02a ""
+# case 02b: on file with no VORBIS_COMMENT block and --tag, add new VORBIS_COMMENT with tags
+flac2flac input-SCPAP.flac case02b "--tag=artist=0"
+# case 02c: on file with VORBIS_COMMENT block and --tag, replace existing VORBIS_COMMENT with new tags
+flac2flac input-SCVAUP.flac case02c "$TOTALLY_SILENT --tag=artist=0"
+# case 03a: on file with no CUESHEET block and --cuesheet specified, add it
+flac2flac input-SVAUP.flac case03a "--cuesheet=input0.cue"
+# case 03b: on file with CUESHEET block and --cuesheet specified, overwrite existing CUESHEET
+flac2flac input-SCVAUP.flac case03b "$TOTALLY_SILENT --cuesheet=input0.cue"
+# case 03c: on file with CUESHEET block and size-changing option specified, drop existing CUESHEET
+flac2flac input-SCVAUP.flac case03c "$TOTALLY_SILENT --skip=1"
+# case 04a: on file with no SEEKTABLE block and --no-seektable specified, no SEEKTABLE
+flac2flac input-VA.flac case04a "--no-padding --no-seektable"
+# case 04b: on file with no SEEKTABLE block and -S specified, new SEEKTABLE
+flac2flac input-VA.flac case04b "--no-padding -S 5x"
+# case 04c: on file with no SEEKTABLE block and no seektable options specified, new SEEKTABLE with default points
+flac2flac input-VA.flac case04c "--no-padding"
+# case 04d: on file with SEEKTABLE block and --no-seektable specified, drop existing SEEKTABLE
+flac2flac input-SCVA.flac case04d "--no-padding --no-seektable"
+# case 04e: on file with SEEKTABLE block and -S specified, overwrite existing SEEKTABLE
+flac2flac input-SCVA.flac case04e "$TOTALLY_SILENT --no-padding -S 5x"
+# case 04f: on file with SEEKTABLE block and size-changing option specified, drop existing SEEKTABLE, new SEEKTABLE with default points
+#(already covered by case03c)
+
+rm -f out.flac out.meta
+
+#@@@ when metaflac handles ogg flac, duplicate flac2flac tests here
+
+cd ..