blob: 568e38cbf1c28dfefe1246792f6fbea6bf4625e8 [file] [log] [blame]
Andrew Geissler6aa7eec2023-03-03 12:41:14 -06001From 08b1aaff972a7f6349373fc1ad4cc23081adb52c Mon Sep 17 00:00:00 2001
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00002From: Jose Quaresma <quaresma.jose@gmail.com>
3Date: Sun, 11 Apr 2021 19:48:13 +0100
Andrew Geissler6aa7eec2023-03-03 12:41:14 -06004Subject: [PATCH] tests: add support for install the tests
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00005
6This will provide to run the tests using the gnome-desktop-testing [1]
7
8[1] https://wiki.gnome.org/Initiatives/GnomeGoals/InstalledTests
9
10Upstream-Status: Submitted [https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/789]
11
12Signed-off-by: Jose Quaresma <quaresma.jose@gmail.com>
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000013
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060014---
15 meson.build | 4 ++++
16 meson_options.txt | 1 +
17 tests/check/meson.build | 22 +++++++++++++++++++++-
18 tests/check/template.test.in | 3 +++
19 4 files changed, 29 insertions(+), 1 deletion(-)
20 create mode 100644 tests/check/template.test.in
21
22diff --git a/meson.build b/meson.build
23index f9f591d..3906fb3 100644
24--- a/meson.build
25+++ b/meson.build
26@@ -606,6 +606,10 @@ if bashcomp_dep.found()
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000027 endif
28 endif
29
30+installed_tests_enabled = get_option('installed_tests')
31+installed_tests_metadir = join_paths(datadir, 'installed-tests', meson.project_name())
32+installed_tests_execdir = join_paths(libexecdir, 'installed-tests', meson.project_name())
33+
34 plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
35
36 pkgconfig = import('pkgconfig')
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060037diff --git a/meson_options.txt b/meson_options.txt
38index 7363bdb..a34ba37 100644
39--- a/meson_options.txt
40+++ b/meson_options.txt
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000041@@ -15,6 +15,7 @@ option('poisoning', type : 'boolean', value : false, description : 'Enable poiso
42 option('memory-alignment', type: 'combo',
43 choices : ['1', '2', '4', '8', '16', '32', '64', '128', '256', '512', '1024', '2048', '4096', '8192', 'malloc', 'pagesize'],
44 value: 'malloc')
45+option('installed_tests', type : 'boolean', value : false, description : 'Enable installed tests')
46
47 # Feature options
48 option('check', type : 'feature', value : 'auto', description : 'Build unit test libraries')
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060049diff --git a/tests/check/meson.build b/tests/check/meson.build
50index 16caac7..f2d400f 100644
51--- a/tests/check/meson.build
52+++ b/tests/check/meson.build
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000053@@ -124,10 +124,16 @@ test_defines = [
54 '-UG_DISABLE_ASSERT',
55 '-UG_DISABLE_CAST_CHECKS',
56 '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_STATE_IGNORE_ELEMENTS"',
57- '-DTESTFILE="' + meson.current_source_dir() + '/meson.build"',
58 '-DGST_DISABLE_DEPRECATED',
59 ]
60
61+testfile = meson.current_source_dir() + '/meson.build'
62+if installed_tests_enabled
63+ install_data(testfile, install_dir : installed_tests_metadir, rename : 'testfile')
64+ testfile = installed_tests_metadir + '/testfile'
65+endif
66+test_defines += '-DTESTFILE="@0@"'.format(testfile)
67+
68 # sanity checking
69 if get_option('check').disabled()
70 if get_option('tests').enabled()
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060071@@ -150,6 +156,8 @@ foreach t : core_tests
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000072 include_directories : [configinc],
73 link_with : link_with_libs,
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060074 dependencies : gst_deps + test_deps,
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000075+ install_dir: installed_tests_execdir,
76+ install: installed_tests_enabled,
77 )
78
79 env = environment()
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060080@@ -161,6 +169,18 @@ foreach t : core_tests
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000081 env.set('GST_PLUGIN_SCANNER_1_0', gst_scanner_dir + '/gst-plugin-scanner')
82 env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer')
83
84+ if installed_tests_enabled
85+ test_conf = configuration_data()
86+ test_conf.set('installed_tests_dir', join_paths(prefix, installed_tests_execdir))
87+ test_conf.set('program', test_name)
88+ configure_file(
89+ input: 'template.test.in',
90+ output: test_name + '.test',
91+ install_dir: installed_tests_metadir,
92+ configuration: test_conf
93+ )
94+ endif
95+
96 test(test_name, exe, env: env, timeout : 3 * 60)
97 endif
98 endforeach
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060099diff --git a/tests/check/template.test.in b/tests/check/template.test.in
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000100new file mode 100644
Andrew Geissler6aa7eec2023-03-03 12:41:14 -0600101index 0000000..f701627
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000102--- /dev/null
Andrew Geissler6aa7eec2023-03-03 12:41:14 -0600103+++ b/tests/check/template.test.in
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000104@@ -0,0 +1,3 @@
105+[Test]
106+Type=session
107+Exec=@installed_tests_dir@/@program@