[libcamera-devel] [PATCH] tests: call the derived Test class cleanup() function

Niklas Söderlund niklas.soderlund at ragnatech.se
Fri Dec 21 01:53:29 CET 2018


Calling the cleanup() function in the base class Test destructor only
calls the base class empty cleanup() function, not the overloaded one.
This results in tests not cleaning up after themself. Solve this by
explicitly calling the cleanup() function from execute().

This was discovered while running valgrind on tests where objects where
allocated in init() and freed in cleanup().

Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
 test/test.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/test.cpp b/test/test.cpp
index 4e7779e750d56687..1bb6ebcb9e8acf18 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -13,7 +13,6 @@ Test::Test()
 
 Test::~Test()
 {
-	cleanup();
 }
 
 int Test::execute()
@@ -24,5 +23,9 @@ int Test::execute()
 	if (ret < 0)
 		return ret;
 
-	return run();
+	ret = run();
+
+	cleanup();
+
+	return ret;
 }
-- 
2.20.1



More information about the libcamera-devel mailing list