[vlc-commits] [Git][videolan/vlc][master] 12 commits: test: Makefile.am: move defines to CPPFLAGS

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Aug 3 08:22:47 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
d5dac699 by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
test: Makefile.am: move defines to CPPFLAGS

There is no need to pass those defines at link time, which is what
CFLAGS will do.

- - - - -
dffc018f by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
test: Makefile.am: define TOP_BUILDDIR in CPPFLAGS

TOP_BUILDDIR is used in particular to setup VLC_PLUGIN_PATH in a static
way.

- - - - -
dde449ee by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
bin: Makefile.am: use abs_top_* variables directly

There's no need for an ad-hoc realpath call since autotools already
provides the absolute path for those variables.

- - - - -
78a60986 by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
test: Makefile.am: export builddir/srcdir variables

Export the variables in the CPPFLAGS directly instead of declaring them
each time for the different targets.

- - - - -
8ab6572b by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
test: test.h: define VLC_PLUGIN_PATH reliably

Define VLC_PLUGIN_PATH from TOP_BUILDDIR so that it doesn't depend upon
from where the test is run, in particular so that it also works when
running with meson.

- - - - -
6ce022cf by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
test: meson.build: add test infrastructure

Test can be declared by adding dictionaries to the vlc_tests variable,
the same way plugins can be added by adding dicitonaries to the
vlc_modules variable. For instance:

    vlc_tests += {
        'name' : 'test_foo',
        'sources' : files(...),
    }

- - - - -
653cec76 by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
test/libvlc: meson.build: add basic tests for libvlc

Add the tests that are not depending on some libvlc plugins, ie. those
that can be run immediately with `meson test` without compiling the
sources first. It makes use of the test infrastructure from the previous
commits.

The test libvlc_media_list_player is commented out like in Makefile.am
since the future refactor of the libvlc API will re-enable it.

- - - - -
02f9428d by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
demux: meson.build: add mock:// plugin

The module is specifically used in some tests and needs to be present
for them.

- - - - -
b749d93b by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
modules: meson.build: name plugins targets

Ensure plugins targets can be referenced by naming them through the
`vlc_plugins_targets` dictionary. They can be used directly through

    vlc_plugins_targets['module_name']

where `module_name` is the 'name' field added in the `vlc_modules` dict.

In particular, tests can reference those targets to ensure the plugin is
built when running it. To do so, the current only way to achieve this is
to declare a dependency on the library as if it was linked, and then
get a partial dependency to remove the library from the link. For
instance:

    declare_dependency(link_with: vlc_plugins_targets['demux_mock'])
        .partial_dependency()

- - - - -
77053716 by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
test: meson.build: add module_depends to tests

Add a field in tests to ensure they are built after the plugins that
needs them. It references the name and not the target directly to ease
its definition, and can also serve different purpose like potentially
linking the plugins directly in the future depending on the build
environment.

When a dependency to an inexistant module is added, the following error
will be triggered:

    ../test/meson.build:39:12: ERROR: Problem encountered: Test entry
    'test_libvlc_media_player' cannot depend on inexistant VLC plugin
    'nonexistantmodule'

- - - - -
3c01c331 by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
test/libvlc: meson.build: add missing tests with deps

Add the tests that were missing from Makefile.am to meson.build, now
that we can define their dependencies.

Tests like test_libvlc_core and test_libvlc_media are depending on the
full list of plugins so that they are run after the plugins they use are
actually built. This list could be reduced in the future but since they
depend on platform plugins or a huge list of different plugins, it's
easier to test them right now after everything is built.

- - - - -
63d0d80c by Alexandre Janniaux at 2023-08-03T08:01:09+00:00
test: meson.build: add testsuite parameter

Add the `suite` parameter to signal tests in different testsuites.
The libvlc tests are assigned to `libvlc` but every tests from the
test/ folder will also be assigned to the `test` suite.

- - - - -


8 changed files:

- bin/Makefile.am
- meson.build
- modules/demux/meson.build
- modules/meson.build
- test/Makefile.am
- + test/libvlc/meson.build
- test/libvlc/test.h
- + test/meson.build


Changes:

=====================================
bin/Makefile.am
=====================================
@@ -57,8 +57,8 @@ vlc_osx_LDADD = ../lib/libvlc.la
 
 vlc_osx_static_SOURCES = $(vlc_osx_SOURCES)
 vlc_osx_static_OBJCFLAGS = $(AM_OBJCFLAGS) \
-	-DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\" \
-	-DTOP_SRCDIR=\"$$(cd "$(top_srcdir)"; pwd)\" \
+	-DTOP_BUILDDIR=\"$(abs_top_builddir)\" \
+	-DTOP_SRCDIR=\"$(abs_top_srcdir)\" \
 	$(NULL)
 vlc_osx_static_LDFLAGS = $(vlc_osx_LDFLAGS) -static
 vlc_osx_static_LDFLAGS += -Xlinker -rpath -Xlinker "@executable_path/../lib/.libs/"
@@ -77,8 +77,8 @@ endif
 #
 vlc_static_SOURCES = $(vlc_SOURCES)
 vlc_static_CFLAGS = $(AM_CFLAGS) \
-	-DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\" \
-	-DTOP_SRCDIR=\"$$(cd "$(top_srcdir)"; pwd)\" \
+	-DTOP_BUILDDIR=\"$(abs_top_builddir)\" \
+	-DTOP_SRCDIR=\"$(abs_top_srcdir)\" \
 	$(NULL)
 vlc_static_CPPFLAGS = $(vlc_CPPFLAGS)
 vlc_static_DEPENDENCIES = $(vlc_DEPENDENCIES)


=====================================
meson.build
=====================================
@@ -1027,6 +1027,10 @@ subdir('bin')
 # VLC plugins
 subdir('modules')
 
+# Integration and non-regression tests, some unittest are there too but the
+# modules/, src/ and lib/ folders should be favoured for those.
+subdir('test')
+
 if get_option('rust').allowed()
     warning('''
     The Rust module support is currently EXPERIMENTAL and INCOMPLETE.


=====================================
modules/demux/meson.build
=====================================
@@ -298,6 +298,11 @@ vlc_modules += {
     'dependencies' : [m_lib, z_dep]
 }
 
+# mock demux
+vlc_modules += {
+    'name' : 'demux_mock',
+    'sources' : files('mock.c')
+}
 
 # mpgv demux
 vlc_modules += {


=====================================
modules/meson.build
=====================================
@@ -256,6 +256,7 @@ endif
 # array is then iterated over and a library is defined for each
 # entry with the needed build definition for a VLC plugin.
 #
+vlc_plugins_targets = {}
 foreach module : vlc_modules
     if not module.has_key('name')
         error('Got invalid vlc_modules entry without \'name\' key')
@@ -290,7 +291,8 @@ foreach module : vlc_modules
         '-DVLC_DYNAMIC_PLUGIN'
     ]
 
-    library(module['name'] + '_plugin',
+    vlc_plugin = library(
+        module['name'] + '_plugin',
         module['sources'],
         link_with: [module.get('link_with', []), vlc_libcompat],
         link_args: module.get('link_args', []),
@@ -305,4 +307,7 @@ foreach module : vlc_modules
         install: true,
         install_dir: get_option('libdir') / 'vlc/plugins'
     )
+    vlc_plugins_targets += {
+        module['name']: vlc_plugin
+    }
 endforeach


=====================================
test/Makefile.am
=====================================
@@ -100,7 +100,10 @@ check_HEADERS = libvlc/test.h libvlc/libvlc_additions.h libvlc/media_utils.h \
 
 TESTS = $(check_PROGRAMS) check_POTFILES.sh
 
-AM_CFLAGS = -DSRCDIR=\"$(srcdir)\"
+AM_CPPFLAGS = \
+	-DSRCDIR=\"$(srcdir)\" \
+	-DTOP_BUILDDIR=\"$(abs_top_builddir)\" \
+	-DTOP_SRCDIR=\"$(abs_top_srcdir)\"
 AM_LDFLAGS = -no-install $(LDFLAGS_vlc)
 LIBVLCCORE = -L../src/ -lvlccore
 LIBVLC = -L../lib -lvlc
@@ -258,9 +261,7 @@ FORCE:
 
 libvlc_demux_run_la_SOURCES = src/input/demux-run.c src/input/demux-run.h \
 	src/input/common.c src/input/common.h
-libvlc_demux_run_la_CPPFLAGS = $(AM_CPPFLAGS) \
-	-DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\" \
-	-DTOP_SRCDIR=\"$$(cd "$(top_srcdir)"; pwd)\"
+libvlc_demux_run_la_CPPFLAGS = $(AM_CPPFLAGS)
 libvlc_demux_run_la_LDFLAGS = -no-install -static
 libvlc_demux_run_la_LIBADD = \
 	../lib/libvlc.la ../src/libvlccore.la ../compat/libcompat.la
@@ -388,9 +389,7 @@ noinst_PROGRAMS += vlccoreios
 endif
 
 vlc_window_SOURCES = vlc-window.c
-vlc_window_CPPFLAGS = $(AM_CPPFLAGS) -I../include/ \
-	-DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\" \
-	-DTOP_SRCDIR=\"$$(cd "$(top_srcdir)"; pwd)\"
+vlc_window_CPPFLAGS = $(AM_CPPFLAGS) -I../include/
 vlc_window_LDADD = ../lib/libvlc.la ../src/libvlccore.la ../compat/libcompat.la
 # Opt-out for building the test driver if there is no dynamic plugins, since we
 # cannot link static plugins currently anyway.


=====================================
test/libvlc/meson.build
=====================================
@@ -0,0 +1,80 @@
+vlc_tests += {
+    'name' : 'test_libvlc_core',
+    'sources' : files('core.c'),
+    'suite' : ['libvlc'],
+    'link_with' : [libvlc],
+    'module_depends' : vlc_plugins_targets.keys()
+}
+
+vlc_tests += {
+    'name' : 'test_libvlc_equalizer',
+    'sources' : files('equalizer.c'),
+    'suite' : ['libvlc'],
+    'link_with' : [libvlc]
+}
+
+vlc_tests += {
+    'name' : 'test_libvlc_media',
+    'sources' : files('media.c'),
+    'link_with' : [libvlc, libvlccore],
+    'module_depends': vlc_plugins_targets.keys()
+}
+
+# vlc_tests += {
+#     'name' : 'test_libvlc_media_list_player',
+#     'sources' : files('libvlc/media_list_player.c'),
+#     'link_with' : [libvlc]
+# }
+
+vlc_tests += {
+    'name' : 'test_libvlc_media_list',
+    'sources' : files('media_list.c'),
+    'suite' : ['libvlc'],
+    'link_with' : [libvlc]
+}
+
+vlc_tests += {
+    'name' : 'test_libvlc_media_player',
+    'sources' : files('media_player.c'),
+    'suite' : ['libvlc'],
+    'link_with' : [libvlc, libvlccore],
+    'module_depends': ['demux_mock']
+}
+
+vlc_tests += {
+    'name' : 'test_libvlc_media_player_record',
+    'sources' : files('media_player_record.c'),
+    'suite' : ['libvlc'],
+    'link_with' : [libvlc, libvlccore],
+    'module_depends': ['demux_mock', 'stream_out_record']
+}
+
+vlc_tests += {
+    'name' : 'test_libvlc_media_discoverer',
+    'sources' : files('media_discoverer.c'),
+    'suite' : ['libvlc'],
+    'link_with' : [libvlc]
+}
+
+vlc_tests += {
+    'name' : 'test_libvlc_renderer_discoverer',
+    'sources' : files('renderer_discoverer.c'),
+    'suite' : ['libvlc'],
+    'link_with' : [libvlc]
+}
+
+vlc_tests += {
+    'name' : 'test_libvlc_slaves',
+    'sources' : files('slaves.c'),
+    'suite' : ['libvlc'],
+    'link_with' : [libvlc, libvlccore],
+    'module_depends' : vlc_plugins_targets.keys()
+}
+
+vlc_tests += {
+    'name' : 'test_libvlc_meta',
+    'sources' : files('meta.c'),
+    'suite' : ['libvlc'],
+    'link_with' : [libvlc, libvlccore],
+    'module_depends' : vlc_plugins_targets.keys()
+}


=====================================
test/libvlc/test.h
=====================================
@@ -96,7 +96,7 @@ static inline void test_init (void)
         alarm (alarm_timeout);
     }
 
-    setenv( "VLC_PLUGIN_PATH", "../modules", 1 );
+    setenv( "VLC_PLUGIN_PATH", TOP_BUILDDIR"/modules", 1 );
 }
 
 #endif /* TEST_H */


=====================================
test/meson.build
=====================================
@@ -0,0 +1,57 @@
+vlc_tests = []
+
+subdir('libvlc')
+
+foreach vlc_test: vlc_tests
+    if not vlc_test.has_key('name')
+        error('Got invalid vlc_tests entry without \'name\' key')
+    endif
+    if not vlc_test.has_key('sources')
+        error('Got invalid vlc_tests entry without \'sources\' key')
+    endif
+
+    # This list MUST be kept in sync with the keys used below!
+    valid_dict_keys = [
+        'name',
+        'sources',
+        'suite',
+        'link_with',
+        'module_depends',
+    ]
+
+    foreach key : vlc_test.keys()
+        if key not in valid_dict_keys
+            error('Invalid key \'@0@\' found in vlc_tests entry for \'@1@\''
+                .format(key, vlc_test['name']))
+        endif
+    endforeach
+
+    common_args = [
+        '-DSRCDIR="@0@"'.format(vlc_src_root + '/test/'),
+        '-DTOP_BUILDDIR="@0@"'.format(vlc_build_root),
+    ]
+
+    test_modules_deps = []
+    foreach module_name : vlc_test.get('module_depends', [])
+        if module_name not in vlc_plugins_targets.keys()
+            error('Test entry \'@0@\' cannot depend on non-existant VLC plugin \'@1@\''
+                  .format(vlc_test['name'], module_name))
+        endif
+        test_modules_deps += vlc_plugins_targets[module_name]
+    endforeach
+
+    test(vlc_test['name'],
+        executable(vlc_test['name'], vlc_test['sources'],
+            build_by_default: false,
+            link_with: [vlc_test.get('link_with', []),
+                vlc_libcompat],
+            include_directories: [vlc_test.get('include_directories', []),
+                vlc_include_dirs],
+            dependencies: [vlc_test.get('dependencies', []),
+                libvlccore_deps],
+            c_args: [vlc_test.get('c_args', []), common_args],
+            cpp_args: [vlc_test.get('cpp_args', []), common_args],
+            objc_args: [vlc_test.get('objc_args', []), common_args]),
+        suite: [vlc_test.get('suite', []), 'test'],
+        depends: [test_modules_deps])
+endforeach



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0a31710d81eacec08a0ad7f6ba5890ed803b377c...63d0d80c43c974b39c2db327ffd3bfbfe5a35ef6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0a31710d81eacec08a0ad7f6ba5890ed803b377c...63d0d80c43c974b39c2db327ffd3bfbfe5a35ef6
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list