summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-06-07 12:36:40 +0200
committerCarl Hetherington <cth@carlh.net>2022-06-07 12:36:40 +0200
commit6a3c03c5eed3cab8fdfdb04fcbaf6cabe8c715e9 (patch)
tree8b5a7a47aff2a066f304c6bd31c2780c6f92ca98 /test
parentfcba100f0dfd1d4214291abb76f22ebd696c24d4 (diff)
Fix incorrect extension on interop subtitle files (#2270).
Diffstat (limited to 'test')
-rw-r--r--test/file_extension_test.cc78
-rw-r--r--test/test.cc6
-rw-r--r--test/wscript1
3 files changed, 82 insertions, 3 deletions
diff --git a/test/file_extension_test.cc b/test/file_extension_test.cc
new file mode 100644
index 000000000..2c9020b6c
--- /dev/null
+++ b/test/file_extension_test.cc
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "lib/content_factory.h"
+#include "lib/film.h"
+#include "test.h"
+#include <boost/test/unit_test.hpp>
+
+
+/* Sanity check to make sure that files in a DCP have the right extensions / names.
+ * This is mostly to catch a crazy mistake where Interop subtitle files suddenly got
+ * a MXF extension but no tests caught it (#2270).
+ */
+BOOST_AUTO_TEST_CASE (interop_file_extension_test)
+{
+ auto video = content_factory("test/data/flat_red.png").front();
+ auto audio = content_factory("test/data/sine_440.wav").front();
+ auto sub = content_factory("test/data/15s.srt").front();
+ auto film = new_test_film2("interop_file_extension_test", { video, audio, sub });
+ film->set_interop(true);
+
+ make_and_verify_dcp(
+ film, {
+ dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+ dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
+ dcp::VerificationNote::Code::INVALID_STANDARD
+ });
+
+ BOOST_REQUIRE(dcp_file(film, "ASSETMAP").extension() == "");
+ BOOST_REQUIRE(dcp_file(film, "VOLINDEX").extension() == "");
+ BOOST_REQUIRE(dcp_file(film, "cpl").extension() == ".xml");
+ BOOST_REQUIRE(dcp_file(film, "pkl").extension() == ".xml");
+ BOOST_REQUIRE(dcp_file(film, "j2c").extension() == ".mxf");
+ BOOST_REQUIRE(dcp_file(film, "pcm").extension() == ".mxf");
+ BOOST_REQUIRE(dcp_file(film, "sub").extension() == ".xml");
+}
+
+
+BOOST_AUTO_TEST_CASE (smpte_file_extension_test)
+{
+ auto video = content_factory("test/data/flat_red.png").front();
+ auto audio = content_factory("test/data/sine_440.wav").front();
+ auto sub = content_factory("test/data/15s.srt").front();
+ auto film = new_test_film2("smpte_file_extension_test", { video, audio, sub });
+ film->set_interop(false);
+
+ make_and_verify_dcp(
+ film, {
+ dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+ dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE
+ });
+
+ BOOST_REQUIRE(dcp_file(film, "ASSETMAP").extension() == ".xml");
+ BOOST_REQUIRE(dcp_file(film, "VOLINDEX").extension() == ".xml");
+ BOOST_REQUIRE(dcp_file(film, "cpl").extension() == ".xml");
+ BOOST_REQUIRE(dcp_file(film, "pkl").extension() == ".xml");
+ BOOST_REQUIRE(dcp_file(film, "j2c").extension() == ".mxf");
+ BOOST_REQUIRE(dcp_file(film, "pcm").extension() == ".mxf");
+ BOOST_REQUIRE(dcp_file(film, "sub").extension() == ".mxf");
+}
diff --git a/test/test.cc b/test/test.cc
index 9260d568f..105939473 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -791,12 +791,12 @@ check_one_frame (boost::filesystem::path dcp_dir, int64_t index, boost::filesyst
boost::filesystem::path
dcp_file (shared_ptr<const Film> film, string prefix)
{
- auto i = boost::filesystem::directory_iterator (film->dir(film->dcp_name()));
- while (i != boost::filesystem::directory_iterator() && !boost::algorithm::starts_with (i->path().leaf().string(), prefix)) {
+ auto i = boost::filesystem::recursive_directory_iterator(film->dir(film->dcp_name()));
+ while (i != boost::filesystem::recursive_directory_iterator() && !boost::algorithm::starts_with(i->path().leaf().string(), prefix)) {
++i;
}
- BOOST_REQUIRE (i != boost::filesystem::directory_iterator());
+ BOOST_REQUIRE_MESSAGE(i != boost::filesystem::recursive_directory_iterator(), "Could not find file with prefix " << prefix);
return i->path();
}
diff --git a/test/wscript b/test/wscript
index 88ff8c6bc..e05f85a58 100644
--- a/test/wscript
+++ b/test/wscript
@@ -76,6 +76,7 @@ def build(bld):
empty_caption_test.cc
empty_test.cc
encryption_test.cc
+ file_extension_test.cc
ffmpeg_audio_only_test.cc
ffmpeg_audio_test.cc
ffmpeg_dcp_test.cc