[libcamera-devel,RFC,v2,4/9] libcamera: test: Add ControlInfo tests

Message ID 20190621161401.28337-5-kieran.bingham@ideasonboard.com
State Superseded
Headers show
Series
  • Libcamera Controls
Related show

Commit Message

Kieran Bingham June 21, 2019, 4:13 p.m. UTC
Provide an initial test coverage for the ControlInfo class.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 test/controls.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
 test/meson.build  |  1 +
 2 files changed, 41 insertions(+)
 create mode 100644 test/controls.cpp

Comments

Niklas Söderlund June 23, 2019, 3:23 p.m. UTC | #1
Hi Kieran,

Thanks for your work.

On 2019-06-21 17:13:56 +0100, Kieran Bingham wrote:
> Provide an initial test coverage for the ControlInfo class.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

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

> ---
>  test/controls.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
>  test/meson.build  |  1 +
>  2 files changed, 41 insertions(+)
>  create mode 100644 test/controls.cpp
> 
> diff --git a/test/controls.cpp b/test/controls.cpp
> new file mode 100644
> index 000000000000..94e89f270108
> --- /dev/null
> +++ b/test/controls.cpp
> @@ -0,0 +1,40 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (C) 2019, Google Inc.
> + *
> + * controls.cpp - Control tests
> + */
> +
> +#include <iostream>
> +
> +#include <libcamera/controls.h>
> +
> +#include "test.h"
> +
> +using namespace std;
> +using namespace libcamera;
> +
> +class Controls : public Test
> +{
> +protected:
> +	int testControlInfo()
> +	{
> +		ControlInfo gainInfo(ManualGain);
> +		cout << "Gain Info: " << gainInfo << endl;
> +
> +		return TestPass;
> +	}
> +
> +	int run()
> +	{
> +		int ret;
> +
> +		ret = testControlInfo();
> +		if (ret)
> +			return ret;
> +
> +		return TestPass;
> +	}
> +};
> +
> +TEST_REGISTER(Controls)
> diff --git a/test/meson.build b/test/meson.build
> index eff541ddc0a6..0b3e6c6813e6 100644
> --- a/test/meson.build
> +++ b/test/meson.build
> @@ -9,6 +9,7 @@ subdir('v4l2_subdevice')
>  subdir('v4l2_videodevice')
>  
>  public_tests = [
> +    ['controls',                        'controls.cpp'],
>      ['event',                           'event.cpp'],
>      ['event-dispatcher',                'event-dispatcher.cpp'],
>      ['geometry',                        'geometry.cpp'],
> -- 
> 2.20.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart June 23, 2019, 9:57 p.m. UTC | #2
Hi Kieran,

Thank you for the patch.

On Fri, Jun 21, 2019 at 05:13:56PM +0100, Kieran Bingham wrote:
> Provide an initial test coverage for the ControlInfo class.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  test/controls.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
>  test/meson.build  |  1 +
>  2 files changed, 41 insertions(+)
>  create mode 100644 test/controls.cpp
> 
> diff --git a/test/controls.cpp b/test/controls.cpp
> new file mode 100644
> index 000000000000..94e89f270108
> --- /dev/null
> +++ b/test/controls.cpp
> @@ -0,0 +1,40 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (C) 2019, Google Inc.
> + *
> + * controls.cpp - Control tests
> + */
> +
> +#include <iostream>
> +
> +#include <libcamera/controls.h>
> +
> +#include "test.h"
> +
> +using namespace std;
> +using namespace libcamera;
> +
> +class Controls : public Test
> +{
> +protected:
> +	int testControlInfo()
> +	{
> +		ControlInfo gainInfo(ManualGain);
> +		cout << "Gain Info: " << gainInfo << endl;
> +
> +		return TestPass;
> +	}
> +
> +	int run()
> +	{
> +		int ret;
> +
> +		ret = testControlInfo();
> +		if (ret)
> +			return ret;
> +
> +		return TestPass;

A test that always succeeds is not a test...

> +	}
> +};
> +
> +TEST_REGISTER(Controls)
> diff --git a/test/meson.build b/test/meson.build
> index eff541ddc0a6..0b3e6c6813e6 100644
> --- a/test/meson.build
> +++ b/test/meson.build
> @@ -9,6 +9,7 @@ subdir('v4l2_subdevice')
>  subdir('v4l2_videodevice')
>  
>  public_tests = [
> +    ['controls',                        'controls.cpp'],
>      ['event',                           'event.cpp'],
>      ['event-dispatcher',                'event-dispatcher.cpp'],
>      ['geometry',                        'geometry.cpp'],

Patch

diff --git a/test/controls.cpp b/test/controls.cpp
new file mode 100644
index 000000000000..94e89f270108
--- /dev/null
+++ b/test/controls.cpp
@@ -0,0 +1,40 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * controls.cpp - Control tests
+ */
+
+#include <iostream>
+
+#include <libcamera/controls.h>
+
+#include "test.h"
+
+using namespace std;
+using namespace libcamera;
+
+class Controls : public Test
+{
+protected:
+	int testControlInfo()
+	{
+		ControlInfo gainInfo(ManualGain);
+		cout << "Gain Info: " << gainInfo << endl;
+
+		return TestPass;
+	}
+
+	int run()
+	{
+		int ret;
+
+		ret = testControlInfo();
+		if (ret)
+			return ret;
+
+		return TestPass;
+	}
+};
+
+TEST_REGISTER(Controls)
diff --git a/test/meson.build b/test/meson.build
index eff541ddc0a6..0b3e6c6813e6 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -9,6 +9,7 @@  subdir('v4l2_subdevice')
 subdir('v4l2_videodevice')
 
 public_tests = [
+    ['controls',                        'controls.cpp'],
     ['event',                           'event.cpp'],
     ['event-dispatcher',                'event-dispatcher.cpp'],
     ['geometry',                        'geometry.cpp'],