diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/client_server_test.cc | 36 | ||||
| -rw-r--r-- | test/config_test.cc | 114 | ||||
| -rw-r--r-- | test/content_test.cc | 2 | ||||
| m--------- | test/data | 0 | ||||
| -rw-r--r-- | test/ffmpeg_decoder_seek_test.cc | 55 | ||||
| -rw-r--r-- | test/ffmpeg_encoder_test.cc | 4 | ||||
| -rw-r--r-- | test/ffmpeg_examiner_test.cc | 2 | ||||
| -rw-r--r-- | test/j2k_encode_threading_test.cc | 117 | ||||
| -rw-r--r-- | test/kdm_cli_test.cc | 41 | ||||
| -rw-r--r-- | test/kdm_naming_test.cc | 26 | ||||
| -rw-r--r-- | test/low_bitrate_test.cc | 3 | ||||
| -rw-r--r-- | test/map_cli_test.cc | 1 | ||||
| -rw-r--r-- | test/shuffler_test.cc | 8 | ||||
| -rw-r--r-- | test/test.cc | 12 | ||||
| -rw-r--r-- | test/wscript | 1 |
15 files changed, 338 insertions, 84 deletions
diff --git a/test/client_server_test.cc b/test/client_server_test.cc index 596668aae..1bfa4c5a6 100644 --- a/test/client_server_test.cc +++ b/test/client_server_test.cc @@ -20,20 +20,18 @@ /** @file test/client_server_test.cc - * @brief Test the server class. + * @brief Test the remote encoding code. * @ingroup feature - * - * Create a test image and then encode it using the standard mechanism - * and also using a EncodeServer object running on localhost. Compare the resulting - * encoded data to check that they are the same. */ +#include "lib/content_factory.h" #include "lib/cross.h" #include "lib/dcp_video.h" #include "lib/dcpomatic_log.h" #include "lib/encode_server.h" #include "lib/encode_server_description.h" +#include "lib/encode_server_finder.h" #include "lib/file_log.h" #include "lib/image.h" #include "lib/j2k_image_proxy.h" @@ -51,6 +49,7 @@ using std::weak_ptr; using boost::thread; using boost::optional; using dcp::ArrayData; +using namespace dcpomatic; void @@ -105,7 +104,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb) ColourConversion(), VideoRange::FULL, weak_ptr<Content>(), - optional<Frame>(), + optional<ContentTime>(), false ); @@ -184,7 +183,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv) ColourConversion(), VideoRange::FULL, weak_ptr<Content>(), - optional<Frame>(), + optional<ContentTime>(), false ); @@ -250,7 +249,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k) ColourConversion(), VideoRange::FULL, weak_ptr<Content>(), - optional<Frame>(), + optional<ContentTime>(), false ); @@ -275,7 +274,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k) PresetColourConversion::all().front().conversion, VideoRange::FULL, weak_ptr<Content>(), - optional<Frame>(), + optional<ContentTime>(), false ); @@ -315,3 +314,22 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k) } +BOOST_AUTO_TEST_CASE(real_encode_with_server) +{ + auto content = content_factory(TestPaths::private_data() / "dolby_aurora.vob"); + auto film = new_test_film2("real_encode_with_server", content); + + EncodeServerFinder::instance(); + + EncodeServer server(true, 4); + thread server_thread(boost::bind(&EncodeServer::run, &server)); + + make_and_verify_dcp(film); + + server.stop(); + server_thread.join(); + + BOOST_CHECK(server.frames_encoded() > 0); + EncodeServerFinder::drop(); +} + diff --git a/test/config_test.cc b/test/config_test.cc index 103a6a585..00adb7b09 100644 --- a/test/config_test.cc +++ b/test/config_test.cc @@ -38,7 +38,7 @@ rewrite_bad_config (string filename, string extra_line) { using namespace boost::filesystem; - auto base = path("build/test/bad_config/2.16"); + auto base = path("build/test/bad_config/2.18"); auto file = base / filename; boost::system::error_code ec; @@ -73,47 +73,49 @@ BOOST_AUTO_TEST_CASE (config_backup_test) */ Config::instance(); - BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.1")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.1") == first_write_xml); - BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.2")); - BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.3")); - BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.4")); + boost::filesystem::path const prefix = "build/test/bad_config/2.18"; + + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.1")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.1") == first_write_xml); + BOOST_CHECK(!boost::filesystem::exists(prefix / "config.xml.2")); + BOOST_CHECK(!boost::filesystem::exists(prefix / "config.xml.3")); + BOOST_CHECK(!boost::filesystem::exists(prefix / "config.xml.4")); Config::drop(); auto const second_write_xml = rewrite_bad_config("config.xml", "second write"); Config::instance(); - BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.1")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.1") == first_write_xml); - BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.2")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.2") == second_write_xml); - BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.3")); - BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.4")); + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.1")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.1") == first_write_xml); + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.2")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.2") == second_write_xml); + BOOST_CHECK(!boost::filesystem::exists(prefix / "config.xml.3")); + BOOST_CHECK(!boost::filesystem::exists(prefix / "config.xml.4")); Config::drop(); auto const third_write_xml = rewrite_bad_config("config.xml", "third write"); Config::instance(); - BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.1")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.1") == first_write_xml); - BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.2")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.2") == second_write_xml); - BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.3")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.3") == third_write_xml); - BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.4")); + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.1")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.1") == first_write_xml); + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.2")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.2") == second_write_xml); + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.3")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.3") == third_write_xml); + BOOST_CHECK(!boost::filesystem::exists(prefix / "config.xml.4")); Config::drop(); auto const fourth_write_xml = rewrite_bad_config("config.xml", "fourth write"); Config::instance(); - BOOST_CHECK (boost::filesystem::exists("build/test/bad_config/2.16/config.xml.1")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.1") == first_write_xml); - BOOST_CHECK (boost::filesystem::exists("build/test/bad_config/2.16/config.xml.2")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.2") == second_write_xml); - BOOST_CHECK (boost::filesystem::exists("build/test/bad_config/2.16/config.xml.3")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.3") == third_write_xml); - BOOST_CHECK (boost::filesystem::exists("build/test/bad_config/2.16/config.xml.4")); - BOOST_CHECK (dcp::file_to_string("build/test/bad_config/2.16/config.xml.4") == fourth_write_xml); + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.1")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.1") == first_write_xml); + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.2")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.2") == second_write_xml); + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.3")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.3") == third_write_xml); + BOOST_CHECK(boost::filesystem::exists(prefix / "config.xml.4")); + BOOST_CHECK(dcp::file_to_string(prefix / "config.xml.4") == fourth_write_xml); } @@ -124,7 +126,7 @@ BOOST_AUTO_TEST_CASE (config_backup_with_link_test) ConfigRestorer cr; auto base = path("build/test/bad_config"); - auto version = base / "2.16"; + auto version = base / "2.18"; Config::override_path = base; Config::drop(); @@ -163,7 +165,8 @@ BOOST_AUTO_TEST_CASE (config_write_utf8_test) } -BOOST_AUTO_TEST_CASE (config_upgrade_test) +/* 2.14 -> 2.18 */ +BOOST_AUTO_TEST_CASE (config_upgrade_test1) { ConfigRestorer cr; @@ -185,12 +188,49 @@ BOOST_AUTO_TEST_CASE (config_upgrade_test) check_xml (dir / "cinemas.xml", "test/data/2.14.cinemas.xml", {}); #ifdef DCPOMATIC_WINDOWS /* This file has the windows path for dkdm_recipients.xml (with backslashes) */ - check_xml (dir / "2.16" / "config.xml", "test/data/2.16.config.windows.xml", {}); + check_xml(dir / "2.18" / "config.xml", "test/data/2.18.config.windows.xml", {}); +#else + check_xml(dir / "2.18" / "config.xml", "test/data/2.18.config.xml", {}); +#endif + /* cinemas.xml is not copied into 2.18 as its format has not changed */ + BOOST_REQUIRE (!boost::filesystem::exists(dir / "2.18" / "cinemas.xml")); +} + + +/* 2.16 -> 2.18 */ +BOOST_AUTO_TEST_CASE (config_upgrade_test2) +{ + ConfigRestorer cr; + + boost::filesystem::path dir = "build/test/config_upgrade_test"; + Config::override_path = dir; + Config::drop (); + boost::filesystem::remove_all (dir); + boost::filesystem::create_directories (dir); + +#ifdef DCPOMATIC_WINDOWS + boost::filesystem::copy_file("test/data/2.16.config.windows.xml", dir / "config.xml"); +#else + boost::filesystem::copy_file("test/data/2.16.config.xml", dir / "config.xml"); +#endif + boost::filesystem::copy_file("test/data/2.14.cinemas.xml", dir / "cinemas.xml"); + Config::instance(); + try { + /* This will fail to write cinemas.xml since the link is to a non-existent directory */ + Config::instance()->write(); + } catch (...) {} + + check_xml(dir / "cinemas.xml", "test/data/2.14.cinemas.xml", {}); +#ifdef DCPOMATIC_WINDOWS + /* This file has the windows path for dkdm_recipients.xml (with backslashes) */ + check_xml(dir / "2.18" / "config.xml", "test/data/2.18.config.windows.xml", {}); + check_xml(dir / "config.xml", "test/data/2.16.config.windows.xml", {}); #else - check_xml (dir / "2.16" / "config.xml", "test/data/2.16.config.xml", {}); + check_xml(dir / "2.18" / "config.xml", "test/data/2.18.config.xml", {}); + check_xml(dir / "config.xml", "test/data/2.16.config.xml", {}); #endif - /* cinemas.xml is not copied into 2.16 as its format has not changed */ - BOOST_REQUIRE (!boost::filesystem::exists(dir / "2.16" / "cinemas.xml")); + /* cinemas.xml is not copied into 2.18 as its format has not changed */ + BOOST_REQUIRE (!boost::filesystem::exists(dir / "2.18" / "cinemas.xml")); } @@ -206,13 +246,13 @@ BOOST_AUTO_TEST_CASE (config_keep_cinemas_if_making_new_config) Config::instance()->write(); - Config::instance()->add_cinema(make_shared<Cinema>("My Great Cinema", vector<string>(), "", 0, 0)); + Config::instance()->add_cinema(make_shared<Cinema>("My Great Cinema", vector<string>(), "")); Config::instance()->write(); boost::filesystem::copy_file (dir / "cinemas.xml", dir / "backup_for_test.xml"); Config::drop (); - boost::filesystem::remove (dir / "2.16" / "config.xml"); + boost::filesystem::remove (dir / "2.18" / "config.xml"); Config::instance(); check_text_file(dir / "backup_for_test.xml", dir / "cinemas.xml"); @@ -234,7 +274,7 @@ BOOST_AUTO_TEST_CASE(keep_config_if_cinemas_fail_to_load) auto const cinemas = dir / "cinemas.xml"; /* Back things up */ - boost::filesystem::copy_file(dir / "2.16" / "config.xml", dir / "config_backup_for_test.xml"); + boost::filesystem::copy_file(dir / "2.18" / "config.xml", dir / "config_backup_for_test.xml"); boost::filesystem::copy_file(cinemas, dir / "cinemas_backup_for_test.xml"); /* Corrupt the cinemas */ @@ -245,7 +285,7 @@ BOOST_AUTO_TEST_CASE(keep_config_if_cinemas_fail_to_load) Config::instance(); /* We should have a new cinemas.xml and the old config.xml */ - check_text_file(dir / "2.16" / "config.xml", dir / "config_backup_for_test.xml"); + check_text_file(dir / "2.18" / "config.xml", dir / "config_backup_for_test.xml"); check_text_file(cinemas, dir / "cinemas_backup_for_test.xml"); } diff --git a/test/content_test.cc b/test/content_test.cc index 5ab714b47..dce7643dc 100644 --- a/test/content_test.cc +++ b/test/content_test.cc @@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE (content_test6) film->set_audio_channels(16); make_and_verify_dcp (film); - check_dcp (TestPaths::private_data() / "fha", film); + check_dcp (TestPaths::private_data() / "v2.18.x" / "fha", film); cl.run (); } diff --git a/test/data b/test/data -Subproject 704f7643393caa29d77ddba138bff3642b273c4 +Subproject a5b12872bf034712039414fad58e7e68c068b77 diff --git a/test/ffmpeg_decoder_seek_test.cc b/test/ffmpeg_decoder_seek_test.cc index 4dceae86b..f38ef3564 100644 --- a/test/ffmpeg_decoder_seek_test.cc +++ b/test/ffmpeg_decoder_seek_test.cc @@ -64,18 +64,18 @@ store (ContentVideo v) static void -check (shared_ptr<FFmpegDecoder> decoder, int frame) +check (shared_ptr<FFmpegDecoder> decoder, ContentTime time) { BOOST_REQUIRE (decoder->ffmpeg_content()->video_frame_rate ()); - decoder->seek (ContentTime::from_frames (frame, decoder->ffmpeg_content()->video_frame_rate().get()), true); + decoder->seek(time, true); stored = optional<ContentVideo> (); while (!decoder->pass() && !stored) {} - BOOST_CHECK (stored->frame <= frame); + BOOST_CHECK(stored->time <= time); } static void -test (boost::filesystem::path file, vector<int> frames) +test (boost::filesystem::path file, vector<ContentTime> times) { auto path = TestPaths::private_data() / file; BOOST_REQUIRE (boost::filesystem::exists (path)); @@ -87,7 +87,7 @@ test (boost::filesystem::path file, vector<int> frames) auto decoder = make_shared<FFmpegDecoder>(film, content, false); decoder->video->Data.connect (bind (&store, _1)); - for (auto i: frames) { + for (auto i: times) { check (decoder, i); } } @@ -95,10 +95,43 @@ test (boost::filesystem::path file, vector<int> frames) BOOST_AUTO_TEST_CASE (ffmpeg_decoder_seek_test) { - vector<int> frames = { 0, 42, 999, 0 }; - - test ("boon_telly.mkv", frames); - test ("Sintel_Trailer1.480p.DivX_Plus_HD.mkv", frames); - test ("prophet_long_clip.mkv", { 15, 42, 999, 15 }); - test ("dolby_aurora.vob", { 0, 125, 250, 41 }); + test( + "boon_telly.mkv", + { + ContentTime::from_frames(0, 29.97), + ContentTime::from_frames(42, 29.97), + ContentTime::from_frames(999, 29.97), + ContentTime::from_frames(0, 29.97), + } + ); + + test( + "Sintel_Trailer1.480p.DivX_Plus_HD.mkv", + { + ContentTime::from_frames(0, 24), + ContentTime::from_frames(42, 24), + ContentTime::from_frames(999, 24), + ContentTime::from_frames(0, 24), + } + ); + + test( + "prophet_long_clip.mkv", + { + ContentTime::from_frames(15, 23.976), + ContentTime::from_frames(42, 23.976), + ContentTime::from_frames(999, 23.976), + ContentTime::from_frames(15, 23.976) + } + ); + + test( + "dolby_aurora.vob", + { + ContentTime::from_frames(0, 25), + ContentTime::from_frames(125, 25), + ContentTime::from_frames(250, 25), + ContentTime::from_frames(41, 25) + } + ); } diff --git a/test/ffmpeg_encoder_test.cc b/test/ffmpeg_encoder_test.cc index dc57b473b..f0133ff66 100644 --- a/test/ffmpeg_encoder_test.cc +++ b/test/ffmpeg_encoder_test.cc @@ -259,8 +259,8 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test4) /** Test mixdown from 5.1 to stereo */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test5) { - auto film = new_test_film ("ffmpeg_transcoder_h264_test5"); - film->set_name ("ffmpeg_transcoder_h264_test5"); + auto film = new_test_film("ffmpeg_encoder_h264_test5"); + film->set_name("ffmpeg_encoder_h264_test5"); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); diff --git a/test/ffmpeg_examiner_test.cc b/test/ffmpeg_examiner_test.cc index c745335ae..231bd16e0 100644 --- a/test/ffmpeg_examiner_test.cc +++ b/test/ffmpeg_examiner_test.cc @@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_examiner_probesize_test) BOOST_CHECK_EQUAL (examiner->audio_streams()[0]->frame_rate(), 48000); BOOST_CHECK_EQUAL (examiner->audio_streams()[0]->channels(), 2); BOOST_CHECK_EQUAL (examiner->audio_streams()[1]->frame_rate(), 48000); - BOOST_CHECK_EQUAL (examiner->audio_streams()[1]->channels(), 5); + BOOST_CHECK_EQUAL (examiner->audio_streams()[1]->channels(), 6); } diff --git a/test/j2k_encode_threading_test.cc b/test/j2k_encode_threading_test.cc new file mode 100644 index 000000000..ff2e7b0dc --- /dev/null +++ b/test/j2k_encode_threading_test.cc @@ -0,0 +1,117 @@ +/* + Copyright (C) 2023 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/config.h" +#include "lib/content_factory.h" +#include "lib/dcp_encoder.h" +#include "lib/dcp_transcode_job.h" +#include "lib/encode_server_description.h" +#include "lib/film.h" +#include "lib/j2k_encoder.h" +#include "lib/job_manager.h" +#include "lib/make_dcp.h" +#include "lib/transcode_job.h" +#include "test.h" +#include <dcp/cpl.h> +#include <dcp/dcp.h> +#include <dcp/reel.h> +#include <dcp/reel_picture_asset.h> +#include <boost/test/unit_test.hpp> + + +using std::dynamic_pointer_cast; +using std::list; + + +BOOST_AUTO_TEST_CASE(local_threads_created_and_destroyed) +{ + auto film = new_test_film2("local_threads_created_and_destroyed", {}); + Writer writer(film, {}); + J2KEncoder encoder(film, writer); + + encoder.remake_threads(32, 0, {}); + BOOST_CHECK_EQUAL(encoder._threads.size(), 32U); + + encoder.remake_threads(9, 0, {}); + BOOST_CHECK_EQUAL(encoder._threads.size(), 9U); + + encoder.end(); + BOOST_CHECK_EQUAL(encoder._threads.size(), 0U); +} + + +BOOST_AUTO_TEST_CASE(remote_threads_created_and_destroyed) +{ + auto film = new_test_film2("remote_threads_created_and_destroyed", {}); + Writer writer(film, {}); + J2KEncoder encoder(film, writer); + + list<EncodeServerDescription> servers = { + { "fred", 7, SERVER_LINK_VERSION }, + { "jim", 2, SERVER_LINK_VERSION }, + { "sheila", 14, SERVER_LINK_VERSION }, + }; + + encoder.remake_threads(0, 0, servers); + BOOST_CHECK_EQUAL(encoder._threads.size(), 7U + 2U + 14U); + + servers = { + { "fred", 7, SERVER_LINK_VERSION }, + { "jim", 5, SERVER_LINK_VERSION }, + { "sheila", 14, SERVER_LINK_VERSION }, + }; + + encoder.remake_threads(0, 0, servers); + BOOST_CHECK_EQUAL(encoder._threads.size(), 7U + 5U + 14U); + + servers = { + { "fred", 0, SERVER_LINK_VERSION }, + { "jim", 0, SERVER_LINK_VERSION }, + { "sheila", 11, SERVER_LINK_VERSION }, + }; + + encoder.remake_threads(0, 0, servers); + BOOST_CHECK_EQUAL(encoder._threads.size(), 11U); +} + + +BOOST_AUTO_TEST_CASE(frames_not_lost_when_threads_disappear) +{ + auto content = content_factory(TestPaths::private_data() / "clapperboard.mp4"); + auto film = new_test_film2("frames_not_lost", content); + film->write_metadata(); + auto job = make_dcp(film, TranscodeJob::ChangedBehaviour::IGNORE); + auto& encoder = dynamic_pointer_cast<DCPEncoder>(job->_encoder)->_j2k_encoder; + + while (JobManager::instance()->work_to_do()) { + encoder.remake_threads(rand() % 8, 0, {}); + dcpomatic_sleep_seconds(1); + } + + BOOST_CHECK(!JobManager::instance()->errors()); + + dcp::DCP dcp(film->dir(film->dcp_name())); + dcp.read(); + BOOST_REQUIRE_EQUAL(dcp.cpls().size(), 1U); + BOOST_REQUIRE_EQUAL(dcp.cpls()[0]->reels().size(), 1U); + BOOST_REQUIRE_EQUAL(dcp.cpls()[0]->reels()[0]->main_picture()->intrinsic_duration(), 423U); +} + diff --git a/test/kdm_cli_test.cc b/test/kdm_cli_test.cc index e79e37b2d..2e5e4760c 100644 --- a/test/kdm_cli_test.cc +++ b/test/kdm_cli_test.cc @@ -87,13 +87,13 @@ setup_test_config() auto config = Config::instance(); auto const cert = dcp::Certificate(dcp::file_to_string("test/data/cert.pem")); - auto cinema_a = std::make_shared<Cinema>("Dean's Screens", vector<string>(), "", 0, 0); + auto cinema_a = std::make_shared<Cinema>("Dean's Screens", vector<string>(), ""); cinema_a->add_screen(std::make_shared<dcpomatic::Screen>("Screen 1", "", cert, boost::none, std::vector<TrustedDevice>())); cinema_a->add_screen(std::make_shared<dcpomatic::Screen>("Screen 2", "", cert, boost::none, std::vector<TrustedDevice>())); cinema_a->add_screen(std::make_shared<dcpomatic::Screen>("Screen 3", "", cert, boost::none, std::vector<TrustedDevice>())); config->add_cinema(cinema_a); - auto cinema_b = std::make_shared<Cinema>("Floyd's Celluloid", vector<string>(), "", 0, 0); + auto cinema_b = std::make_shared<Cinema>("Floyd's Celluloid", vector<string>(), ""); cinema_b->add_screen(std::make_shared<dcpomatic::Screen>("Foo", "", cert, boost::none, std::vector<TrustedDevice>())); cinema_b->add_screen(std::make_shared<dcpomatic::Screen>("Bar", "", cert, boost::none, std::vector<TrustedDevice>())); config->add_cinema(cinema_b); @@ -228,3 +228,40 @@ BOOST_AUTO_TEST_CASE(kdm_cli_specify_cert) BOOST_CHECK(boost::filesystem::exists(kdm_filename)); } + +BOOST_AUTO_TEST_CASE(kdm_cli_time) +{ + ConfigRestorer cr; + + setup_test_config(); + + boost::filesystem::path kdm_filename = "build/test/KDM_Test_FTR-1_F-133_XX-XX_MOS_2K_20220109_SMPTE_OV_Deans_Screens_Screen_2.xml"; + + boost::system::error_code ec; + boost::filesystem::remove(kdm_filename, ec); + + dcp::LocalTime now; + now.add_days(2); + + vector<string> args = { + "kdm_cli", + "--verbose", + "--valid-from", now.as_string(), + "--valid-duration", "2 weeks", + "-c", "Dean's Screens", + "-S", "Screen 2", + "-o", "build/test", + "test/data/dkdm.xml" + }; + + vector<string> output; + auto error = run(args, output); + BOOST_CHECK(!error); + + BOOST_REQUIRE_EQUAL(output.size(), 2U); + BOOST_CHECK(boost::algorithm::starts_with(output[0], "Making KDMs valid from")); + BOOST_CHECK_EQUAL(output[1], "Wrote 1 KDM files to build/test"); + + BOOST_CHECK(boost::filesystem::exists(kdm_filename)); +} + diff --git a/test/kdm_naming_test.cc b/test/kdm_naming_test.cc index 32500553e..0f44fe2ea 100644 --- a/test/kdm_naming_test.cc +++ b/test/kdm_naming_test.cc @@ -59,16 +59,14 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test) auto crypt_cert = c->decryption_chain()->leaf(); - /* Cinema A: UTC +4:30 */ - auto cinema_a = make_shared<Cinema>("Cinema A", vector<string>(), "", 4, 30); + auto cinema_a = make_shared<Cinema>("Cinema A", vector<string>(), ""); cinema_a_screen_1 = std::make_shared<dcpomatic::Screen>("Screen 1", "", crypt_cert, boost::none, vector<TrustedDevice>()); cinema_a->add_screen (cinema_a_screen_1); cinema_a_screen_2 = std::make_shared<dcpomatic::Screen>("Screen 2", "", crypt_cert, boost::none, vector<TrustedDevice>()); cinema_a->add_screen (cinema_a_screen_2); c->add_cinema (cinema_a); - /* Cinema B: UTC -1:00 */ - auto cinema_b = make_shared<Cinema>("Cinema B", vector<string>(), "", -1, 0); + auto cinema_b = make_shared<Cinema>("Cinema B", vector<string>(), ""); cinema_b_screen_x = std::make_shared<dcpomatic::Screen>("Screen X", "", crypt_cert, boost::none, vector<TrustedDevice>()); cinema_b->add_screen (cinema_b_screen_x); cinema_b_screen_y = std::make_shared<dcpomatic::Screen>("Screen Y", "", crypt_cert, boost::none, vector<TrustedDevice>()); @@ -90,14 +88,13 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test) auto sign_cert = c->signer_chain()->leaf(); - dcp::LocalTime from (sign_cert.not_before()); + dcp::LocalTime from = sign_cert.not_before(); + from.set_offset({ 4, 30 }); from.add_months (2); - dcp::LocalTime until (sign_cert.not_after()); + dcp::LocalTime until = sign_cert.not_after(); + until.set_offset({ 4, 30 }); until.add_months (-2); - auto const from_string = from.date() + " " + from.time_of_day(true, false); - auto const until_string = until.date() + " " + until.time_of_day(true, false); - std::vector<KDMCertificatePeriod> period_checks; auto cpl = cpls.front().cpl_file; @@ -107,8 +104,8 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test) auto kdm = kdm_for_screen ( make_kdm, cinema_a_screen_1, - boost::posix_time::time_from_string(from_string), - boost::posix_time::time_from_string(until_string), + from, + until, dcp::Formulation::MODIFIED_TRANSITIONAL_1, false, optional<int>(), @@ -157,9 +154,6 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on( dcp::LocalTime until (sign_cert.not_after()); until.add_months (-2); - string const from_string = from.date() + " " + from.time_of_day(true, false); - string const until_string = until.date() + " " + until.time_of_day(true, false); - vector<shared_ptr<dcpomatic::Screen>> screens = { cinema_a_screen_2, cinema_b_screen_x, cinema_a_screen_1, (cinema_b_screen_z) }; @@ -178,8 +172,8 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on( auto kdm = kdm_for_screen ( make_kdm, i, - boost::posix_time::time_from_string(from_string), - boost::posix_time::time_from_string(until_string), + from, + until, dcp::Formulation::MODIFIED_TRANSITIONAL_1, false, optional<int>(), diff --git a/test/low_bitrate_test.cc b/test/low_bitrate_test.cc index 7050dd771..52b8d54be 100644 --- a/test/low_bitrate_test.cc +++ b/test/low_bitrate_test.cc @@ -31,6 +31,7 @@ extern "C" { using std::make_shared; +using namespace dcpomatic; BOOST_AUTO_TEST_CASE (low_bitrate_test) @@ -51,7 +52,7 @@ BOOST_AUTO_TEST_CASE (low_bitrate_test) boost::optional<ColourConversion>(), VideoRange::FULL, std::weak_ptr<Content>(), - boost::optional<Frame>(), + boost::optional<ContentTime>(), false ); diff --git a/test/map_cli_test.cc b/test/map_cli_test.cc index ed2a7e5ec..0600de31e 100644 --- a/test/map_cli_test.cc +++ b/test/map_cli_test.cc @@ -466,6 +466,7 @@ BOOST_AUTO_TEST_CASE(map_with_given_config) }; boost::filesystem::remove_all(out); + boost::filesystem::remove_all("test/data/map_with_given_config/2.18"); Config::instance()->drop(); vector<string> output_messages; diff --git a/test/shuffler_test.cc b/test/shuffler_test.cc index 2099a0923..37d6749c3 100644 --- a/test/shuffler_test.cc +++ b/test/shuffler_test.cc @@ -33,14 +33,15 @@ using boost::optional; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif +using namespace dcpomatic; static void -push (Shuffler& s, int frame, Eyes eyes) +push(Shuffler& s, int frame, Eyes eyes) { auto piece = make_shared<Piece>(shared_ptr<Content>(), shared_ptr<Decoder>(), FrameRateChange(24, 24)); ContentVideo cv; - cv.frame = frame; + cv.time = ContentTime::from_frames(frame, 24); cv.eyes = eyes; s.video (piece, cv); } @@ -56,8 +57,9 @@ receive (weak_ptr<Piece>, ContentVideo cv) static void check (int frame, Eyes eyes, int line) { + auto const time = ContentTime::from_frames(frame, 24); BOOST_REQUIRE_MESSAGE (!pending_cv.empty(), "Check at " << line << " failed."); - BOOST_CHECK_MESSAGE (pending_cv.front().frame == frame, "Check at " << line << " failed."); + BOOST_CHECK_MESSAGE (pending_cv.front().time == time, "Check at " << line << " failed."); BOOST_CHECK_MESSAGE (pending_cv.front().eyes == eyes, "Check at " << line << " failed."); pending_cv.pop_front(); } diff --git a/test/test.cc b/test/test.cc index fc5d9dc83..bf008998a 100644 --- a/test/test.cc +++ b/test/test.cc @@ -163,11 +163,21 @@ struct TestConfig setup_test_config (); capture_ffmpeg_logs(); - EncodeServerFinder::instance()->stop (); + EncodeServerFinder::drop(); signal_manager = new TestSignalManager (); dcpomatic_log.reset (new FileLog("build/test/log")); + + auto const& suite = boost::unit_test::framework::master_test_suite(); + int types = LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR; + for (int i = 1; i < suite.argc; ++i) { + if (string(suite.argv[i]) == "--log=debug-player") { + types |= LogEntry::TYPE_DEBUG_PLAYER; + } + } + + dcpomatic_log->set_types(types); } ~TestConfig () diff --git a/test/wscript b/test/wscript index 7930397f6..f464b34cd 100644 --- a/test/wscript +++ b/test/wscript @@ -111,6 +111,7 @@ def build(bld): interrupt_encoder_test.cc isdcf_name_test.cc j2k_bandwidth_test.cc + j2k_encode_threading_test.cc job_manager_test.cc kdm_cli_test.cc kdm_naming_test.cc |
