diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-10-12 22:08:01 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-10-12 22:08:01 +0100 |
| commit | 1e517fcc4eb35f09b7f02f6843be361a62d20ed9 (patch) | |
| tree | 0042849dd123257cf1e96476acfa180f9abed8a2 /test | |
| parent | 45d19dde4861fe9a729ba90ab1d8c486ab956529 (diff) | |
Use ImageMagick for test stuff.
Diffstat (limited to 'test')
| -rw-r--r-- | test/test.cc | 18 | ||||
| -rw-r--r-- | test/wscript | 4 |
2 files changed, 19 insertions, 3 deletions
diff --git a/test/test.cc b/test/test.cc index a3235eb62..c87f4e70b 100644 --- a/test/test.cc +++ b/test/test.cc @@ -46,6 +46,7 @@ #include <asdcp/AS_DCP.h> #include <sndfile.h> #include <libxml++/libxml++.h> +#include <Magick++.h> extern "C" { #include <libavformat/avformat.h> } @@ -232,7 +233,17 @@ check_mxf_audio_file (boost::filesystem::path ref, boost::filesystem::path check void check_image (boost::filesystem::path ref, boost::filesystem::path check, double threshold) { - /* XXX */ + using namespace MagickCore; + + Magick::Image ref_image; + ref_image.read (ref.string ()); + Magick::Image check_image; + check_image.read (check.string ()); + /* XXX: this is a hack; we really want the ImageMagick call but GraphicsMagick doesn't have it; + this may cause random test failures on platforms that use GraphicsMagick. + */ + double const dist = ref_image.compare(check_image, Magick::RootMeanSquaredErrorMetric); + BOOST_CHECK_MESSAGE (dist < threshold, ref << " differs from " << check << " " << dist); } void @@ -408,7 +419,10 @@ wait_for_jobs () void write_image (shared_ptr<const Image> image, boost::filesystem::path file, string format) { - /* XXX */ + using namespace MagickCore; + + Magick::Image m (image->size().width, image->size().height, format.c_str(), CharPixel, (void *) image->data()[0]); + m.write (file.string ()); } void diff --git a/test/wscript b/test/wscript index cfa718307..8ef281dd7 100644 --- a/test/wscript +++ b/test/wscript @@ -30,11 +30,13 @@ def configure(conf): int main() {} """, msg = 'Checking for boost unit testing library', lib = 'boost_unit_test_framework%s' % boost_test_suffix, uselib_store = 'BOOST_TEST') + conf.check_cfg(package='ImageMagick++', args='--cflags --libs', uselib_store='MAGICK', mandatory=True) + def build(bld): 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 ' - obj.uselib += 'AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE SWRESAMPLE POSTPROC CXML SUB GLIB CURL SSH XMLSEC BOOST_REGEX ICU NETTLE ' + obj.uselib += 'AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE SWRESAMPLE POSTPROC CXML SUB GLIB CURL SSH XMLSEC BOOST_REGEX ICU NETTLE MAGICK ' if bld.env.TARGET_WINDOWS: obj.uselib += 'WINSOCK2 DBGHELP SHLWAPI MSWSOCK BOOST_LOCALE ' obj.use = 'libdcpomatic2' |
