[libcamera-devel] [PATCH] tests: call the derived Test class cleanup() function
jacopo mondi
jacopo at jmondi.org
Fri Dec 21 17:26:42 CET 2018
Hi Niklas,
On Fri, Dec 21, 2018 at 01:53:29AM +0100, Niklas Söderlund wrote:
> 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)
Shouldn't the same be done here?
> return ret;
>
> - return run();
> + ret = run();
> +
> + cleanup();
> +
> + return ret;
> }
> --
> 2.20.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20181221/60a1ba41/attachment.sig>
More information about the libcamera-devel
mailing list