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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
From b843400284751968862751dfe93853f151551c64 Mon Sep 17 00:00:00 2001
From: Carlos Rafael Giani <crg7475@mailbox.org>
Date: Fri, 25 Oct 2019 00:06:26 +0200
Subject: [PATCH] meson: Add option for installed tests
This adds an option for producing installed versions of the unit tests.
These versions don't need meson to run (only a small shell script). This
makes it easier to run cross compiled tests on a target machine.
Upstream-Status: Pending
Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
---
build-aux/gen-installed-test-desc.py | 18 ++++++
build-aux/gen-installed-test-shscript.py | 25 ++++++++
meson_options.txt | 2 +
tests/check/meson.build | 46 +++++++++++++-
tests/files/testfile | 80 ++++++++++++++++++++++++
5 files changed, 170 insertions(+), 1 deletion(-)
create mode 100644 build-aux/gen-installed-test-desc.py
create mode 100644 build-aux/gen-installed-test-shscript.py
create mode 100644 tests/files/testfile
diff --git a/build-aux/gen-installed-test-desc.py b/build-aux/gen-installed-test-desc.py
new file mode 100644
index 0000000..69e8a0f
--- /dev/null
+++ b/build-aux/gen-installed-test-desc.py
@@ -0,0 +1,18 @@
+import sys
+import os
+import argparse
+
+def write_template(filename, data):
+ with open(filename, 'w') as f:
+ f.write(data)
+
+def build_template(testdir, testname):
+ return "[Test]\nType=session\nExec={}\n".format(os.path.join(testdir, testname))
+
+argparser = argparse.ArgumentParser(description='Generate installed-test data.')
+argparser.add_argument('--test-execdir', metavar='dir', required=True, help='Installed test directory')
+argparser.add_argument('--testname', metavar='name', required=True, help='Installed test name')
+argparser.add_argument('--output', metavar='file', required=True, help='Output file')
+args = argparser.parse_args()
+
+write_template(args.output, build_template(args.test_execdir, args.testname))
diff --git a/build-aux/gen-installed-test-shscript.py b/build-aux/gen-installed-test-shscript.py
new file mode 100644
index 0000000..5da86fb
--- /dev/null
+++ b/build-aux/gen-installed-test-shscript.py
@@ -0,0 +1,25 @@
+import sys
+import os
+import argparse
+
+def write_template(filename, data):
+ with open(filename, 'w') as f:
+ f.write(data)
+
+def build_template(testdir, testname):
+ return ''.join([
+ "#!/usr/bin/env sh\n",
+ "export GST_STATE_IGNORE_ELEMENTS=''\n",
+ "export CK_DEFAULT_TIMEOUT=20\n",
+ "export GST_PLUGIN_LOADING_WHITELIST='gstreamer'\n",
+ "{}\n".format(os.path.join(testdir, testname)),
+ ])
+
+argparser = argparse.ArgumentParser(description='Generate installed-test data.')
+argparser.add_argument('--test-execdir', metavar='dir', required=True, help='Installed test directory')
+argparser.add_argument('--testname', metavar='name', required=True, help='Installed test name')
+argparser.add_argument('--output', metavar='file', required=True, help='Output file')
+args = argparser.parse_args()
+
+write_template(args.output, build_template(args.test_execdir, args.testname))
+os.chmod(args.output, 0o755)
diff --git a/meson_options.txt b/meson_options.txt
index 8afde39..8884dcc 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -16,6 +16,8 @@ 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')
+option('test-files-path', type : 'string', description : 'Path where to find test files')
# 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 04da83f..2db7f76 100644
--- a/tests/check/meson.build
+++ b/tests/check/meson.build
@@ -118,11 +118,17 @@ if add_languages('cpp', required : false)
]
endif
+test_files_path = get_option('test-files-path')
+if test_files_path == ''
+ test_files_path = meson.current_source_dir() + '/../files'
+endif
+message('Using path "@0@" as the path to read test files from'.format(test_files_path))
+
test_defines = [
'-UG_DISABLE_ASSERT',
'-UG_DISABLE_CAST_CHECKS',
'-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_STATE_IGNORE_ELEMENTS"',
- '-DTESTFILE="' + meson.current_source_dir() + '/meson.build"',
+ '-DTESTFILE="@0@"'.format(test_files_path + '/testfile'),
'-DGST_USE_UNSTABLE_API',
'-DGST_DISABLE_DEPRECATED',
]
@@ -137,6 +143,14 @@ endif
glib_deps = [gio_dep, gobject_dep, gmodule_dep, glib_dep]
gst_deps = [gst_dep, gst_base_dep, gst_check_dep, gst_net_dep, gst_controller_dep]
+installed_tests_datadir = join_paths(prefix, get_option('datadir'), 'installed-tests', 'gstreamer-1.0')
+installed_tests_execdir = join_paths(prefix, libexecdir, 'installed-tests', 'gstreamer-1.0')
+installed_tests_enabled = get_option('installed-tests')
+
+python = import('python').find_installation()
+gen_installed_test_desc = files('../../build-aux/gen-installed-test-desc.py')
+gen_installed_test_shscript = files('../../build-aux/gen-installed-test-shscript.py')
+
foreach t : core_tests
fname = t[0]
test_name = fname.split('.')[0].underscorify()
@@ -150,8 +164,38 @@ foreach t : core_tests
include_directories : [configinc],
link_with : link_with_libs,
dependencies : test_deps + glib_deps + gst_deps,
+ install_dir: installed_tests_execdir,
+ install: installed_tests_enabled
)
+ if installed_tests_enabled
+ installed_test_shscript = test_name + '.sh'
+ shscript = custom_target (test_name + '_shscript',
+ output: installed_test_shscript,
+ command: [
+ python,
+ gen_installed_test_shscript,
+ '--test-execdir=@0@'.format(installed_tests_execdir),
+ '--testname=@0@'.format(test_name),
+ '--output=@0@'.format(join_paths('@OUTDIR@', installed_test_shscript)),
+ ],
+ install: true,
+ install_dir: installed_tests_execdir)
+
+ installed_test_desc = test_name + '.test'
+ data = custom_target(test_name + '_desc',
+ output: installed_test_desc,
+ command: [
+ python,
+ gen_installed_test_desc,
+ '--test-execdir=@0@'.format(installed_tests_execdir),
+ '--testname=@0@'.format(installed_test_shscript),
+ '--output=@0@'.format(join_paths('@OUTDIR@', installed_test_desc)),
+ ],
+ install: true,
+ install_dir: installed_tests_datadir)
+ endif
+
env = environment()
env.set('GST_PLUGIN_PATH_1_0', meson.build_root())
env.set('GST_PLUGIN_SYSTEM_PATH_1_0', '')
diff --git a/tests/files/testfile b/tests/files/testfile
new file mode 100644
index 0000000..89954e0
--- /dev/null
+++ b/tests/files/testfile
@@ -0,0 +1,80 @@
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
+................................................................................
--
2.17.1
|