about summary refs log tree commit
diff options
context:
space:
mode:
authorjcoalson <jcoalson>2006-08-28 03:39:45 +0000
committerjcoalson <jcoalson>2006-08-28 03:39:45 +0000
commit68cf0fac9175dc06914fa841f2002bd1e1f60c94 (patch)
tree4369dab7232b135190512b78edb6a7747ac83eaa
parent6aedf8162ac01daf776b42e78a28c677ecce28b5 (diff)
downloadflac-arm-1.1.3-68cf0fac9175dc06914fa841f2002bd1e1f60c94.tar.gz
switch metaflac test over to comparing output against "golden" files
-rw-r--r--test/metaflac-test-files/Makefile.am67
-rw-r--r--test/metaflac-test-files/case00-expect.meta24
-rw-r--r--test/metaflac-test-files/case01-expect.meta9
-rw-r--r--test/metaflac-test-files/case02-expect.meta28
-rw-r--r--test/metaflac-test-files/case03-expect.meta25
-rw-r--r--test/metaflac-test-files/case04-expect.meta26
-rw-r--r--test/metaflac-test-files/case05-expect.meta27
-rw-r--r--test/metaflac-test-files/case06-expect.meta28
-rw-r--r--test/metaflac-test-files/case07-expect.meta4
-rw-r--r--test/metaflac-test-files/case08-expect.meta27
-rw-r--r--test/metaflac-test-files/case09-expect.meta25
-rw-r--r--test/metaflac-test-files/case10-expect.meta6
-rw-r--r--test/metaflac-test-files/case11-expect.meta9
-rw-r--r--test/metaflac-test-files/case12-expect.meta12
-rw-r--r--test/metaflac-test-files/case13-expect.meta10
-rw-r--r--test/metaflac-test-files/case14-expect.meta13
-rw-r--r--test/metaflac-test-files/case15-expect.meta16
-rw-r--r--test/metaflac-test-files/case16-expect.meta33
-rw-r--r--test/metaflac-test-files/case17-expect.meta25
-rw-r--r--test/metaflac-test-files/case18-expect.meta29
-rw-r--r--test/metaflac-test-files/case19-expect.meta25
-rw-r--r--test/metaflac-test-files/case20-expect.meta29
-rw-r--r--test/metaflac-test-files/case21-expect.meta24
-rw-r--r--test/metaflac-test-files/case22-expect.meta18
-rw-r--r--test/metaflac-test-files/case23-expect.meta18
-rw-r--r--test/metaflac-test-files/case24-expect.meta18
-rw-r--r--test/metaflac-test-files/case25-expect.meta14
-rw-r--r--test/metaflac-test-files/case26-expect.meta22
-rw-r--r--test/metaflac-test-files/case27-expect.meta13
-rw-r--r--test/metaflac-test-files/case28-expect.meta13
-rw-r--r--test/metaflac-test-files/case29-expect.meta9
-rw-r--r--test/metaflac-test-files/case30-expect.meta9
-rw-r--r--test/metaflac-test-files/case31-expect.meta15
-rw-r--r--test/metaflac-test-files/case32-expect.meta15
-rw-r--r--test/metaflac-test-files/case33-expect.meta19
-rw-r--r--test/metaflac-test-files/case34-expect.meta19
-rw-r--r--test/metaflac-test-files/case35-expect.meta19
-rw-r--r--test/metaflac-test-files/case36-expect.meta15
-rw-r--r--test/metaflac-test-files/case37-expect.meta19
-rw-r--r--test/metaflac-test-files/case38-expect.meta19
-rw-r--r--test/metaflac-test-files/case39-expect.meta20
-rw-r--r--test/metaflac-test-files/case40-expect.meta22
-rw-r--r--test/metaflac-test-files/case41-expect.meta26
-rw-r--r--test/metaflac-test-files/case42-expect.meta22
-rw-r--r--test/metaflac-test-files/case43-expect.meta49
-rw-r--r--test/metaflac-test-files/case44-expect.meta28
-rw-r--r--test/metaflac-test-files/case45-expect.meta49
-rwxr-xr-xtest/test_metaflac.sh346
48 files changed, 1172 insertions, 185 deletions
diff --git a/test/metaflac-test-files/Makefile.am b/test/metaflac-test-files/Makefile.am
new file mode 100644
index 00000000..f9ead229
--- /dev/null
+++ b/test/metaflac-test-files/Makefile.am
@@ -0,0 +1,67 @@
+#  FLAC - Free Lossless Audio Codec
+#  Copyright (C) 2006  Josh Coalson
+#
+#  This file is part the FLAC project.  FLAC is comprised of several
+#  components distributed under difference licenses.  The codec libraries
+#  are distributed under Xiph.Org's BSD-like license (see the file
+#  COPYING.Xiph in this distribution).  All other programs, libraries, and
+#  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
+#  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
+#  FLAC distribution contains at the top the terms under which it may be
+#  distributed.
+#
+#  Since this particular file is relevant to all components of FLAC,
+#  it may be distributed under the Xiph.Org license, which is the least
+#  restrictive of those mentioned above.  See the file COPYING.Xiph in this
+#  distribution.
+
+EXTRA_DIST = \
+        case00-expect.meta \
+        case01-expect.meta \
+        case02-expect.meta \
+        case03-expect.meta \
+        case04-expect.meta \
+        case05-expect.meta \
+        case06-expect.meta \
+        case07-expect.meta \
+        case08-expect.meta \
+        case09-expect.meta \
+        case10-expect.meta \
+        case11-expect.meta \
+        case12-expect.meta \
+        case13-expect.meta \
+        case14-expect.meta \
+        case15-expect.meta \
+        case16-expect.meta \
+        case17-expect.meta \
+        case18-expect.meta \
+        case19-expect.meta \
+        case20-expect.meta \
+        case21-expect.meta \
+        case22-expect.meta \
+        case23-expect.meta \
+        case24-expect.meta \
+        case25-expect.meta \
+        case26-expect.meta \
+        case27-expect.meta \
+        case28-expect.meta \
+        case29-expect.meta \
+        case30-expect.meta \
+        case31-expect.meta \
+        case32-expect.meta \
+        case33-expect.meta \
+        case34-expect.meta \
+        case35-expect.meta \
+        case36-expect.meta \
+        case37-expect.meta \
+        case38-expect.meta \
+        case39-expect.meta \
+        case40-expect.meta \
+        case41-expect.meta \
+        case42-expect.meta \
+        case43-expect.meta \
+        case44-expect.meta \
+        case45-expect.meta
+
+CLEANFILES = \
+        $(wildcard out.*)
diff --git a/test/metaflac-test-files/case00-expect.meta b/test/metaflac-test-files/case00-expect.meta
new file mode 100644
index 00000000..e6d0599a
--- /dev/null
+++ b/test/metaflac-test-files/case00-expect.meta
@@ -0,0 +1,24 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 40
+  comments: 0
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 4096
diff --git a/test/metaflac-test-files/case01-expect.meta b/test/metaflac-test-files/case01-expect.meta
new file mode 100644
index 00000000..bae8f49a
--- /dev/null
+++ b/test/metaflac-test-files/case01-expect.meta
@@ -0,0 +1,9 @@
+a042237c5493fdb9656b94a83608d11a
+1152
+1152
+10
+10
+8000
+1
+8
+80000
diff --git a/test/metaflac-test-files/case02-expect.meta b/test/metaflac-test-files/case02-expect.meta
new file mode 100644
index 00000000..e10e95f2
--- /dev/null
+++ b/test/metaflac-test-files/case02-expect.meta
@@ -0,0 +1,28 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 40
+  comments: 0
+METADATA block #3
+  type: 1 (PADDING)
+  is last: false
+  length: 4096
+METADATA block #4
+  type: 1 (PADDING)
+  is last: true
+  length: 12345
diff --git a/test/metaflac-test-files/case03-expect.meta b/test/metaflac-test-files/case03-expect.meta
new file mode 100644
index 00000000..d1e1fcac
--- /dev/null
+++ b/test/metaflac-test-files/case03-expect.meta
@@ -0,0 +1,25 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 93
+  comments: 1
+    comment[0]: ARTIST=The_artist_formerly_known_as_the_artist...
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 16392
diff --git a/test/metaflac-test-files/case04-expect.meta b/test/metaflac-test-files/case04-expect.meta
new file mode 100644
index 00000000..8bf68cdf
--- /dev/null
+++ b/test/metaflac-test-files/case04-expect.meta
@@ -0,0 +1,26 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 117
+  comments: 2
+    comment[0]: ARTIST=The_artist_formerly_known_as_the_artist...
+    comment[1]: ARTIST=Chuck_Woolery
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 16368
diff --git a/test/metaflac-test-files/case05-expect.meta b/test/metaflac-test-files/case05-expect.meta
new file mode 100644
index 00000000..601519ad
--- /dev/null
+++ b/test/metaflac-test-files/case05-expect.meta
@@ -0,0 +1,27 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 132
+  comments: 3
+    comment[0]: ARTIST=The_artist_formerly_known_as_the_artist...
+    comment[1]: ARTIST=Chuck_Woolery
+    comment[2]: ARTIST=Vern
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 16353
diff --git a/test/metaflac-test-files/case06-expect.meta b/test/metaflac-test-files/case06-expect.meta
new file mode 100644
index 00000000..afeb503a
--- /dev/null
+++ b/test/metaflac-test-files/case06-expect.meta
@@ -0,0 +1,28 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 166
+  comments: 4
+    comment[0]: ARTIST=The_artist_formerly_known_as_the_artist...
+    comment[1]: ARTIST=Chuck_Woolery
+    comment[2]: ARTIST=Vern
+    comment[3]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 16319
diff --git a/test/metaflac-test-files/case07-expect.meta b/test/metaflac-test-files/case07-expect.meta
new file mode 100644
index 00000000..2e953030
--- /dev/null
+++ b/test/metaflac-test-files/case07-expect.meta
@@ -0,0 +1,4 @@
+reference libFLAC 1.1.3 20060805
+ARTIST=The_artist_formerly_known_as_the_artist...
+ARTIST=Chuck_Woolery
+ARTIST=Vern
diff --git a/test/metaflac-test-files/case08-expect.meta b/test/metaflac-test-files/case08-expect.meta
new file mode 100644
index 00000000..3cc35e45
--- /dev/null
+++ b/test/metaflac-test-files/case08-expect.meta
@@ -0,0 +1,27 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 113
+  comments: 3
+    comment[0]: ARTIST=Chuck_Woolery
+    comment[1]: ARTIST=Vern
+    comment[2]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 16372
diff --git a/test/metaflac-test-files/case09-expect.meta b/test/metaflac-test-files/case09-expect.meta
new file mode 100644
index 00000000..1277bb99
--- /dev/null
+++ b/test/metaflac-test-files/case09-expect.meta
@@ -0,0 +1,25 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 16411
diff --git a/test/metaflac-test-files/case10-expect.meta b/test/metaflac-test-files/case10-expect.meta
new file mode 100644
index 00000000..c5986ab9
--- /dev/null
+++ b/test/metaflac-test-files/case10-expect.meta
@@ -0,0 +1,6 @@
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
diff --git a/test/metaflac-test-files/case11-expect.meta b/test/metaflac-test-files/case11-expect.meta
new file mode 100644
index 00000000..f42d320f
--- /dev/null
+++ b/test/metaflac-test-files/case11-expect.meta
@@ -0,0 +1,9 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
diff --git a/test/metaflac-test-files/case12-expect.meta b/test/metaflac-test-files/case12-expect.meta
new file mode 100644
index 00000000..19ed454e
--- /dev/null
+++ b/test/metaflac-test-files/case12-expect.meta
@@ -0,0 +1,12 @@
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
diff --git a/test/metaflac-test-files/case13-expect.meta b/test/metaflac-test-files/case13-expect.meta
new file mode 100644
index 00000000..adcd0863
--- /dev/null
+++ b/test/metaflac-test-files/case13-expect.meta
@@ -0,0 +1,10 @@
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 16411
diff --git a/test/metaflac-test-files/case14-expect.meta b/test/metaflac-test-files/case14-expect.meta
new file mode 100644
index 00000000..03d93f2d
--- /dev/null
+++ b/test/metaflac-test-files/case14-expect.meta
@@ -0,0 +1,13 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 16411
diff --git a/test/metaflac-test-files/case15-expect.meta b/test/metaflac-test-files/case15-expect.meta
new file mode 100644
index 00000000..e5a1154a
--- /dev/null
+++ b/test/metaflac-test-files/case15-expect.meta
@@ -0,0 +1,16 @@
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 16411
diff --git a/test/metaflac-test-files/case16-expect.meta b/test/metaflac-test-files/case16-expect.meta
new file mode 100644
index 00000000..b6b33f02
--- /dev/null
+++ b/test/metaflac-test-files/case16-expect.meta
@@ -0,0 +1,33 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: false
+  length: 16411
+METADATA block #4
+  type: 1 (PADDING)
+  is last: false
+  length: 4321
+METADATA block #5
+  type: 1 (PADDING)
+  is last: true
+  length: 4321
diff --git a/test/metaflac-test-files/case17-expect.meta b/test/metaflac-test-files/case17-expect.meta
new file mode 100644
index 00000000..0a53fc86
--- /dev/null
+++ b/test/metaflac-test-files/case17-expect.meta
@@ -0,0 +1,25 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 25061
diff --git a/test/metaflac-test-files/case18-expect.meta b/test/metaflac-test-files/case18-expect.meta
new file mode 100644
index 00000000..e6f064a3
--- /dev/null
+++ b/test/metaflac-test-files/case18-expect.meta
@@ -0,0 +1,29 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: false
+  length: 25061
+METADATA block #4
+  type: 1 (PADDING)
+  is last: true
+  length: 0
diff --git a/test/metaflac-test-files/case19-expect.meta b/test/metaflac-test-files/case19-expect.meta
new file mode 100644
index 00000000..059e3ef0
--- /dev/null
+++ b/test/metaflac-test-files/case19-expect.meta
@@ -0,0 +1,25 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 25065
diff --git a/test/metaflac-test-files/case20-expect.meta b/test/metaflac-test-files/case20-expect.meta
new file mode 100644
index 00000000..c76e7280
--- /dev/null
+++ b/test/metaflac-test-files/case20-expect.meta
@@ -0,0 +1,29 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 74
+  comments: 1
+    comment[0]: TITLE=He_who_smelt_it_dealt_it
+METADATA block #3
+  type: 1 (PADDING)
+  is last: false
+  length: 25065
+METADATA block #4
+  type: 1 (PADDING)
+  is last: true
+  length: 0
diff --git a/test/metaflac-test-files/case21-expect.meta b/test/metaflac-test-files/case21-expect.meta
new file mode 100644
index 00000000..97fe0ac6
--- /dev/null
+++ b/test/metaflac-test-files/case21-expect.meta
@@ -0,0 +1,24 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 40
+  comments: 0
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 25103
diff --git a/test/metaflac-test-files/case22-expect.meta b/test/metaflac-test-files/case22-expect.meta
new file mode 100644
index 00000000..64ec68db
--- /dev/null
+++ b/test/metaflac-test-files/case22-expect.meta
@@ -0,0 +1,18 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 40
+  comments: 0
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 25103
diff --git a/test/metaflac-test-files/case23-expect.meta b/test/metaflac-test-files/case23-expect.meta
new file mode 100644
index 00000000..64ec68db
--- /dev/null
+++ b/test/metaflac-test-files/case23-expect.meta
@@ -0,0 +1,18 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 40
+  comments: 0
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 25103
diff --git a/test/metaflac-test-files/case24-expect.meta b/test/metaflac-test-files/case24-expect.meta
new file mode 100644
index 00000000..64ec68db
--- /dev/null
+++ b/test/metaflac-test-files/case24-expect.meta
@@ -0,0 +1,18 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 40
+  comments: 0
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 25103
diff --git a/test/metaflac-test-files/case25-expect.meta b/test/metaflac-test-files/case25-expect.meta
new file mode 100644
index 00000000..8986a705
--- /dev/null
+++ b/test/metaflac-test-files/case25-expect.meta
@@ -0,0 +1,14 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: true
+  length: 40
+  comments: 0
diff --git a/test/metaflac-test-files/case26-expect.meta b/test/metaflac-test-files/case26-expect.meta
new file mode 100644
index 00000000..eaf6c27b
--- /dev/null
+++ b/test/metaflac-test-files/case26-expect.meta
@@ -0,0 +1,22 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 40
+  comments: 0
+METADATA block #2
+  type: 1 (PADDING)
+  is last: false
+  length: 0
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 0
diff --git a/test/metaflac-test-files/case27-expect.meta b/test/metaflac-test-files/case27-expect.meta
new file mode 100644
index 00000000..eac969c1
--- /dev/null
+++ b/test/metaflac-test-files/case27-expect.meta
@@ -0,0 +1,13 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 1 (PADDING)
+  is last: true
+  length: 48
diff --git a/test/metaflac-test-files/case28-expect.meta b/test/metaflac-test-files/case28-expect.meta
new file mode 100644
index 00000000..eac969c1
--- /dev/null
+++ b/test/metaflac-test-files/case28-expect.meta
@@ -0,0 +1,13 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 1 (PADDING)
+  is last: true
+  length: 48
diff --git a/test/metaflac-test-files/case29-expect.meta b/test/metaflac-test-files/case29-expect.meta
new file mode 100644
index 00000000..cd0ad279
--- /dev/null
+++ b/test/metaflac-test-files/case29-expect.meta
@@ -0,0 +1,9 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: true
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
diff --git a/test/metaflac-test-files/case30-expect.meta b/test/metaflac-test-files/case30-expect.meta
new file mode 100644
index 00000000..cd0ad279
--- /dev/null
+++ b/test/metaflac-test-files/case30-expect.meta
@@ -0,0 +1,9 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: true
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
diff --git a/test/metaflac-test-files/case31-expect.meta b/test/metaflac-test-files/case31-expect.meta
new file mode 100644
index 00000000..a8fb438c
--- /dev/null
+++ b/test/metaflac-test-files/case31-expect.meta
@@ -0,0 +1,15 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: true
+  length: 66
+  comments: 1
+    comment[0]: f=0123456789abcdefghij
diff --git a/test/metaflac-test-files/case32-expect.meta b/test/metaflac-test-files/case32-expect.meta
new file mode 100644
index 00000000..9d1a1849
--- /dev/null
+++ b/test/metaflac-test-files/case32-expect.meta
@@ -0,0 +1,15 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: true
+  length: 65
+  comments: 1
+    comment[0]: f=0123456789abcdefghi
diff --git a/test/metaflac-test-files/case33-expect.meta b/test/metaflac-test-files/case33-expect.meta
new file mode 100644
index 00000000..0c883c36
--- /dev/null
+++ b/test/metaflac-test-files/case33-expect.meta
@@ -0,0 +1,19 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 61
+  comments: 1
+    comment[0]: f=0123456789abcde
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 0
diff --git a/test/metaflac-test-files/case34-expect.meta b/test/metaflac-test-files/case34-expect.meta
new file mode 100644
index 00000000..b59ccb8a
--- /dev/null
+++ b/test/metaflac-test-files/case34-expect.meta
@@ -0,0 +1,19 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 47
+  comments: 1
+    comment[0]: f=0
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 14
diff --git a/test/metaflac-test-files/case35-expect.meta b/test/metaflac-test-files/case35-expect.meta
new file mode 100644
index 00000000..7f484525
--- /dev/null
+++ b/test/metaflac-test-files/case35-expect.meta
@@ -0,0 +1,19 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 56
+  comments: 1
+    comment[0]: f=0123456789
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 5
diff --git a/test/metaflac-test-files/case36-expect.meta b/test/metaflac-test-files/case36-expect.meta
new file mode 100644
index 00000000..9d1a1849
--- /dev/null
+++ b/test/metaflac-test-files/case36-expect.meta
@@ -0,0 +1,15 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: true
+  length: 65
+  comments: 1
+    comment[0]: f=0123456789abcdefghi
diff --git a/test/metaflac-test-files/case37-expect.meta b/test/metaflac-test-files/case37-expect.meta
new file mode 100644
index 00000000..7f484525
--- /dev/null
+++ b/test/metaflac-test-files/case37-expect.meta
@@ -0,0 +1,19 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 56
+  comments: 1
+    comment[0]: f=0123456789
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 5
diff --git a/test/metaflac-test-files/case38-expect.meta b/test/metaflac-test-files/case38-expect.meta
new file mode 100644
index 00000000..93d1e329
--- /dev/null
+++ b/test/metaflac-test-files/case38-expect.meta
@@ -0,0 +1,19 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 66
+  comments: 1
+    comment[0]: f=0123456789abcdefghij
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 5
diff --git a/test/metaflac-test-files/case39-expect.meta b/test/metaflac-test-files/case39-expect.meta
new file mode 100644
index 00000000..700caffc
--- /dev/null
+++ b/test/metaflac-test-files/case39-expect.meta
@@ -0,0 +1,20 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 82
+  comments: 2
+    comment[0]: f=0123456789abcdefghij
+    comment[1]: TITLE=Tittle
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 5
diff --git a/test/metaflac-test-files/case40-expect.meta b/test/metaflac-test-files/case40-expect.meta
new file mode 100644
index 00000000..125eedc9
--- /dev/null
+++ b/test/metaflac-test-files/case40-expect.meta
@@ -0,0 +1,22 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 117
+  comments: 4
+    comment[0]: f=0123456789abcdefghij
+    comment[1]: TITLE=Tittle
+    comment[2]: artist=Fartist
+    comment[3]: artist=artits
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 5
diff --git a/test/metaflac-test-files/case41-expect.meta b/test/metaflac-test-files/case41-expect.meta
new file mode 100644
index 00000000..3e2fcf0b
--- /dev/null
+++ b/test/metaflac-test-files/case41-expect.meta
@@ -0,0 +1,26 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 259
+  comments: 8
+    comment[0]: f=0123456789abcdefghij
+    comment[1]: TITLE=Tittle
+    comment[2]: artist=Fartist
+    comment[3]: artist=artits
+    comment[4]: REPLAYGAIN_TRACK_PEAK=0.00000000
+    comment[5]: REPLAYGAIN_TRACK_GAIN=+64.82 dB
+    comment[6]: REPLAYGAIN_ALBUM_PEAK=0.00000000
+    comment[7]: REPLAYGAIN_ALBUM_GAIN=+64.82 dB
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 5
diff --git a/test/metaflac-test-files/case42-expect.meta b/test/metaflac-test-files/case42-expect.meta
new file mode 100644
index 00000000..bdc02eae
--- /dev/null
+++ b/test/metaflac-test-files/case42-expect.meta
@@ -0,0 +1,22 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 117
+  comments: 4
+    comment[0]: f=0123456789abcdefghij
+    comment[1]: TITLE=Tittle
+    comment[2]: artist=Fartist
+    comment[3]: artist=artits
+METADATA block #2
+  type: 1 (PADDING)
+  is last: true
+  length: 147
diff --git a/test/metaflac-test-files/case43-expect.meta b/test/metaflac-test-files/case43-expect.meta
new file mode 100644
index 00000000..7e2957de
--- /dev/null
+++ b/test/metaflac-test-files/case43-expect.meta
@@ -0,0 +1,49 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 117
+  comments: 4
+    comment[0]: f=0123456789abcdefghij
+    comment[1]: TITLE=Tittle
+    comment[2]: artist=Fartist
+    comment[3]: artist=artits
+METADATA block #3
+  type: 5 (CUESHEET)
+  is last: false
+  length: 480
+  media catalog number: 1234567890123
+  lead-in: 0
+  is CD: false
+  number of tracks: 2
+    track[0]
+      offset: 0
+      number: 1
+      ISRC:
+      type: AUDIO
+      pre-emphasis: false
+      number of index points: 1
+        index[0]
+          offset: 0
+          number: 1
+    track[1]
+      offset: 80000
+      number: 1 (LEAD-OUT)
+METADATA block #4
+  type: 1 (PADDING)
+  is last: true
+  length: 147
diff --git a/test/metaflac-test-files/case44-expect.meta b/test/metaflac-test-files/case44-expect.meta
new file mode 100644
index 00000000..49ca8e59
--- /dev/null
+++ b/test/metaflac-test-files/case44-expect.meta
@@ -0,0 +1,28 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 117
+  comments: 4
+    comment[0]: f=0123456789abcdefghij
+    comment[1]: TITLE=Tittle
+    comment[2]: artist=Fartist
+    comment[3]: artist=artits
+METADATA block #3
+  type: 1 (PADDING)
+  is last: true
+  length: 631
diff --git a/test/metaflac-test-files/case45-expect.meta b/test/metaflac-test-files/case45-expect.meta
new file mode 100644
index 00000000..7e2957de
--- /dev/null
+++ b/test/metaflac-test-files/case45-expect.meta
@@ -0,0 +1,49 @@
+METADATA block #0
+  type: 0 (STREAMINFO)
+  is last: false
+  length: 34
+  sample_rate: 8000 Hz
+  channels: 1
+  bits-per-sample: 8
+  total samples: 80000
+  MD5 signature: a042237c5493fdb9656b94a83608d11a
+METADATA block #1
+  type: 3 (SEEKTABLE)
+  is last: false
+  length: 18
+  seek points: 1
+    point 0: sample_number=0
+METADATA block #2
+  type: 4 (VORBIS_COMMENT)
+  is last: false
+  length: 117
+  comments: 4
+    comment[0]: f=0123456789abcdefghij
+    comment[1]: TITLE=Tittle
+    comment[2]: artist=Fartist
+    comment[3]: artist=artits
+METADATA block #3
+  type: 5 (CUESHEET)
+  is last: false
+  length: 480
+  media catalog number: 1234567890123
+  lead-in: 0
+  is CD: false
+  number of tracks: 2
+    track[0]
+      offset: 0
+      number: 1
+      ISRC:
+      type: AUDIO
+      pre-emphasis: false
+      number of index points: 1
+        index[0]
+          offset: 0
+          number: 1
+    track[1]
+      offset: 80000
+      number: 1 (LEAD-OUT)
+METADATA block #4
+  type: 1 (PADDING)
+  is last: true
+  length: 147
diff --git a/test/test_metaflac.sh b/test/test_metaflac.sh
index 1022ef30..13860f33 100755
--- a/test/test_metaflac.sh
+++ b/test/test_metaflac.sh
@@ -23,26 +23,36 @@ die ()
         exit 1
 }
 
-if [ x = x"$1" ] ; then
+if [ x = x"$1" ] ; then
         BUILD=debug
 else
         BUILD="$1"
 fi
 
-LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/libOggFLAC/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/getopt/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/utf8/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH
+# change to 'false' to show all flac/metaflac output (useful for debugging)
+if true ; then
+        SILENT='--silent'
+        TOTALLY_SILENT='--totally-silent'
+else
+        SILENT=''
+        TOTALLY_SILENT=''
+fi
+
+LD_LIBRARY_PATH=`pwd`/../src/libFLAC/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/libOggFLAC/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/grabbag/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/getopt/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/utf8/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../obj/$BUILD/lib:$LD_LIBRARY_PATH
 export LD_LIBRARY_PATH
-PATH=../src/flac:$PATH
-PATH=../src/metaflac:$PATH
-PATH=../obj/$BUILD/bin:$PATH
+PATH=`pwd`/../src/flac:$PATH
+PATH=`pwd`/../src/metaflac:$PATH
+PATH=`pwd`/../obj/$BUILD/bin:$PATH
 
-flacfile=metaflac.flac
+testdir="metaflac-test-files"
+flacfile="metaflac.flac"
 
 flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
 metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
@@ -65,276 +75,240 @@ run_metaflac ()
         fi
 }
 
+run_metaflac_silent ()
+{
+        if [ -z "$SILENT" ] ; then
+                run_metaflac $*
+        else
+                if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
+                        valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 2>/dev/null 4>>test_metaflac.valgrind.log
+                else
+                        metaflac $* 2>/dev/null
+                fi
+        fi
+}
+
+check_flac ()
+{
+        run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2
+}
+
 echo "Generating stream..."
-if [ -f /bin/sh.exe ] ; then
-        inputfile=/bin/sh.exe
-elif [ -f /bin/sh ] ; then
-        inputfile=/bin/sh
-else
-        inputfile="$0"
-fi
-if run_flac --force --verify -0 --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=44100 $inputfile ; then
+bytes=80000
+if dd if=/dev/zero ibs=1 count=$bytes | flac --force --verify -0 --input-size=$bytes --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=8000 - ; then
         chmod +w $flacfile
 else
         die "ERROR during generation"
 fi
 
-check_exit ()
+check_flac
+
+echo
+
+filter ()
 {
-        exit_code=$?
-        [ $exit_code = 0 ] || die "ERROR, exit code = $exit_code"
+        # minor danger, changing vendor strings will 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.*//'
 }
-
-check_flac ()
+metaflac_test ()
 {
-        run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2
+        case="$1"
+        desc="$2"
+        args="$3"
+        expect="$testdir/$case-expect.meta"
+        echo -n "test $case: $desc... "
+        run_metaflac $args $flacfile | filter > $testdir/out.meta || die "ERROR running metaflac"
+        diff -q -w $expect $testdir/out.meta 2>/dev/null || die "ERROR: metadata does not match expected $expect"
+        echo OK
 }
 
-check_flac
-
-(set -x && run_metaflac --list $flacfile)
-check_exit
+metaflac_test case00 "--list" "--list"
 
-(set -x &&
-run_metaflac \
-        --show-md5sum \
-        --show-min-blocksize \
-        --show-max-blocksize \
-        --show-min-framesize \
-        --show-max-framesize \
-        --show-sample-rate \
-        --show-channels \
-        --show-bps \
-        --show-total-samples \
-        $flacfile
-)
-check_exit
+metaflac_test case01 "STREAMINFO --show-* shortcuts" "
+        --show-md5sum
+        --show-min-blocksize
+        --show-max-blocksize
+        --show-min-framesize
+        --show-max-framesize
+        --show-sample-rate
+        --show-channels
+        --show-bps
+        --show-total-samples"
 
-(set -x && run_metaflac --preserve-modtime --add-padding=12345 $flacfile)
-check_exit
+run_metaflac --preserve-modtime --add-padding=12345 $flacfile
 check_flac
+metaflac_test case02 "--add-padding" "--list"
 
 # some flavors of /bin/sh (e.g. Darwin's) won't even handle quoted spaces, so we underscore:
-(set -x && run_metaflac --set-tag="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile)
-check_exit
+run_metaflac --set-tag="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile
 check_flac
+metaflac_test case03 "--set-tag=ARTIST" "--list"
 
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
-
-(set -x && run_metaflac --set-tag="ARTIST=Chuck_Woolery" $flacfile)
-check_exit
+run_metaflac --set-tag="ARTIST=Chuck_Woolery" $flacfile
 check_flac
+metaflac_test case04 "--set-tag=ARTIST" "--list"
 
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
-
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
-
-(set -x && run_metaflac --set-tag="ARTIST=Vern" $flacfile)
-check_exit
+run_metaflac --set-tag="ARTIST=Vern" $flacfile
 check_flac
+metaflac_test case05 "--set-tag=ARTIST" "--list"
 
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
-
-(set -x && run_metaflac --set-tag="TITLE=He_who_smelt_it_dealt_it" $flacfile)
-check_exit
+run_metaflac --set-tag="TITLE=He_who_smelt_it_dealt_it" $flacfile
 check_flac
+metaflac_test case06 "--set-tag=TITLE" "--list"
 
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
+metaflac_test case07 "--show-vendor-tag --show-tag=ARTIST" "--show-vendor-tag --show-tag=ARTIST"
 
-(set -x && run_metaflac --show-vendor-tag --show-tag=ARTIST $flacfile)
-check_exit
-
-(set -x && run_metaflac --remove-first-tag=ARTIST $flacfile)
-check_exit
+run_metaflac --remove-first-tag=ARTIST $flacfile
 check_flac
+metaflac_test case08 "--remove-first-tag=ARTIST" "--list"
 
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
-
-(set -x && run_metaflac --remove-tag=ARTIST $flacfile)
-check_exit
+run_metaflac --remove-tag=ARTIST $flacfile
 check_flac
+metaflac_test case09 "--remove-tag=ARTIST" "--list"
 
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
-
-(set -x && run_metaflac --list --block-number=0 $flacfile)
-check_exit
-
-(set -x && run_metaflac --list --block-number=1,2,999 $flacfile)
-check_exit
-
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT,PADDING $flacfile)
-check_exit
+metaflac_test case10 "--list --block-type=VORBIS_COMMENT" "--list --block-type=VORBIS_COMMENT"
+metaflac_test case11 "--list --block-number=0" "--list --block-number=0"
+metaflac_test case12 "--list --block-number=1,2,999" "--list --block-number=1,2,999"
+metaflac_test case13 "--list --block-type=VORBIS_COMMENT,PADDING" "--list --block-type=VORBIS_COMMENT,PADDING"
+metaflac_test case14 "--list --except-block-type=SEEKTABLE,VORBIS_COMMENT" "--list --except-block-type=SEEKTABLE,VORBIS_COMMENT"
+metaflac_test case15 "--list --except-block-type=STREAMINFO" "--list --except-block-type=STREAMINFO"
 
-(set -x && run_metaflac --list --except-block-type=SEEKTABLE,VORBIS_COMMENT $flacfile)
-check_exit
-
-(set -x && run_metaflac --add-padding=4321 $flacfile $flacfile)
-check_exit
+run_metaflac --add-padding=4321 $flacfile $flacfile
 check_flac
+metaflac_test case16 "--add-padding=4321 * 2" "--list"
 
-(set -x && run_metaflac --merge-padding $flacfile)
-check_exit
+run_metaflac --merge-padding $flacfile
 check_flac
+metaflac_test case17 "--merge-padding" "--list"
 
-(set -x && run_metaflac --add-padding=0 $flacfile)
-check_exit
+run_metaflac --add-padding=0 $flacfile
 check_flac
+metaflac_test case18 "--add-padding=0" "--list"
 
-(set -x && run_metaflac --sort-padding $flacfile)
-check_exit
+run_metaflac --sort-padding $flacfile
 check_flac
+metaflac_test case19 "--sort-padding" "--list"
 
-(set -x && run_metaflac --add-padding=0 $flacfile)
-check_exit
+run_metaflac --add-padding=0 $flacfile
 check_flac
+metaflac_test case20 "--add-padding=0" "--list"
 
-(set -x && run_metaflac --remove-all-tags $flacfile)
-check_exit
+run_metaflac --remove-all-tags $flacfile
 check_flac
+metaflac_test case21 "--remove-all-tags" "--list"
 
-(set -x && run_metaflac --remove --block-number=1,99 --dont-use-padding $flacfile)
-check_exit
+run_metaflac --remove --block-number=1,99 --dont-use-padding $flacfile
 check_flac
+metaflac_test case22 "--remove --block-number=1,99 --dont-use-padding" "--list"
 
-(set -x && run_metaflac --remove --block-number=99 --dont-use-padding $flacfile)
-check_exit
+run_metaflac --remove --block-number=99 --dont-use-padding $flacfile
 check_flac
+metaflac_test case23 "--remove --block-number=99 --dont-use-padding" "--list"
 
-(set -x && run_metaflac --remove --block-type=PADDING $flacfile)
-check_exit
+run_metaflac --remove --block-type=PADDING $flacfile
 check_flac
+metaflac_test case24 "--remove --block-type=PADDING" "--list"
 
-(set -x && run_metaflac --remove --block-type=PADDING --dont-use-padding $flacfile)
-check_exit
+run_metaflac --remove --block-type=PADDING --dont-use-padding $flacfile
 check_flac
+metaflac_test case25 "--remove --block-type=PADDING --dont-use-padding" "--list"
 
-(set -x && run_metaflac --add-padding=0 $flacfile $flacfile)
-check_exit
+run_metaflac --add-padding=0 $flacfile $flacfile
 check_flac
+metaflac_test case26 "--add-padding=0 * 2" "--list"
 
-(set -x && run_metaflac --remove --except-block-type=PADDING $flacfile)
-check_exit
+run_metaflac --remove --except-block-type=PADDING $flacfile
 check_flac
+metaflac_test case27 "--remove --except-block-type=PADDING" "--list"
 
-(set -x && run_metaflac --remove-all $flacfile)
-check_exit
+run_metaflac --remove-all $flacfile
 check_flac
+metaflac_test case28 "--remove-all" "--list"
 
-(set -x && run_metaflac --remove-all --dont-use-padding $flacfile)
-check_exit
+run_metaflac --remove-all --dont-use-padding $flacfile
 check_flac
+metaflac_test case29 "--remove-all --dont-use-padding" "--list"
 
-(set -x && run_metaflac --remove-all --dont-use-padding $flacfile)
-check_exit
+run_metaflac --remove-all --dont-use-padding $flacfile
 check_flac
+metaflac_test case30 "--remove-all --dont-use-padding" "--list"
 
-(set -x && run_metaflac --set-tag="f=0123456789abcdefghij" $flacfile)
-check_exit
+run_metaflac --set-tag="f=0123456789abcdefghij" $flacfile
 check_flac
-(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
-check_exit
+metaflac_test case31 "--set-tag=..." "--list"
 
-(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile)
-check_exit
+run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile
 check_flac
-(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
-check_exit
+metaflac_test case32 "--remove-all-tags --set-tag=..." "--list"
 
-(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcde" $flacfile)
-check_exit
+run_metaflac --remove-all-tags --set-tag="f=0123456789abcde" $flacfile
 check_flac
-(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
-check_exit
+metaflac_test case33 "--remove-all-tags --set-tag=..." "--list"
 
-(set -x && run_metaflac --remove-all-tags --set-tag="f=0" $flacfile)
-check_exit
+run_metaflac --remove-all-tags --set-tag="f=0" $flacfile
 check_flac
-(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
-check_exit
+metaflac_test case34 "--remove-all-tags --set-tag=..." "--list"
 
-(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile)
-check_exit
+run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile
 check_flac
-(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
-check_exit
+metaflac_test case35 "--remove-all-tags --set-tag=..." "--list"
 
-(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile)
-check_exit
+run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile
 check_flac
-(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
-check_exit
+metaflac_test case36 "--remove-all-tags --set-tag=..." "--list"
 
-(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile)
-check_exit
+run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile
 check_flac
-(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
-check_exit
+metaflac_test case37 "--remove-all-tags --set-tag=..." "--list"
 
-(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghij" $flacfile)
-check_exit
+run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghij" $flacfile
 check_flac
-(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
-check_exit
+metaflac_test case38 "--remove-all-tags --set-tag=..." "--list"
 
-(set -x && echo "TITLE=Tittle" | run_metaflac --import-tags-from=- $flacfile)
-check_exit
+echo "TITLE=Tittle" | run_metaflac --import-tags-from=- $flacfile
 check_flac
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
+metaflac_test case39 "--import-tags-from=-" "--list"
 
 cat > vc.txt << EOF
 artist=Fartist
 artist=artits
 EOF
-(set -x && run_metaflac --import-tags-from=vc.txt $flacfile)
-check_exit
+run_metaflac --import-tags-from=vc.txt $flacfile
 check_flac
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
+metaflac_test case40 "--import-tags-from=[FILE]" "--list"
 
 rm vc.txt
 
+run_metaflac --add-replay-gain $flacfile
+check_flac
+metaflac_test case41 "--add-replay-gain" "--list"
+
+run_metaflac --remove-replay-gain $flacfile
+check_flac
+metaflac_test case42 "--remove-replay-gain" "--list"
+
 cs_in=cuesheets/good.000.cue
 cs_out=metaflac.cue
 cs_out2=metaflac2.cue
-(set -x && run_metaflac --import-cuesheet-from="$cs_in" $flacfile)
-check_exit
+run_metaflac --import-cuesheet-from="$cs_in" $flacfile
 check_flac
-(set -x && run_metaflac --export-cuesheet-to=$cs_out $flacfile)
-check_exit
-(set -x && run_metaflac --remove --block-type=CUESHEET $flacfile)
-check_exit
+metaflac_test case43 "--import-cuesheet-from" "--list"
+run_metaflac --export-cuesheet-to=$cs_out $flacfile
+run_metaflac --remove --block-type=CUESHEET $flacfile
 check_flac
-(set -x && run_metaflac --import-cuesheet-from=$cs_out $flacfile)
-check_exit
+metaflac_test case44 "--remove --block-type=CUESHEET" "--list"
+run_metaflac --import-cuesheet-from=$cs_out $flacfile
 check_flac
-(set -x && run_metaflac --export-cuesheet-to=$cs_out2 $flacfile)
-check_exit
+metaflac_test case45 "--import-cuesheet-from" "--list"
+run_metaflac --export-cuesheet-to=$cs_out2 $flacfile
 echo "comparing cuesheets:"
 diff $cs_out $cs_out2 || die "ERROR, cuesheets should be identical"
 echo identical
 
 rm -f $cs_out $cs_out2
 
-(set -x && run_metaflac --add-replay-gain $flacfile)
-check_exit
-check_flac
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
-
-(set -x && run_metaflac --remove-replay-gain $flacfile)
-check_exit
-check_flac
-(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
-check_exit
-
 echo -n "Testing FLAC file with unknown metadata... "
 cp -p metaflac.flac.in $flacfile
 # remove the VORBIS_COMMENT block so vendor string changes don't interfere with the comparison:
@@ -342,4 +316,6 @@ run_metaflac --remove --block-type=VORBIS_COMMENT --dont-use-padding $flacfile
 cmp $flacfile metaflac.flac.ok || die "ERROR, $flacfile and metaflac.flac.ok differ"
 echo OK
 
+rm -f out.flac out.meta
+
 exit 0