Various test hackery.
authorCarl Hetherington <cth@carlh.net>
Tue, 17 Jul 2012 16:25:18 +0000 (17:25 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 17 Jul 2012 16:25:18 +0000 (17:25 +0100)
13 files changed:
asdcplib/src/KM_prng.cpp
asdcplib/src/KM_prng.h
asdcplib/src/KM_util.cpp
asdcplib/src/KM_util.h
run-tests.sh
src/asset.cc
test/ref/DCP/8e293965-f8ad-48c6-971d-261b01f65cdb_pkl.xml
test/ref/DCP/ASSETMAP.xml
test/ref/DCP/audio.mxf
test/ref/DCP/df0e4141-13c3-4a7a-bef8-b5a04fcbc4bb_cpl.xml
test/ref/DCP/video.mxf
test/ref/make.py
test/tests.cc

index 3c64bdcc6a3cb2ca5ad21ab64148d93d37609835..e7526da113fbfebf014f88470f9d971877b3a6a3 100755 (executable)
@@ -48,8 +48,6 @@ using namespace Kumu;
 const char* DEV_URANDOM = "/dev/urandom";
 #endif // KM_WIN32
 
-bool Kumu::libdcp_test = false;
-
 const ui32_t RNG_KEY_SIZE = 512UL;
 const ui32_t RNG_KEY_SIZE_BITS = 256UL;
 const ui32_t RNG_BLOCK_SIZE = 16UL;
index a1f232884ad64492709935dbe808d9e6f39e7b10..4d7ab2b776e109c4f2016bd2146384acb41130be 100755 (executable)
@@ -50,8 +50,6 @@ namespace Kumu
 
   // key_len must be <= 64 (larger values will be truncated)
   void Gen_FIPS_186_Value(const byte_t* key_in, ui32_t key_len, byte_t* buf, ui32_t buf_len);
-
-  extern bool libdcp_test;
 } // namespace Kumu
 
 
index 325bd2dada524aee458db72df86899f5b4ede42f..23e8a1a6eaebaaca8da8b8c25b481e56c9bdd61a 100755 (executable)
@@ -40,6 +40,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <map>
 #include <string>
 
+bool Kumu::libdcp_test = false;
+
 const char*
 Kumu::Version()
 {
@@ -688,7 +690,14 @@ Kumu::write_BER(byte_t* buf, ui64_t val, ui32_t ber_len)
 
 //
 Kumu::Timestamp::Timestamp() : m_TZOffsetMinutes(0) {
-  m_Timestamp.now();
+  if (libdcp_test)
+    {
+      m_Timestamp.x = 42;
+    }
+  else
+    {
+      m_Timestamp.now();
+    }
 }
 
 Kumu::Timestamp::Timestamp(const Timestamp& rhs) {
index 78f07398e4d70319371c781c62ea3a17e652422c..892670e62c96be6a3f93c2aa69a03c3aa6179496 100755 (executable)
@@ -41,6 +41,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 namespace Kumu
 {
+  extern bool libdcp_test;
+       
   // The version number declaration and explanation are in ../configure.ac
   const char* Version();
 
index a837a287e7cc4903f53bf3b844c24cf4eea382bd..a16806f72a574858d43b9c6c91773886ebe4f0b3 100755 (executable)
@@ -3,4 +3,8 @@
 LD_LIBRARY_PATH=build/src:build/asdcplib/src
 build/test/tests
 diff -ur build/test/foo test/ref/DCP
\ No newline at end of file
+if [ "$?" != "0" ]; then
+  echo "FAIL: files differ"
+  exit 1
+fi
+echo "PASS"
\ No newline at end of file
index 6b4c3fe4c655ce140a043ec12b41d2500a1ac304..4e3bb0e1ca1dc16edbeeb1ad33688630ba9e49f2 100644 (file)
@@ -17,6 +17,7 @@
 
 */
 
+#include <iostream>
 #include <boost/filesystem.hpp>
 #include "AS_DCP.h"
 #include "KM_util.h"
index e8342cc7148edb987301f595fe4def88a0a33f85..0e62ce071a9a9ab51c0304e70c01f48b3a2f71f4 100644 (file)
@@ -2,27 +2,27 @@
 <PackingList xmlns="http://www.smpte-ra.org/schemas/429-8/2007/PKL">
   <Id>urn:uuid:8e293965-f8ad-48c6-971d-261b01f65cdb</Id>
   <AnnotationText>A Test DCP</AnnotationText>
-  <IssueDate>2012-07-17T04:32:07+00:00</IssueDate>
+  <IssueDate>2012-07-17T04:45:18+00:00</IssueDate>
   <Issuer>OpenDCP 0.0.25</Issuer>
   <Creator>OpenDCP 0.0.25</Creator>
   <AssetList>
     <Asset>
       <Id>urn:uuid:81fb54df-e1bf-4647-8788-ea7ba154375b</Id>
       <AnnotationText>video.mxf</AnnotationText>
-      <Hash>4jimd5RaYhFS0ENh6tUTnjMqN/M=</Hash>
+      <Hash>E2vhyxdJQhEzSQZdp31w84ZZpfk=</Hash>
       <Size>26080</Size>
       <Type>application/mxf</Type>
     </Asset>
     <Asset>
       <Id>urn:uuid:c38bdd62-ce03-4988-8603-195f134207c7</Id>
       <AnnotationText>audio.mxf</AnnotationText>
-      <Hash>6YhrUkOvm46kYdhrgDuKNvfa9uA=</Hash>
+      <Hash>9OVODrw+zTkSbkGduoQ30k3Kk6Y=</Hash>
       <Size>305326</Size>
       <Type>application/mxf</Type>
     </Asset>
     <Asset>
       <Id>urn:uuid:df0e4141-13c3-4a7a-bef8-b5a04fcbc4bb</Id>
-      <Hash>DR62woRxafHQcqScRIHQd6hChFU=</Hash>
+      <Hash>5E8Q9swcc2bBbFF3IEPNXfIP8gM=</Hash>
       <Size>1526</Size>
       <Type>text/xml</Type>
     </Asset>
index cf84577283eae80158d7f79d361301fcb0f2b1d4..edb62bda546516ec8ce21c3bf423e60fa0fe304a 100644 (file)
@@ -3,7 +3,7 @@
   <Id>urn:uuid:18be072e-5a0f-44e1-b2eb-c8a52ae12789</Id>
   <Creator>OpenDCP 0.0.25</Creator>
   <VolumeCount>1</VolumeCount>
-  <IssueDate>2012-07-17T04:32:07+00:00</IssueDate>
+  <IssueDate>2012-07-17T04:45:18+00:00</IssueDate>
   <Issuer>OpenDCP 0.0.25</Issuer>
   <AssetList>
     <Asset>
index a945da6df35b1f8d12bb262c269d180a2ba6a8d1..8910b6fba09f08e22d213098a4147e08bcacb30a 100644 (file)
Binary files a/test/ref/DCP/audio.mxf and b/test/ref/DCP/audio.mxf differ
index 27fdc5b5ecf5e72231323eb672314eb8e7d60298..bb8775fd0fbb0c679e07d5a731ddeed1bf26f5c7 100644 (file)
@@ -2,18 +2,18 @@
 <CompositionPlaylist xmlns="http://www.smpte-ra.org/schemas/429-7/2006/CPL">
   <Id>urn:uuid:df0e4141-13c3-4a7a-bef8-b5a04fcbc4bb</Id>
   <AnnotationText>A Test DCP</AnnotationText>
-  <IssueDate>2012-07-17T04:32:07+00:00</IssueDate>
+  <IssueDate>2012-07-17T04:45:18+00:00</IssueDate>
   <Creator>OpenDCP 0.0.25</Creator>
   <ContentTitleText>A Test DCP</ContentTitleText>
   <ContentKind>feature</ContentKind>
   <ContentVersion>
-    <Id>urn:uri:df0e4141-13c3-4a7a-bef8-b5a04fcbc4bb_2012-07-17T04:32:07+00:00</Id>
-    <LabelText>df0e4141-13c3-4a7a-bef8-b5a04fcbc4bb_2012-07-17T04:32:07+00:00</LabelText>
+    <Id>urn:uri:df0e4141-13c3-4a7a-bef8-b5a04fcbc4bb_2012-07-17T04:45:18+00:00</Id>
+    <LabelText>df0e4141-13c3-4a7a-bef8-b5a04fcbc4bb_2012-07-17T04:45:18+00:00</LabelText>
   </ContentVersion>
   <RatingList/>
   <ReelList>
     <Reel>
-      <Id>urn:uuid:e4456baa-d4d6-42f6-bfc6-1cf748582227</Id>
+      <Id>urn:uuid:b135d5cf-d180-43d8-b0b3-7373737b73bf</Id>
       <AssetList>
         <MainPicture>
           <Id>urn:uuid:81fb54df-e1bf-4647-8788-ea7ba154375b</Id>
index d71cf1e3f634d8fddf9578b786bbe5fea77a3de0..645fb85affaaca1d273f5fff2b5f7abf10a850c5 100644 (file)
Binary files a/test/ref/DCP/video.mxf and b/test/ref/DCP/video.mxf differ
index 013a7c248bb81b0696bc7fd27dc88b5e96087b24..0b469e24e2237d817888d12f9ef8d8202e9d40ef 100755 (executable)
@@ -5,17 +5,18 @@ import sys
 import fileinput
 from lxml import etree
 
-def replace(l, a, b):
-    return l.replace(a, b)
-
 assetmap_namespace = 'http://www.smpte-ra.org/schemas/429-9/2007/AM'
 cpl_namespace = 'http://www.smpte-ra.org/schemas/429-7/2006/CPL'
+pkl_namespace = 'http://www.smpte-ra.org/schemas/429-8/2007/PKL'
 
 wanted_cpl_id = 'df0e4141-13c3-4a7a-bef8-b5a04fcbc4bb'
 wanted_pkl_id = '8e293965-f8ad-48c6-971d-261b01f65cdb'
 wanted_assetmap_id = '18be072e-5a0f-44e1-b2eb-c8a52ae12789'
 wanted_video_mxf_id = '81fb54df-e1bf-4647-8788-ea7ba154375b'
 wanted_audio_mxf_id = 'c38bdd62-ce03-4988-8603-195f134207c7'
+wanted_reel_id = 'b135d5cf-d180-43d8-b0b3-7373737b73bf'
+wanted_asset_hashes = ['E2vhyxdJQhEzSQZdp31w84ZZpfk=', '9OVODrw+zTkSbkGduoQ30k3Kk6Y=', '5E8Q9swcc2bBbFF3IEPNXfIP8gM=']
+wanted_issue_date = '2012-07-17T04:45:18+00:00'
 
 os.system('rm -rf DCP')
 os.mkdir('DCP')
@@ -27,6 +28,9 @@ os.system('mv *.xml DCP')
 cpl_id = None
 pkl_id = None
 assetmap_id = None
+video_mxf_id = None
+audio_mxf_id = None
+reel_id = None
 
 for r, d, f in os.walk('DCP'):
     for n in f:
@@ -61,15 +65,38 @@ audio_mxf_id = xml.getroot().find(cpl_name('ReelList')).    \
                              find(cpl_name('Id')).text
 audio_mxf_id = audio_mxf_id.replace('urn:uuid:', '')
 
+reel_id =      xml.getroot().find(cpl_name('ReelList')).    \
+                             find(cpl_name('Reel')).        \
+                             find(cpl_name('Id')).text
+reel_id = reel_id.replace('urn:uuid:', '')
+
+def pkl_name(s):
+    return '{%s}%s' % (pkl_namespace, s)
+
+xml = etree.parse('DCP/%s_pkl.xml' % wanted_pkl_id)
+
+asset_list =   xml.getroot().find(pkl_name('AssetList'))
+asset_hashes = []
+print asset_list
+for a in asset_list.iter():
+    if a.tag == "{%s}Hash" % pkl_namespace:
+        asset_hashes.append(a.text)
+
+issue_date =    xml.getroot().find(pkl_name('IssueDate')).text
+
 for r, d, f in os.walk('DCP'):
     for n in f:
         if n.endswith('.xml'):
             for line in fileinput.input(os.path.join(r, n), inplace = 1):
-                line = replace(line, cpl_id, wanted_cpl_id)
-                line = replace(line, pkl_id, wanted_pkl_id)
-                line = replace(line, assetmap_id, wanted_assetmap_id)
-                line = replace(line, video_mxf_id, wanted_video_mxf_id)
-                line = replace(line, audio_mxf_id, wanted_audio_mxf_id)
+                line = line.replace(cpl_id, wanted_cpl_id)
+                line = line.replace(pkl_id, wanted_pkl_id)
+                line = line.replace(assetmap_id, wanted_assetmap_id)
+                line = line.replace(video_mxf_id, wanted_video_mxf_id)
+                line = line.replace(audio_mxf_id, wanted_audio_mxf_id)
+                line = line.replace(reel_id, wanted_reel_id)
+                line = line.replace(issue_date, wanted_issue_date)
+                for i in range(0, len(asset_hashes)):
+                    line = line.replace(asset_hashes[i], wanted_asset_hashes[i])
                 print line,
                 
 
index 11f8a7eeea0ce0ef1b8154f54cffed8d61f3a208..41811b1ee8417f17c2d0ac40c698d565aba9091c 100644 (file)
@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE (dcp_test)
        t->company_name = "OpenDCP";
        t->product_name = "OpenDCP";
        t->product_version = "0.0.25";
-       t->issue_date = "2012-07-17T04:32:07+00:00";
+       t->issue_date = "2012-07-17T04:45:18+00:00";
        filesystem::remove_all ("build/test/foo");
        filesystem::create_directories ("build/test/foo");
        libdcp::DCP d ("build/test/foo", "A Test DCP", libdcp::DCP::FEATURE, 24, 24);