projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
91e0b54
)
Add ConfigRestorer and use it instead of setup_test_config() directly.
author
Carl Hetherington
<cth@carlh.net>
Tue, 2 Nov 2021 22:14:04 +0000
(23:14 +0100)
committer
Carl Hetherington
<cth@carlh.net>
Wed, 3 Nov 2021 10:29:27 +0000
(11:29 +0100)
test/config_test.cc
patch
|
blob
|
history
test/import_dcp_test.cc
patch
|
blob
|
history
test/test.cc
patch
|
blob
|
history
test/test.h
patch
|
blob
|
history
test/vf_kdm_test.cc
patch
|
blob
|
history
diff --git
a/test/config_test.cc
b/test/config_test.cc
index 035d778281936f9ddc3f4eb7de119d1b5819957b..48dec27d76543e9b13566ae1f614f3f9c75d62c8 100644
(file)
--- a/
test/config_test.cc
+++ b/
test/config_test.cc
@@
-47,6
+47,8
@@
rewrite_bad_config ()
BOOST_AUTO_TEST_CASE (config_backup_test)
{
BOOST_AUTO_TEST_CASE (config_backup_test)
{
+ ConfigRestorer cr;
+
Config::override_path = "build/test/bad_config";
Config::drop();
Config::override_path = "build/test/bad_config";
Config::drop();
@@
-88,16
+90,13
@@
BOOST_AUTO_TEST_CASE (config_backup_test)
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_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)
{
}
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";
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";
@@
-105,16
+104,13
@@
BOOST_AUTO_TEST_CASE (config_write_utf8_test)
Config::instance()->write();
check_text_file ("test/data/utf8_config.xml", "build/test/config.xml");
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)
{
}
BOOST_AUTO_TEST_CASE (config_upgrade_test)
{
+ ConfigRestorer cr;
+
boost::filesystem::path dir = "build/test/config_upgrade_test";
Config::override_path = dir;
Config::drop ();
boost::filesystem::path dir = "build/test/config_upgrade_test";
Config::override_path = dir;
Config::drop ();
@@
-139,7
+135,5
@@
BOOST_AUTO_TEST_CASE (config_upgrade_test)
#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"));
#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();
}
}
diff --git
a/test/import_dcp_test.cc
b/test/import_dcp_test.cc
index 8107aa77a0300e560607f8d21ca2f85d78265da4..46deea53931480b2bb35965f548245036d7e9bc8 100644
(file)
--- a/
test/import_dcp_test.cc
+++ b/
test/import_dcp_test.cc
@@
-54,6
+54,8
@@
using std::make_shared;
/** Make an encrypted DCP, import it and make a new unencrypted DCP */
BOOST_AUTO_TEST_CASE (import_dcp_test)
{
/** 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"));
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"));
@@
-100,9
+102,6
@@
BOOST_AUTO_TEST_CASE (import_dcp_test)
/* Should be 1s red, 1s green, 1s blue */
check_dcp ("test/data/import_dcp_test2", "build/test/import_dcp_test2/" + B->dcp_name());
/* 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 ();
}
}
diff --git
a/test/test.cc
b/test/test.cc
index b40d5eed6e9eaa96abb86655a6db677085ebf110..d1677a107cf4f25af2f6f33e9a9d05374778dfc1 100644
(file)
--- a/
test/test.cc
+++ b/
test/test.cc
@@
-99,10
+99,10
@@
boost::filesystem::path TestPaths::xsd ()
}
}
-void
+
static
void
setup_test_config ()
{
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"));
Config::instance()->set_server_encoding_threads (1);
Config::instance()->set_server_port_base (61921);
Config::instance()->set_default_container (Ratio::from_id ("185"));
@@
-914,3
+914,10
@@
check_int_close (std::pair<int, int> a, std::pair<int, int> b, int d)
check_int_close (a.first, b.first, d);
check_int_close (a.second, b.second, d);
}
check_int_close (a.first, b.first, d);
check_int_close (a.second, b.second, d);
}
+
+
+ConfigRestorer::~ConfigRestorer()
+{
+ setup_test_config();
+}
+
diff --git
a/test/test.h
b/test/test.h
index 217b738f48d2144d81fba4f4dc589f7f745fd09f..2b01db294286743dbca0a2631ff72c6f8174be5a 100644
(file)
--- a/
test/test.h
+++ b/
test/test.h
@@
-56,7
+56,6
@@
private:
extern bool wait_for_jobs ();
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);
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);
@@
-91,6
+90,13
@@
private:
};
};
+class ConfigRestorer
+{
+public:
+ ~ConfigRestorer();
+};
+
+
namespace dcp {
std::ostream& operator<< (std::ostream& s, dcp::Size i);
namespace dcp {
std::ostream& operator<< (std::ostream& s, dcp::Size i);
diff --git
a/test/vf_kdm_test.cc
b/test/vf_kdm_test.cc
index 44d497e6df89fe6993d29320b47a8a249e5f3a41..5248ee798d7bb328001650fcf0811f85048f8510 100644
(file)
--- a/
test/vf_kdm_test.cc
+++ b/
test/vf_kdm_test.cc
@@
-47,6
+47,8
@@
using std::vector;
BOOST_AUTO_TEST_CASE (vf_kdm_test)
{
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");
/* Make an encrypted DCP from test.mp4 */
auto A = new_test_film ("vf_kdm_test_ov");
@@
-124,7
+126,4
@@
BOOST_AUTO_TEST_CASE (vf_kdm_test)
/* 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());
/* 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 ();
}
}