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

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Jul 1 22:27:12 CEST 2019


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 at ideasonboard.com>
---
 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



More information about the libcamera-devel mailing list