0002-tests-add-support-for-install-the-tests.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. From bfb530d2f0761f28c2645e2c45de5147b0528e4d Mon Sep 17 00:00:00 2001
  2. From: Jose Quaresma <quaresma.jose@gmail.com>
  3. Date: Sun, 11 Apr 2021 19:48:13 +0100
  4. Subject: [PATCH] tests: add support for install the tests
  5. This will provide to run the tests using the gnome-desktop-testing [1]
  6. [1] https://wiki.gnome.org/Initiatives/GnomeGoals/InstalledTests
  7. Upstream-Status: Submitted [https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/789]
  8. Signed-off-by: Jose Quaresma <quaresma.jose@gmail.com>
  9. ---
  10. meson.build | 4 ++++
  11. meson_options.txt | 1 +
  12. tests/check/meson.build | 22 +++++++++++++++++++++-
  13. tests/check/template.test.in | 3 +++
  14. 4 files changed, 29 insertions(+), 1 deletion(-)
  15. create mode 100644 tests/check/template.test.in
  16. diff --git a/meson.build b/meson.build
  17. index ba50005..09c7212 100644
  18. --- a/meson.build
  19. +++ b/meson.build
  20. @@ -664,6 +664,10 @@ if bashcomp_dep.found()
  21. endif
  22. endif
  23. +installed_tests_enabled = get_option('installed_tests')
  24. +installed_tests_metadir = join_paths(datadir, 'installed-tests', meson.project_name())
  25. +installed_tests_execdir = join_paths(libexecdir, 'installed-tests', meson.project_name())
  26. +
  27. plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
  28. pkgconfig = import('pkgconfig')
  29. diff --git a/meson_options.txt b/meson_options.txt
  30. index 39255cf..78af552 100644
  31. --- a/meson_options.txt
  32. +++ b/meson_options.txt
  33. @@ -16,6 +16,7 @@ option('poisoning', type : 'boolean', value : false, description : 'Enable poiso
  34. option('memory-alignment', type: 'combo',
  35. choices : ['1', '2', '4', '8', '16', '32', '64', '128', '256', '512', '1024', '2048', '4096', '8192', 'malloc', 'pagesize'],
  36. value: 'malloc')
  37. +option('installed_tests', type : 'boolean', value : false, description : 'Enable installed tests')
  38. # Feature options
  39. option('check', type : 'feature', value : 'auto', description : 'Build unit test libraries')
  40. diff --git a/tests/check/meson.build b/tests/check/meson.build
  41. index 4cc4618..f290e2e 100644
  42. --- a/tests/check/meson.build
  43. +++ b/tests/check/meson.build
  44. @@ -128,10 +128,16 @@ test_defines = [
  45. '-UG_DISABLE_ASSERT',
  46. '-UG_DISABLE_CAST_CHECKS',
  47. '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_STATE_IGNORE_ELEMENTS"',
  48. - '-DTESTFILE="' + fsmod.as_posix(meson.current_source_dir()) + '/meson.build"',
  49. '-DGST_DISABLE_DEPRECATED',
  50. ]
  51. +testfile = meson.current_source_dir() + '/meson.build'
  52. +if installed_tests_enabled
  53. + install_data(testfile, install_dir : installed_tests_metadir, rename : 'testfile')
  54. + testfile = installed_tests_metadir + '/testfile'
  55. +endif
  56. +test_defines += '-DTESTFILE="@0@"'.format(testfile)
  57. +
  58. # sanity checking
  59. if get_option('check').disabled()
  60. if get_option('tests').enabled()
  61. @@ -154,6 +160,8 @@ foreach t : core_tests
  62. include_directories : [configinc],
  63. link_with : link_with_libs,
  64. dependencies : gst_deps + test_deps,
  65. + install_dir: installed_tests_execdir,
  66. + install: installed_tests_enabled,
  67. )
  68. env = environment()
  69. @@ -165,6 +173,18 @@ foreach t : core_tests
  70. env.set('GST_PLUGIN_SCANNER_1_0', gst_scanner_dir + '/gst-plugin-scanner')
  71. env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer')
  72. + if installed_tests_enabled
  73. + test_conf = configuration_data()
  74. + test_conf.set('installed_tests_dir', join_paths(prefix, installed_tests_execdir))
  75. + test_conf.set('program', test_name)
  76. + configure_file(
  77. + input: 'template.test.in',
  78. + output: test_name + '.test',
  79. + install_dir: installed_tests_metadir,
  80. + configuration: test_conf
  81. + )
  82. + endif
  83. +
  84. test(test_name, exe, env: env, timeout : 3 * 60)
  85. endif
  86. endforeach
  87. diff --git a/tests/check/template.test.in b/tests/check/template.test.in
  88. new file mode 100644
  89. index 0000000..f701627
  90. --- /dev/null
  91. +++ b/tests/check/template.test.in
  92. @@ -0,0 +1,3 @@
  93. +[Test]
  94. +Type=session
  95. +Exec=@installed_tests_dir@/@program@