BOOST_AUTO_TEST_CASE (config_backup_test)
{
+ ConfigRestorer cr;
+
Config::override_path = "build/test/bad_config";
Config::drop();
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"));
-
- /* This test has called Config::set_defaults(), so take us back
- to the config that we want for our tests.
- */
- setup_test_config ();
}
BOOST_AUTO_TEST_CASE (config_write_utf8_test)
{
+ ConfigRestorer cr;
+
boost::filesystem::remove_all ("build/test/config.xml");
boost::filesystem::copy_file ("test/data/utf8_config.xml", "build/test/config.xml");
Config::override_path = "build/test";
Config::instance()->write();
check_text_file ("test/data/utf8_config.xml", "build/test/config.xml");
-
- /* This test has called Config::set_defaults(), so take us back
- to the config that we want for our tests.
- */
- setup_test_config ();
}
BOOST_AUTO_TEST_CASE (config_upgrade_test)
{
+ ConfigRestorer cr;
+
boost::filesystem::path dir = "build/test/config_upgrade_test";
Config::override_path = dir;
Config::drop ();
#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"));
-
- setup_test_config();
}
/** Make an encrypted DCP, import it and make a new unencrypted DCP */
BOOST_AUTO_TEST_CASE (import_dcp_test)
{
+ ConfigRestorer cr;
+
auto A = new_test_film ("import_dcp_test");
A->set_container (Ratio::from_id ("185"));
A->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
/* Should be 1s red, 1s green, 1s blue */
check_dcp ("test/data/import_dcp_test2", "build/test/import_dcp_test2/" + B->dcp_name());
-
- /* Restore the reference decryption chain */
- setup_test_config ();
}
}
-void
+static void
setup_test_config ()
{
- Config::instance()->set_master_encoding_threads (boost::thread::hardware_concurrency());
+ Config::instance()->set_master_encoding_threads (boost::thread::hardware_concurrency() / 2);
Config::instance()->set_server_encoding_threads (1);
Config::instance()->set_server_port_base (61921);
Config::instance()->set_default_container (Ratio::from_id ("185"));
check_int_close (a.first, b.first, d);
check_int_close (a.second, b.second, d);
}
+
+
+ConfigRestorer::~ConfigRestorer()
+{
+ setup_test_config();
+}
+
extern bool wait_for_jobs ();
-extern void setup_test_config ();
extern std::shared_ptr<Film> new_test_film (std::string);
extern std::shared_ptr<Film> new_test_film2 (std::string, std::vector<std::shared_ptr<Content>> content = {}, Cleanup* cleanup = nullptr);
extern void check_dcp (boost::filesystem::path, boost::filesystem::path);
};
+class ConfigRestorer
+{
+public:
+ ~ConfigRestorer();
+};
+
+
namespace dcp {
std::ostream& operator<< (std::ostream& s, dcp::Size i);
BOOST_AUTO_TEST_CASE (vf_kdm_test)
{
+ ConfigRestorer cr;
+
/* Make an encrypted DCP from test.mp4 */
auto A = new_test_film ("vf_kdm_test_ov");
/* Should be 1s red, 1s green, 1s blue */
check_dcp ("test/data/vf_kdm_test_check", "build/test/vf_kdm_test_check/" + C->dcp_name());
-
- /* Restore the reference decryption chain */
- setup_test_config ();
}