summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-02-08 02:19:40 +0000
committerCarl Hetherington <cth@carlh.net>2013-02-08 02:19:40 +0000
commit10df3e6c29912ddd3e38de4e28b2974d6288af52 (patch)
treefe7c0f682bd142c39c1a4bff9696be064c0151c4
parent07a95f6750979c8e353d1434d7fca6b780fc3a1f (diff)
Add a couple of test scripts.
-rw-r--r--test/guessdcp.py15
-rw-r--r--test/torture_partial.py62
2 files changed, 77 insertions, 0 deletions
diff --git a/test/guessdcp.py b/test/guessdcp.py
new file mode 100644
index 000000000..d4c41afb1
--- /dev/null
+++ b/test/guessdcp.py
@@ -0,0 +1,15 @@
+import os
+
+def path(f):
+ for d in os.listdir(f):
+ try:
+ for s in os.listdir(os.path.join(f, d)):
+ if s.endswith('.xml'):
+ return os.path.join(f, d)
+ except:
+ pass
+
+ return None
+
+if __name__ == '__main__':
+ print path('/home/carl/Unsafe/DCP/Boon')
diff --git a/test/torture_partial.py b/test/torture_partial.py
new file mode 100644
index 000000000..ced8db6a6
--- /dev/null
+++ b/test/torture_partial.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+
+import sys
+import os
+import shutil
+import random
+
+import guessdcp
+
+if len(sys.argv) < 2:
+ print 'Syntax: %s <film>' % sys.argv[0]
+ sys.exit(1)
+
+film = sys.argv[1]
+
+print 'Creating reference Film'
+os.system('makedcp -n %s' % film)
+
+videos = os.listdir(os.path.join(film, 'video'))
+assert(len(videos) == 1)
+
+full_size = os.path.getsize(os.path.join(film, 'video', videos[0]))
+print 'Video MXF is %d bytes long' % full_size
+
+while 1:
+ film_copy = '%s-copy' % film
+
+ try:
+ shutil.rmtree(film_copy)
+ except:
+ pass
+
+ print 'Copying %s to %s' % (film, film_copy)
+ shutil.copytree(film, film_copy)
+ old_dcp = guessdcp.path(film_copy)
+ print 'Removing %s and log' % old_dcp
+ shutil.rmtree(old_dcp)
+ os.remove(os.path.join(film_copy, 'log'))
+
+ truncated_size = random.randint(1, full_size)
+ print 'Truncating video MXF to %d' % truncated_size
+ videos = os.listdir(os.path.join(film_copy, 'video'))
+ assert(len(videos) == 1)
+ os.system('ls -l %s' % os.path.join(film_copy, 'video'))
+ os.system('truncate %s --size %d' % (os.path.join(film_copy, 'video', videos[0]), truncated_size))
+ os.system('ls -l %s' % os.path.join(film_copy, 'video'))
+
+ print 'Rebuilding'
+ os.system('makedcp -n %s' % film_copy)
+
+ print 'Checking'
+ r = os.system('dcpdiff %s %s' % (guessdcp.path(film), guessdcp.path(film_copy)))
+ if r != 0:
+ print 'FAIL'
+ sys.exit(1)
+
+ print 'OK'
+ print
+
+ print 'Deleting copy'
+ shutil.rmtree(film_copy)
+