diff options
| -rw-r--r-- | test/grok_test.cc | 20 | ||||
| -rw-r--r-- | test/mock_grok.cc | 11 |
2 files changed, 30 insertions, 1 deletions
diff --git a/test/grok_test.cc b/test/grok_test.cc index ef58088ce..09ed626da 100644 --- a/test/grok_test.cc +++ b/test/grok_test.cc @@ -63,4 +63,24 @@ BOOST_AUTO_TEST_CASE(mock_grok_encode_test) make_and_verify_dcp(film); } + +BOOST_AUTO_TEST_CASE(mock_grok_encode_test_with_lost_frames) +{ + ConfigRestorer cr; + + grk_plugin::setGrokLogger(new grk_plugin::GrokLogger("[GROK] ")); + + auto grok = Config::instance()->grok(); + grok.enable = true; + grok.binary_location = "build/test"; + /* This tells the mock grk_compress to drop some frames */ + grok.licence = "random_drop"; + Config::instance()->set_grok(grok); + + auto content = content_factory(TestPaths::private_data() / "arrietty_JP-EN.mkv"); + auto film = new_test_film("mock_grok_encode_test_with_lost_frames", content); + + make_and_verify_dcp(film); +} + #endif diff --git a/test/mock_grok.cc b/test/mock_grok.cc index 9abc656e2..a89feefa6 100644 --- a/test/mock_grok.cc +++ b/test/mock_grok.cc @@ -123,6 +123,13 @@ int main(int argc, char* argv[]) boost::algorithm::split(parameters, argv[2], boost::is_any_of(",")); std::cout << "Parameters: " << argv[2] << "\n"; + string licence; + if (argc >= 12) { + licence = argv[12]; + } + + std::cout << "Licence: " << licence << "\n"; + if (parameters.size() != 6) { std::cerr << "Unexpected parameter count.\n"; exit(EXIT_FAILURE); @@ -223,7 +230,9 @@ int main(int argc, char* argv[]) int const dcp_frame = dcp::raw_convert<int>(parameters[1]); int const frame_id = dcp::raw_convert<int>(parameters[2]); send(fmt::format("{},{}", GROK_PROCESSED_UNCOMPRESSED, frame_id).c_str()); - send(fmt::format("{},{},{},{}", GROK_SUBMIT_COMPRESSED, dcp_frame, frame_id, j2k.size()).c_str()); + if (licence == "random_drop" && (rand() % 16 != 0)) { + send(fmt::format("{},{},{},{}", GROK_SUBMIT_COMPRESSED, dcp_frame, frame_id, j2k.size()).c_str()); + } } else if (parameters[0] == GROK_SHUTDOWN) { break; } |
