summaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia/gstreamer/gstreamer1.0/0002-tests-add-support-for-install-the-tests.patch
blob: a990940cc6800159397663f8c904c8e684d881b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
From 31dea17a1d5de0003719a875a1089df43a50219a Mon Sep 17 00:00:00 2001
From: Jose Quaresma <quaresma.jose@gmail.com>
Date: Sun, 11 Apr 2021 19:48:13 +0100
Subject: [PATCH] tests: add support for install the tests

This will provide to run the tests using the gnome-desktop-testing [1]

[1] https://wiki.gnome.org/Initiatives/GnomeGoals/InstalledTests

Upstream-Status: Submitted [https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/789]

Signed-off-by: Jose Quaresma <quaresma.jose@gmail.com>
---
 meson.build                  |  4 ++++
 meson_options.txt            |  1 +
 tests/check/meson.build      | 22 +++++++++++++++++++++-
 tests/check/template.test.in |  3 +++
 4 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 tests/check/template.test.in

diff --git a/meson.build b/meson.build
index efcf189..c97d9a8 100644
--- a/meson.build
+++ b/meson.build
@@ -624,6 +624,10 @@ if bashcomp_dep.found()
   endif
 endif
 
+installed_tests_enabled = get_option('installed_tests')
+installed_tests_metadir = join_paths(datadir, 'installed-tests', meson.project_name())
+installed_tests_execdir = join_paths(libexecdir, 'installed-tests', meson.project_name())
+
 plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
 
 pkgconfig = import('pkgconfig')
diff --git a/meson_options.txt b/meson_options.txt
index 340fb58..5b87f68 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -16,6 +16,7 @@ option('poisoning', type : 'boolean', value : false, description : 'Enable poiso
 option('memory-alignment', type: 'combo',
        choices : ['1', '2', '4', '8', '16', '32', '64', '128', '256', '512', '1024', '2048', '4096', '8192', 'malloc', 'pagesize'],
        value: 'malloc')
+option('installed_tests', type : 'boolean', value : false, description : 'Enable installed tests')
 
 # Feature options
 option('check', type : 'feature', value : 'auto', description : 'Build unit test libraries')
diff --git a/tests/check/meson.build b/tests/check/meson.build
index e9501fe..08f8fd8 100644
--- a/tests/check/meson.build
+++ b/tests/check/meson.build
@@ -125,10 +125,16 @@ test_defines = [
   '-UG_DISABLE_ASSERT',
   '-UG_DISABLE_CAST_CHECKS',
   '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_STATE_IGNORE_ELEMENTS"',
-  '-DTESTFILE="' + fsmod.as_posix(meson.current_source_dir()) + '/meson.build"',
   '-DGST_DISABLE_DEPRECATED',
 ]
 
+testfile = meson.current_source_dir() + '/meson.build'
+if installed_tests_enabled
+  install_data(testfile, install_dir : installed_tests_metadir, rename : 'testfile')
+  testfile = installed_tests_metadir + '/testfile'
+endif
+test_defines += '-DTESTFILE="@0@"'.format(testfile)
+
 # sanity checking
 if get_option('check').disabled()
   if get_option('tests').enabled()
@@ -151,6 +157,8 @@ foreach t : core_tests
       include_directories : [configinc],
       link_with : link_with_libs,
       dependencies : gst_deps + test_deps,
+      install_dir: installed_tests_execdir,
+      install: installed_tests_enabled,
     )
 
     env = environment()
@@ -162,6 +170,18 @@ foreach t : core_tests
     env.set('GST_PLUGIN_SCANNER_1_0', gst_scanner_dir + '/gst-plugin-scanner')
     env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer')
 
+    if installed_tests_enabled
+      test_conf = configuration_data()
+      test_conf.set('installed_tests_dir', join_paths(prefix, installed_tests_execdir))
+      test_conf.set('program', test_name)
+      configure_file(
+        input: 'template.test.in',
+        output: test_name + '.test',
+        install_dir: installed_tests_metadir,
+        configuration: test_conf
+      )
+    endif
+
     test(test_name, exe, env: env, timeout : 3 * 60)
   endif
 endforeach
diff --git a/tests/check/template.test.in b/tests/check/template.test.in
new file mode 100644
index 0000000..f701627
--- /dev/null
+++ b/tests/check/template.test.in
@@ -0,0 +1,3 @@
+[Test]
+Type=session
+Exec=@installed_tests_dir@/@program@