Simple test to make sure a couple of simple make DCP jobs complete.
authorCarl Hetherington <cth@carlh.net>
Sun, 7 Oct 2012 21:42:49 +0000 (22:42 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 7 Oct 2012 21:42:49 +0000 (22:42 +0100)
src/lib/job_manager.cc
src/lib/job_manager.h
test/test.cc

index a166b5924dd0e3c472c89bdcc24bdd378c07797a..76fcc6c5d736d72a25b3079584706bb4b6b8963d 100644 (file)
@@ -73,6 +73,20 @@ JobManager::work_to_do () const
        return i != _jobs.end ();
 }
 
+bool
+JobManager::errors () const
+{
+       boost::mutex::scoped_lock lm (_mutex);
+       for (list<shared_ptr<Job> >::const_iterator i = _jobs.begin(); i != _jobs.end(); ++i) {
+               if ((*i)->finished_in_error ()) {
+                       return true;
+               }
+       }
+
+       return false;
+}      
+
+
 void
 JobManager::scheduler ()
 {
index d1d33cfc2ce7e7dc3ac4693d579d7309e0ec30e5..8b79fd67d330c6078563da2f5972a8766801095c 100644 (file)
@@ -41,6 +41,7 @@ public:
        void add_after (boost::shared_ptr<Job> after, boost::shared_ptr<Job> j);
        std::list<boost::shared_ptr<Job> > get () const;
        bool work_to_do () const;
+       bool errors () const;
 
        static JobManager* instance ();
 
index 638d526e05f760303a6b98945e86f098e27c961a..99781d1a28e6d81636a8689a724e41cff97910e3 100644 (file)
@@ -315,3 +315,50 @@ BOOST_AUTO_TEST_CASE (client_server_test)
                (*i)->join ();
        }
 }
+
+BOOST_AUTO_TEST_CASE (make_dcp_test)
+{
+       string const test_film = "build/test/film2";
+       
+       if (boost::filesystem::exists (test_film)) {
+               boost::filesystem::remove_all (test_film);
+       }
+       
+       Film film (test_film, false);
+       film.set_name ("test_film");
+       film.set_content ("../../../test/test.mp4");
+       film.examine_content ();
+       film.set_format (Format::from_ratio (185));
+       film.set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
+       film.make_dcp (true);
+
+       while (JobManager::instance()->work_to_do ()) {
+               sleep (1);
+       }
+       
+       BOOST_CHECK_EQUAL (JobManager::instance()->errors(), false);
+}
+
+BOOST_AUTO_TEST_CASE (make_dcp_with_range_test)
+{
+       string const test_film = "build/test/film3";
+       
+       if (boost::filesystem::exists (test_film)) {
+               boost::filesystem::remove_all (test_film);
+       }
+       
+       Film film (test_film, false);
+       film.set_name ("test_film");
+       film.set_content ("../../../test/test.mp4");
+       film.examine_content ();
+       film.set_format (Format::from_ratio (185));
+       film.set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
+       film.set_dcp_frames (42);
+       film.make_dcp (true);
+
+       while (JobManager::instance()->work_to_do ()) {
+               sleep (1);
+       }
+
+       BOOST_CHECK_EQUAL (JobManager::instance()->errors(), false);
+}