tests: Use native GTest utils to generate assets names

This commit is contained in:
Marco Trevisan (Treviño)
2023-08-17 21:17:26 +02:00
committed by Marco Trevisan
parent 135a015b6a
commit 1372d6f081
2 changed files with 10 additions and 8 deletions

View File

@@ -6,6 +6,8 @@ envs.set('G_MESSAGES_DEBUG', 'all')
# Setup paths # Setup paths
envs.set('MESON_SOURCE_ROOT', meson.project_source_root()) envs.set('MESON_SOURCE_ROOT', meson.project_source_root())
envs.set('MESON_BUILD_ROOT', meson.project_build_root()) envs.set('MESON_BUILD_ROOT', meson.project_build_root())
envs.set('G_TEST_SRCDIR', meson.current_source_dir())
envs.set('G_TEST_BUILDDIR', meson.current_build_dir())
envs.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libfprint') envs.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libfprint')
# Set FP_DEVICE_EMULATION so that drivers can adapt (e.g. to use fixed # Set FP_DEVICE_EMULATION so that drivers can adapt (e.g. to use fixed
@@ -71,6 +73,12 @@ envs_str = run_command(python3, '-c', env_parser_cmd,
env: envs, env: envs,
check: installed_tests).stdout().strip() check: installed_tests).stdout().strip()
envs_str = ' '.join([
envs_str,
'G_TEST_SRCDIR=' + installed_tests_testdir,
'G_TEST_BUILDDIR=' + installed_tests_execdir,
])
if get_option('introspection') if get_option('introspection')
envs.prepend('GI_TYPELIB_PATH', meson.project_build_root() / 'libfprint') envs.prepend('GI_TYPELIB_PATH', meson.project_build_root() / 'libfprint')
virtual_devices_tests = [ virtual_devices_tests = [
@@ -247,10 +255,6 @@ endif
unit_tests_deps = { 'fpi-assembling' : [cairo_dep] } unit_tests_deps = { 'fpi-assembling' : [cairo_dep] }
test_config = configuration_data()
test_config.set_quoted('SOURCE_ROOT', meson.project_source_root())
test_config_h = configure_file(output: 'test-config.h', configuration: test_config)
foreach test_name: unit_tests foreach test_name: unit_tests
if unit_tests_deps.has_key(test_name) if unit_tests_deps.has_key(test_name)
missing_deps = false missing_deps = false
@@ -278,7 +282,7 @@ foreach test_name: unit_tests
basename = 'test-' + test_name basename = 'test-' + test_name
test_exe = executable(basename, test_exe = executable(basename,
sources: [basename + '.c', test_config_h], sources: basename + '.c',
dependencies: [ libfprint_private_dep ] + extra_deps, dependencies: [ libfprint_private_dep ] + extra_deps,
c_args: common_cflags, c_args: common_cflags,
link_whole: test_utils, link_whole: test_utils,

View File

@@ -22,7 +22,6 @@
#include <cairo.h> #include <cairo.h>
#include "fpi-assembling.h" #include "fpi-assembling.h"
#include "fpi-image.h" #include "fpi-image.h"
#include "test-config.h"
typedef struct typedef struct
{ {
@@ -67,8 +66,7 @@ test_frame_assembling (void)
g_autoptr(FpImage) fp_img = NULL; g_autoptr(FpImage) fp_img = NULL;
GSList *frames = NULL; GSList *frames = NULL;
g_assert_false (SOURCE_ROOT == NULL); path = g_test_build_filename (G_TEST_DIST, "vfs5011", "capture.png", NULL);
path = g_build_path (G_DIR_SEPARATOR_S, SOURCE_ROOT, "tests", "vfs5011", "capture.png", NULL);
img = cairo_image_surface_create_from_png (path); img = cairo_image_surface_create_from_png (path);
data = cairo_image_surface_get_data (img); data = cairo_image_surface_get_data (img);