[libcamera-devel,2/5] test: timer: Add a 32 bit wraparound test

Message ID 20190117202043.21420-3-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • General fixes
Related show

Commit Message

Kieran Bingham Jan. 17, 2019, 8:20 p.m. UTC
Add a test which catches a timer running longer than the nanosecond
resolution of 32 bits.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 test/timer.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Laurent Pinchart Jan. 17, 2019, 8:42 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Thu, Jan 17, 2019 at 08:20:40PM +0000, Kieran Bingham wrote:
> Add a test which catches a timer running longer than the nanosecond
> resolution of 32 bits.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

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

> ---
>  test/timer.cpp | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/test/timer.cpp b/test/timer.cpp
> index 3d1a78ac2768..c6a6ede73486 100644
> --- a/test/timer.cpp
> +++ b/test/timer.cpp
> @@ -81,6 +81,19 @@ protected:
>  			return TestFail;
>  		}
>  
> +		/*
> +		 * 32 bit wrap test
> +		 * Nanosecond resolution in a 32 bit value wraps at 4.294967
> +		 * seconds (0xFFFFFFFF / 1000000)
> +		 */
> +		timer.start(4295);
> +		dispatcher->processEvents();
> +
> +		if (timer.isRunning() || timer.jitter() > 50) {
> +			cout << "Timer expiration test failed" << endl;
> +			return TestFail;
> +		}
> +
>  		/* Timer restart. */
>  		timer.start(500);
>
Niklas Söderlund Jan. 17, 2019, 10 p.m. UTC | #2
Hi Kieran,

Thanks for your patch.

On 2019-01-17 20:20:40 +0000, Kieran Bingham wrote:
> Add a test which catches a timer running longer than the nanosecond
> resolution of 32 bits.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

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

> ---
>  test/timer.cpp | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/test/timer.cpp b/test/timer.cpp
> index 3d1a78ac2768..c6a6ede73486 100644
> --- a/test/timer.cpp
> +++ b/test/timer.cpp
> @@ -81,6 +81,19 @@ protected:
>  			return TestFail;
>  		}
>  
> +		/*
> +		 * 32 bit wrap test
> +		 * Nanosecond resolution in a 32 bit value wraps at 4.294967
> +		 * seconds (0xFFFFFFFF / 1000000)
> +		 */
> +		timer.start(4295);
> +		dispatcher->processEvents();
> +
> +		if (timer.isRunning() || timer.jitter() > 50) {
> +			cout << "Timer expiration test failed" << endl;
> +			return TestFail;
> +		}
> +
>  		/* Timer restart. */
>  		timer.start(500);
>  
> -- 
> 2.17.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/test/timer.cpp b/test/timer.cpp
index 3d1a78ac2768..c6a6ede73486 100644
--- a/test/timer.cpp
+++ b/test/timer.cpp
@@ -81,6 +81,19 @@  protected:
 			return TestFail;
 		}
 
+		/*
+		 * 32 bit wrap test
+		 * Nanosecond resolution in a 32 bit value wraps at 4.294967
+		 * seconds (0xFFFFFFFF / 1000000)
+		 */
+		timer.start(4295);
+		dispatcher->processEvents();
+
+		if (timer.isRunning() || timer.jitter() > 50) {
+			cout << "Timer expiration test failed" << endl;
+			return TestFail;
+		}
+
 		/* Timer restart. */
 		timer.start(500);