blob: b77fb5797fb2ede14c016f466bc0b813fbea7ba1 [file] [log] [blame]
Andrew Geisslerc926e172021-05-07 16:11:35 -05001From c9e93c7a3e4d2773abef4f5e1464af24f36700b3 Mon Sep 17 00:00:00 2001
2From: Jose Quaresma <quaresma.jose@gmail.com>
3Date: Sun, 11 Apr 2021 19:48:13 +0100
4Subject: [PATCH 2/4] tests: add support for install the tests
5
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>
13---
14 meson.build | 5 +++++
15 meson_options.txt | 1 +
16 template.test.in | 3 +++
17 tests/check/meson.build | 22 +++++++++++++++++++++-
18 4 files changed, 30 insertions(+), 1 deletion(-)
19 create mode 100644 template.test.in
20
21diff --git a/meson.build b/meson.build
22index c4e8774f5..1abf4eb26 100644
23--- a/meson.build
24+++ b/meson.build
25@@ -562,6 +562,11 @@ if bashcomp_dep.found()
26 endif
27 endif
28
29+installed_tests_metadir = join_paths(datadir, 'installed-tests', meson.project_name())
30+installed_tests_execdir = join_paths(libexecdir, 'installed-tests', meson.project_name())
31+installed_tests_enabled = get_option('installed-tests')
32+installed_tests_template = files('template.test.in')
33+
34 plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
35
36 pkgconfig = import('pkgconfig')
37diff --git a/meson_options.txt b/meson_options.txt
38index c8cee3762..b5da40eaa 100644
39--- a/meson_options.txt
40+++ b/meson_options.txt
41@@ -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')
49diff --git a/template.test.in b/template.test.in
50new file mode 100644
51index 000000000..f701627f8
52--- /dev/null
53+++ b/template.test.in
54@@ -0,0 +1,3 @@
55+[Test]
56+Type=session
57+Exec=@installed_tests_dir@/@program@
58diff --git a/tests/check/meson.build b/tests/check/meson.build
59index b2636714b..a697a7b06 100644
60--- a/tests/check/meson.build
61+++ b/tests/check/meson.build
62@@ -124,10 +124,16 @@ test_defines = [
63 '-UG_DISABLE_ASSERT',
64 '-UG_DISABLE_CAST_CHECKS',
65 '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_STATE_IGNORE_ELEMENTS"',
66- '-DTESTFILE="' + meson.current_source_dir() + '/meson.build"',
67 '-DGST_DISABLE_DEPRECATED',
68 ]
69
70+testfile = meson.current_source_dir() + '/meson.build'
71+if installed_tests_enabled
72+ install_data(testfile, install_dir : installed_tests_metadir, rename : 'testfile')
73+ testfile = installed_tests_metadir + '/testfile'
74+endif
75+test_defines += '-DTESTFILE="@0@"'.format(testfile)
76+
77 # sanity checking
78 if get_option('check').disabled()
79 if get_option('tests').enabled()
80@@ -151,6 +157,8 @@ foreach t : core_tests
81 include_directories : [configinc],
82 link_with : link_with_libs,
83 dependencies : test_deps + glib_deps + gst_deps,
84+ install_dir: installed_tests_execdir,
85+ install: installed_tests_enabled,
86 )
87
88 env = environment()
89@@ -162,6 +170,18 @@ foreach t : core_tests
90 env.set('GST_PLUGIN_SCANNER_1_0', gst_scanner_dir + '/gst-plugin-scanner')
91 env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer')
92
93+ if installed_tests_enabled
94+ test_conf = configuration_data()
95+ test_conf.set('installed_tests_dir', join_paths(prefix, installed_tests_execdir))
96+ test_conf.set('program', test_name)
97+ configure_file(
98+ input: installed_tests_template,
99+ output: test_name + '.test',
100+ install_dir: installed_tests_metadir,
101+ configuration: test_conf
102+ )
103+ endif
104+
105 test(test_name, exe, env: env, timeout : 3 * 60)
106 endif
107 endforeach
108--
1092.31.1
110