diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gen-resources.py | 44 | ||||
-rw-r--r-- | tests/meson.build | 82 |
2 files changed, 126 insertions, 0 deletions
diff --git a/tests/gen-resources.py b/tests/gen-resources.py new file mode 100644 index 000000000..4c182d9cf --- /dev/null +++ b/tests/gen-resources.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +# Ancillary wrapper around glib-compile-resources that sets up a +# modified environment in order to use the tools that we just +# built instead of the system ones + +import argparse +import os +import subprocess +import sys + +argparser = argparse.ArgumentParser(description='Compile resources') +argparser.add_argument('--pixdata', metavar='PATH', help='Path to gdk-pixbuf-pixdata') +argparser.add_argument('--loaders', metavar='PATH', help='Path to the loaders.cache file') +argparser.add_argument('--sourcedir', metavar='PATH', help='Path to the source directory') +argparser.add_argument('resource', help='GResource XML file') +argparser.add_argument('output', help='Output file') + +group = argparser.add_mutually_exclusive_group() +group.add_argument('--header', help='Generate header file', action='store_true') +group.add_argument('--source', help='Generate source file', action='store_true') + +args = argparser.parse_args() + +cmd = ['glib-compile-resources'] +if args.header: + cmd += ['--generate-header'] +else: + cmd += ['--generate-source'] + +cmd += ['--sourcedir', args.sourcedir] +cmd += [args.resource] +cmd += ['--target', args.output] + +newenv = os.environ.copy() +newenv['GDK_PIXBUF_PIXDATA'] = args.pixdata +newenv['GDK_PIXBUF_MODULE_FILE'] = args.loaders + +out, err = subprocess.Popen(cmd, env=newenv).communicate() +if out is None: + sys.exit(0) +else: + print(out) + sys.exit(1) diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 000000000..91e2f8863 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,82 @@ +# Resources; we cannot use gnome.compile_resources() here, because we need to +# override the environment in order to use the utilities we just built instead +# of the system ones +gen_resources = find_program('gen-resources.py') +resources_c = custom_target('resources.c', + input: 'resources.gresource.xml', + output: 'resources.c', + command: [ + gen_resources, + '--pixdata=@0@'.format(gdk_pixbuf_pixdata.full_path()), + '--loaders=@0@'.format(loaders_cache.full_path()), + '--sourcedir=@0@'.format(meson.current_source_dir()), + '--source', + '@INPUT@', + '@OUTPUT@', + ], + depends: [ + gdk_pixbuf_pixdata, + loaders_cache, + ]) +resources_h = custom_target('resources.h', + input: 'resources.gresource.xml', + output: 'resources.h', + command: [ + gen_resources, + '--pixdata=@0@'.format(gdk_pixbuf_pixdata.full_path()), + '--loaders=@0@'.format(loaders_cache.full_path()), + '--sourcedir=@0@'.format(meson.current_source_dir()), + '--header', + '@INPUT@', + '@OUTPUT@', + ], + depends: [ + gdk_pixbuf_pixdata, + loaders_cache, + ]) + +installed_tests = [ + [ 'animation' ], + [ 'cve-2015-4491', true ], + [ 'pixbuf-fail' ], + [ 'pixbuf-icon-serialize' ], + [ 'pixbuf-randomly-modified' ], + [ 'pixbuf-threads' ], + [ 'pixbuf-icc' ], + [ 'pixbuf-jpeg' ], + [ 'pixbuf-dpi' ], + [ 'pixbuf-pixdata', true ], + [ 'pixbuf-stream' ], + [ 'pixbuf-reftest' ], + [ 'pixbuf-resource', true ], + [ 'pixbuf-scale' ], + [ 'pixbuf-scale-two-step' ], + [ 'pixbuf-short-gif-write' ], + [ 'pixbuf-save' ], + [ 'pixbuf-readonly-to-mutable' ], + [ 'pixbuf-composite' ], + [ 'pixbuf-area-updated' ], +] + +test_deps = gdk_pixbuf_deps + [ gdkpixbuf_dep ] +foreach t: installed_tests + test_name = t[0] + test_sources = [ test_name + '.c', 'test-common.c' ] + needs_resources = t.get(1, false) + if needs_resources + test_sources += [ resources_c, resources_h ] + endif + + test_bin = executable(test_name, test_sources, + dependencies: test_deps, + include_directories: [ root_inc, include_directories('../gdk-pixbuf') ], + c_args: common_cflags) + + test(test_name, test_bin, + args: [ '-k', '--tap' ], + env: [ + 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), + 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), + 'GDK_PIXBUF_MODULE_FILE=@0@'.format(loaders_cache.full_path()), + ]) +endforeach |