[libcamera-devel,2/5] test: Use foreach iterators to simplify definitions

Message ID 20190101212947.28098-3-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • test: Unit Test Improvements
Related show

Commit Message

Kieran Bingham Jan. 1, 2019, 9:29 p.m. UTC
Create two arrays, to contain public and internal test targets, and use
the foreach iterators to automatically generate test output targets for
each entry in each array.

The public tests array is linked only against public libcamera headers,
while tests declared in the internal_tests will have access to
non-public API headers from within the libcamera sources.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 test/meson.build | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

Patch

diff --git a/test/meson.build b/test/meson.build
index 3b7591ad9204..bf8232f32787 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -12,15 +12,28 @@  test_includes_internal = [
     libcamera_internal_includes,
 ]
 
-test_init = executable('test_init', 'init.cpp',
-                       link_with : test_libraries,
-                       include_directories : test_includes_public)
+subdir('media_device')
 
-list = executable('list', 'list.cpp',
-                  link_with : test_libraries,
-                  include_directories : test_includes_public)
+public_tests = [
+    ['test_init',       'init.cpp'],
+    ['list',            'list.cpp'],
+]
 
-subdir('media_device')
+internal_tests = [
+]
+
+foreach t : public_tests
+    exe = executable(t[0], t[1],
+                     link_with : test_libraries,
+                     include_directories : test_includes_public)
+
+    test(t[0], exe)
+endforeach
+
+foreach t : internal_tests
+    exe = executable(t[0], t[1],
+                     link_with : test_libraries,
+                     include_directories : test_includes_internal)
 
-test('Initialisation test', test_init)
-test('List Camera API tests', list)
+    test(t[0], exe)
+endforeach