Allow tests to be run on Windows.
authorCarl Hetherington <cth@carlh.net>
Wed, 20 Apr 2022 18:49:04 +0000 (20:49 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 4 May 2022 17:37:38 +0000 (19:37 +0200)
cscript
run/tests.bat [new file with mode: 0644]
test/cpl_sar_test.cc
test/decryption_test.cc
test/encryption_test.cc
test/frame_info_hash_test.cc
test/verify_test.cc

diff --git a/cscript b/cscript
index 7b767ddfdb7e54b8681faf358232cfa813b20ec6..fd625204fede397527ebe174115cc94a8e82256d 100644 (file)
--- a/cscript
+++ b/cscript
@@ -52,7 +52,7 @@ def build(target, options):
             # We only build tests on Ubuntu 18.04
             cmd += ' --disable-tests'
     elif target.platform == 'windows':
-        cmd += f' --target-windows-{target.bits} --disable-tests'
+        cmd += f' --target-windows-{target.bits}'
         if target.version == 'xp':
             # OpenJPEG 1.x is inexplicably faster on Windows XP; see DCP-o-matic bug #771
             cmd += ' --jpeg=oj1'
@@ -89,9 +89,9 @@ def make_doxygen(target):
     return os.path.abspath('build/doc/html')
 
 def test(target, test):
-    if target.platform != 'windows':
-        target.set('LC_ALL', 'C')
-        if test is None:
-            target.command('run/tests')
-        else:
-            target.command('run/tests --run_test=%s' % test)
+    target.set('LC_ALL', 'C')
+    cmd = 'run\\tests ' if target.platform == 'windows' else 'run/tests '
+    if test is not None:
+        cmd += '-t %s' % test
+    target.command(cmd)
+
diff --git a/run/tests.bat b/run/tests.bat
new file mode 100644 (file)
index 0000000..13c8490
--- /dev/null
@@ -0,0 +1,4 @@
+set PATH=%PATH%;c:\users\ci\bin;c:\users\ci\workspace\libdcp\bin;c:\users\ci\workspace\libdcp\lib
+xcopy ..\libdcp\tags build\tags\
+xcopy ..\libdcp\ratings build\
+build\test\tests.exe --log_level=test_suite -- c:\users\ci\libdcp-test-private
index 1bf536868d7b63eb8fa948e3844215bfb2528692..0ecc87e0239cb6890f7421bee4b8ea5691551fa0 100644 (file)
@@ -48,9 +48,9 @@ using std::shared_ptr;
 using std::make_shared;
 
 static void
-check (shared_ptr<dcp::ReelMonoPictureAsset> pa, dcp::Fraction far, string sar)
+check (shared_ptr<dcp::ReelMonoPictureAsset> pa, dcp::Fraction frac, string sar)
 {
-       pa->set_screen_aspect_ratio (far);
+       pa->set_screen_aspect_ratio (frac);
        xmlpp::Document doc;
        auto el = doc.create_root_node ("Test");
        pa->write_to_cpl (el, dcp::Standard::INTEROP);
index eb305c6ae1a2267a003d6859095b096f867b5543..ce5aeecee18f85b908a4ef12072ea071102dc06f 100644 (file)
 #include <boost/scoped_array.hpp>
 
 
+#ifndef M_PI
+#define M_PI (3.14159265358979323846)
+#endif
+
+
 using std::dynamic_pointer_cast;
 using std::make_pair;
 using std::make_shared;
index dd7ccadb40dc0c9968aed1f2c383469b82b4feac..93cea8dc396272b297e5c442163c269b33e9ec73 100644 (file)
@@ -157,13 +157,15 @@ BOOST_AUTO_TEST_CASE (encryption_test)
 
        int r = system (
                "xmllint --path schema --nonet --noout --schema schema/SMPTE-430-1-2006-Amd-1-2009-KDM.xsd build/test/encryption_test.kdm.xml "
+#ifndef LIBDCP_WINDOWS
                "> build/test/xmllint.log 2>&1 < /dev/null"
+#endif
                );
 
 #ifdef LIBDCP_WINDOWS
        BOOST_CHECK_EQUAL (r, 0);
 #else
-       BOOST_CHECK_EQUAL (WEXITSTATUS (r), 0);
+       BOOST_CHECK_EQUAL (WEXITSTATUS(r), 0);
 #endif
 
        r = system ("xmlsec1 verify "
@@ -171,8 +173,12 @@ BOOST_AUTO_TEST_CASE (encryption_test)
                "--trusted-pem test/ref/crypt/intermediate.signed.pem "
                "--trusted-pem test/ref/crypt/ca.self-signed.pem "
                "--id-attr:Id http://www.smpte-ra.org/schemas/430-3/2006/ETM:AuthenticatedPublic "
-               "--id-attr:Id http://www.smpte-ra.org/schemas/430-3/2006/ETM:AuthenticatedPrivate "
-                   "build/test/encryption_test.kdm.xml > build/test/xmlsec1.log 2>&1 < /dev/null");
+               "--id-attr:Id http://www.smpte-ra.org/schemas/430-3/2006/ETM:AuthenticatedPrivate --crypto openssl "
+               "build/test/encryption_test.kdm.xml "
+#ifndef LIBDCP_WINDOWS
+               "> build/test/xmlsec1.log 2>&1 < /dev/null"
+#endif
+                  );
 
 #ifdef LIBDCP_WINDOWS
        BOOST_CHECK_EQUAL (r, 0);
index 82e0f3ac0bd12246d950f383dfc8b44e737fc0f8..677a00710fd55aae2d9fab99ebfce7a9aa9ee6ac 100644 (file)
@@ -42,12 +42,12 @@ using std::shared_ptr;
 using std::make_shared;
 
 static void
-check (unsigned int* seed, shared_ptr<dcp::PictureAssetWriter> writer, string hash)
+check (shared_ptr<dcp::PictureAssetWriter> writer, string hash)
 {
        shared_ptr<dcp::OpenJPEGImage> xyz (new dcp::OpenJPEGImage (dcp::Size (1998, 1080)));
        for (int c = 0; c < 3; ++c) {
                for (int p = 0; p < (1998 * 1080); ++p) {
-                       xyz->data(c)[p] = rand_r (seed) & 0xfff;
+                       xyz->data(c)[p] = rand() & 0xfff;
                }
        }
 
@@ -57,16 +57,17 @@ check (unsigned int* seed, shared_ptr<dcp::PictureAssetWriter> writer, string ha
        BOOST_CHECK_EQUAL (info.hash, hash);
 }
 
+
 /** Test the hashing of data written to JPEG2000 MXFs with some random inputs */
 BOOST_AUTO_TEST_CASE (frame_info_hash_test)
 {
        auto mp = make_shared<dcp::MonoPictureAsset>(dcp::Fraction (24, 1), dcp::Standard::SMPTE);
        auto writer = mp->start_write ("build/test/frame_info_hash_test.mxf", false);
 
-       unsigned int seed = 42;
+       srand(42);
 
        /* Check a few random frames */
-       check (&seed, writer, "9da3d1d93a80683e65d996edae4101ed");
-       check (&seed, writer, "ecd77b3fbf459591f24119d4118783fb");
-       check (&seed, writer, "9f10303495b58ccb715c893d40127e22");
+       check (writer, "9da3d1d93a80683e65d996edae4101ed");
+       check (writer, "ecd77b3fbf459591f24119d4118783fb");
+       check (writer, "9f10303495b58ccb715c893d40127e22");
 }
index 76c20ffc2addf3f6acbbfe7e5eb976d861a262cd..38be998bb225395f093511b939d56262afad8b2f 100644 (file)
@@ -3007,7 +3007,7 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_subtitle_resource_id)
        auto xml_id = dcp::make_uuid ();
        ASDCP::TimedText::MXFWriter writer;
        auto subs_mxf = dir / "subs.mxf";
-       auto r = writer.OpenWrite(subs_mxf.c_str(), writer_info, descriptor, 4096);
+       auto r = writer.OpenWrite(subs_mxf.string().c_str(), writer_info, descriptor, 4096);
        BOOST_REQUIRE (ASDCP_SUCCESS(r));
        writer.WriteTimedTextResource (dcp::String::compose(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -3071,7 +3071,7 @@ BOOST_AUTO_TEST_CASE (verify_incorrect_timed_text_id)
        auto xml_id = resource_id;
        ASDCP::TimedText::MXFWriter writer;
        auto subs_mxf = dir / "subs.mxf";
-       auto r = writer.OpenWrite(subs_mxf.c_str(), writer_info, descriptor, 4096);
+       auto r = writer.OpenWrite(subs_mxf.string().c_str(), writer_info, descriptor, 4096);
        BOOST_REQUIRE (ASDCP_SUCCESS(r));
        writer.WriteTimedTextResource (dcp::String::compose(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"