[libcamera-devel] test: Use foreach iterators to simplify definitions

Message ID 20181221090804.8208-1-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] test: Use foreach iterators to simplify definitions
Related show

Commit Message

Kieran Bingham Dec. 21, 2018, 9:08 a.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.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---

This patch applies on top of the series "[PATCH 0/5] test: Define
libtest" just posted.


 test/meson.build | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

Comments

Niklas Söderlund Dec. 28, 2018, 2:34 a.m. UTC | #1
Hi Kieran,

Thanks for your patch.

On 2018-12-21 09:08:04 +0000, Kieran Bingham wrote:
> 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.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
> 
> This patch applies on top of the series "[PATCH 0/5] test: Define
> libtest" just posted.
> 
> 
>  test/meson.build | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/test/meson.build b/test/meson.build
> index 50ec11853203..754527324c7d 100644
> --- a/test/meson.build
> +++ b/test/meson.build
> @@ -12,8 +12,26 @@ test_includes_internal = [
>    libcamera_internal_includes,
>  ]
>  
> -test_init = executable('test_init', 'init.cpp',
> -                       link_with : test_libraries,
> -                       include_directories : test_includes_public)
> +public_tests = [
> +  [ 'test_init',      'init.cpp' ],
> +]
> +
> +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(t[0], exe)
> +endforeach
> -- 
> 2.17.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Dec. 31, 2018, 9:12 a.m. UTC | #2
Hi Kieran,

Thank you for the patch.

On Friday, 21 December 2018 11:08:04 EET Kieran Bingham wrote:
> 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.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
> 
> This patch applies on top of the series "[PATCH 0/5] test: Define
> libtest" just posted.
> 
> 
>  test/meson.build | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/test/meson.build b/test/meson.build
> index 50ec11853203..754527324c7d 100644
> --- a/test/meson.build
> +++ b/test/meson.build
> @@ -12,8 +12,26 @@ test_includes_internal = [
>    libcamera_internal_includes,
>  ]
> 
> -test_init = executable('test_init', 'init.cpp',
> -                       link_with : test_libraries,
> -                       include_directories : test_includes_public)
> +public_tests = [
> +  [ 'test_init',      'init.cpp' ],

Indentation.

> +]
> +
> +internal_tests = [
> +

Extraneous blank line.

With this fixed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +]
> +
> +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(t[0], exe)
> +endforeach

Patch

diff --git a/test/meson.build b/test/meson.build
index 50ec11853203..754527324c7d 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -12,8 +12,26 @@  test_includes_internal = [
   libcamera_internal_includes,
 ]
 
-test_init = executable('test_init', 'init.cpp',
-                       link_with : test_libraries,
-                       include_directories : test_includes_public)
+public_tests = [
+  [ 'test_init',      'init.cpp' ],
+]
+
+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(t[0], exe)
+endforeach