[libcamera-devel] test: timer: Add dynamically allocated timer test

Message ID 20190701202712.29332-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 3952d49d8db15eb0788817f97b4de9eadd036324
Headers show
Series
  • [libcamera-devel] test: timer: Add dynamically allocated timer test
Related show

Commit Message

Laurent Pinchart July 1, 2019, 8:27 p.m. UTC
Timers should be automatically stopped and unregistered when deleted.
Add a test to verify this is the case.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/timer.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Niklas Söderlund July 1, 2019, 9:42 p.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2019-07-01 23:27:12 +0300, Laurent Pinchart wrote:
> Timers should be automatically stopped and unregistered when deleted.
> Add a test to verify this is the case.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

Will you push this together with the timer fix or should I?

> ---
>  test/timer.cpp | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/test/timer.cpp b/test/timer.cpp
> index 41c132bd1ab2..addebce3c784 100644
> --- a/test/timer.cpp
> +++ b/test/timer.cpp
> @@ -152,6 +152,17 @@ protected:
>  			return TestFail;
>  		}
>  
> +		/*
> +		 * Test that dynamically allocated timers are stopped when
> +		 * deleted. This will result in a crash on failure.
> +		 */
> +		ManagedTimer *dyntimer = new ManagedTimer();
> +		dyntimer->start(100);
> +		delete dyntimer;
> +
> +		timer.start(200);
> +		dispatcher->processEvents();
> +
>  		return TestPass;
>  	}
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> 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 41c132bd1ab2..addebce3c784 100644
--- a/test/timer.cpp
+++ b/test/timer.cpp
@@ -152,6 +152,17 @@  protected:
 			return TestFail;
 		}
 
+		/*
+		 * Test that dynamically allocated timers are stopped when
+		 * deleted. This will result in a crash on failure.
+		 */
+		ManagedTimer *dyntimer = new ManagedTimer();
+		dyntimer->start(100);
+		delete dyntimer;
+
+		timer.start(200);
+		dispatcher->processEvents();
+
 		return TestPass;
 	}