* morituri/common/checksum.py:

* morituri/test/Makefile.am:
	* morituri/test/test_common_checksum.py (added):
	  Add a check to make sure that checksumming an empty file doesn't
	  hang.  Fix the hang.
This commit is contained in:
Thomas Vander Stichele
2009-09-11 11:48:17 +00:00
parent d7c204c62b
commit d9530cb82a
4 changed files with 45 additions and 2 deletions

View File

@@ -1,3 +1,11 @@
2009-09-11 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/checksum.py:
* morituri/test/Makefile.am:
* morituri/test/test_common_checksum.py (added):
Add a check to make sure that checksumming an empty file doesn't
hang. Fix the hang.
2009-09-08 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri.spec.in:

View File

@@ -82,7 +82,13 @@ class ChecksumTask(task.Task):
if self._frameLength < 0:
self.debug('query duration')
length, qformat = sink.query_duration(gst.FORMAT_DEFAULT)
try:
length, qformat = sink.query_duration(gst.FORMAT_DEFAULT)
except gst.QueryError, e:
self.exception = e
self.stop()
return
# wavparse 0.10.14 returns in bytes
if qformat == gst.FORMAT_BYTES:
self.debug('query returned in BYTES format')
@@ -176,7 +182,7 @@ class ChecksumTask(task.Task):
if not self._last:
# see http://bugzilla.gnome.org/show_bug.cgi?id=578612
print 'ERROR: not a single buffer gotten'
raise
#raise
else:
self._checksum = self._checksum % 2 ** 32
self.debug("last offset %r", self._last.offset)
@@ -328,6 +334,7 @@ class TRMTask(task.Task):
def _bus_error_cb(self, bus, message):
error = message.parse_error()
# FIXME: handle properly
print error
def _new_buffer_cb(self, sink):

View File

@@ -4,6 +4,7 @@ EXTRA_DIST = \
__init__.py \
common.py \
test_common_accurip.py \
test_common_checksum.py \
test_common_program.py \
test_common_renamer.py \
test_image_cue.py \

View File

@@ -0,0 +1,27 @@
# -*- Mode: Python; test-case-name: morituri.test.test_common_checksum -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import unittest
import tempfile
import gobject
gobject.threads_init()
import gst
from morituri.common import task, checksum
def h(i):
return "0x%08x" % i
class EmptyTestCase(unittest.TestCase):
def testEmpty(self):
# this test makes sure that checksumming empty files doesn't hang
self.runner = task.SyncRunner(verbose=False)
fd, path = tempfile.mkstemp(suffix='morituri.test.empty')
checksumtask = checksum.ChecksumTask(path)
# FIXME: do we want a specific error for this ?
self.assertRaises(gst.QueryError, self.runner.run,
checksumtask, verbose=False)
os.unlink(path)