From fda30e227e2fe874f9350f6165eaa5b178ba791c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 29 May 2025 23:53:11 +0200 Subject: Basic grok test using mockgrok. --- test/grok_test.cc | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/grok_util_test.cc | 43 -------------------------------- test/wscript | 14 +++++------ 3 files changed, 73 insertions(+), 50 deletions(-) create mode 100644 test/grok_test.cc delete mode 100644 test/grok_util_test.cc diff --git a/test/grok_test.cc b/test/grok_test.cc new file mode 100644 index 000000000..9ad7854f3 --- /dev/null +++ b/test/grok_test.cc @@ -0,0 +1,66 @@ +/* + Copyright (C) 2025 Carl Hetherington + + 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 . + +*/ + + +#include "lib/config.h" +#include "lib/content_factory.h" +#ifdef DCPOMATIC_GROK +#include "lib/grok/context.h" +#include "lib/grok/util.h" +#endif +#include "test.h" +#include + + +#ifdef DCPOMATIC_GROK +BOOST_AUTO_TEST_CASE(get_gpu_names_test) +{ + ConfigRestorer cr; + + Config::Grok grok; + grok.binary_location = "test"; + Config::instance()->set_grok(grok); + + auto names = get_gpu_names(); + BOOST_REQUIRE_EQUAL(names.size(), 3U); + BOOST_CHECK_EQUAL(names[0], "Foo bar baz"); + BOOST_CHECK_EQUAL(names[1], "Spondoolix Mega Kompute 2000"); + BOOST_CHECK_EQUAL(names[2], "Energy Sink-o-matic"); +} + + +BOOST_AUTO_TEST_CASE(mock_grok_encode_test) +{ + ConfigRestorer cr; + + grk_plugin::setMessengerLogger(new grk_plugin::GrokLogger("[GROK] ")); + + auto grok = Config::instance()->grok(); + grok.enable = true; + grok.binary_location = "build/test"; + 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", content); + + make_and_verify_dcp(film); +} + +#endif diff --git a/test/grok_util_test.cc b/test/grok_util_test.cc deleted file mode 100644 index 2a84fe2a4..000000000 --- a/test/grok_util_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2025 Carl Hetherington - - 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 . - -*/ - - -#include "lib/config.h" -#include "lib/grok/util.h" -#include "test.h" -#include - - -#ifdef DCPOMATIC_GROK -BOOST_AUTO_TEST_CASE(get_gpu_names_test) -{ - ConfigRestorer cr; - - Config::Grok grok; - grok.binary_location = "test"; - Config::instance()->set_grok(grok); - - auto names = get_gpu_names(); - BOOST_REQUIRE_EQUAL(names.size(), 3U); - BOOST_CHECK_EQUAL(names[0], "Foo bar baz"); - BOOST_CHECK_EQUAL(names[1], "Spondoolix Mega Kompute 2000"); - BOOST_CHECK_EQUAL(names[2], "Energy Sink-o-matic"); -} -#endif diff --git a/test/wscript b/test/wscript index 7c7568cdb..f7b93ccf1 100644 --- a/test/wscript +++ b/test/wscript @@ -33,6 +33,12 @@ def configure(conf): """, msg = 'Checking for boost unit testing library', lib = 'boost_unit_test_framework%s' % boost_test_suffix, uselib_store = 'BOOST_TEST') def build(bld): + obj = bld(features='cxx cxxprogram') + obj.name = 'mockgrok' + obj.source = 'mock_grok.cc' + obj.target = 'grk_compress' + obj.uselib = 'DCP' + obj = bld(features='cxx cxxprogram') obj.name = 'unit-tests' obj.uselib = 'BOOST_TEST BOOST_THREAD BOOST_FILESYSTEM BOOST_DATETIME SNDFILE SAMPLERATE DCP FONTCONFIG CAIROMM PANGOMM XMLPP ' @@ -112,7 +118,7 @@ def build(bld): font_id_allocator_test.cc frame_interval_checker_test.cc frame_rate_test.cc - grok_util_test.cc + grok_test.cc guess_crop_test.cc hints_test.cc image_content_fade_test.cc @@ -206,9 +212,3 @@ def build(bld): obj.target = 'unit-tests' obj.install_path = '' - - obj = bld(features='cxx cxxprogram') - obj.name = 'mockgrok' - obj.source = 'mock_grok.cc' - obj.target = 'grk_compress' - obj.uselib = 'DCP' -- cgit v1.2.3