[libcamera-devel,01/14] test: object-invoke: Test direct invocation

Message ID 20200104050947.7673-2-laurent.pinchart@ideasonboard.com
State Accepted
Commit d82b8778ed4fa9cf0f2ccacc95807c1bdaa25bda
Headers show
Series
  • object: Propagate return value of invoked method
Related show

Commit Message

Laurent Pinchart Jan. 4, 2020, 5:09 a.m. UTC
Test the ConnectionTypeDirect type when the object lives in a different
thread. This test passes but generates a memory leak.

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

Comments

Niklas Söderlund Jan. 7, 2020, 6:54 p.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2020-01-04 07:09:34 +0200, Laurent Pinchart wrote:
> Test the ConnectionTypeDirect type when the object lives in a different
> thread. This test passes but generates a memory leak.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

> ---
>  test/object-invoke.cpp | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp
> index f9a8bea9dce2..ed16de99ef5e 100644
> --- a/test/object-invoke.cpp
> +++ b/test/object-invoke.cpp
> @@ -123,6 +123,27 @@ protected:
>  			return TestFail;
>  		}
>  
> +		/* Test that direct method invocation bypasses threads. */
> +		object_.reset();
> +		object_.invokeMethod(&InvokedObject::method,
> +				     ConnectionTypeDirect, 42);
> +
> +		switch (object_.status()) {
> +		case InvokedObject::NoCall:
> +			cout << "Method not invoked for custom thread" << endl;
> +			return TestFail;
> +		case InvokedObject::CallReceived:
> +			cout << "Method invoked in incorrect thread for direct call" << endl;
> +			return TestFail;
> +		default:
> +			break;
> +		}
> +
> +		if (object_.value() != 42) {
> +			cout << "Method invoked with incorrect value for direct call" << endl;
> +			return TestFail;
> +		}
> +
>  		/*
>  		 * Test invoking a method that takes reference arguments. This
>  		 * targets compilation, there's no need to check runtime
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp
index f9a8bea9dce2..ed16de99ef5e 100644
--- a/test/object-invoke.cpp
+++ b/test/object-invoke.cpp
@@ -123,6 +123,27 @@  protected:
 			return TestFail;
 		}
 
+		/* Test that direct method invocation bypasses threads. */
+		object_.reset();
+		object_.invokeMethod(&InvokedObject::method,
+				     ConnectionTypeDirect, 42);
+
+		switch (object_.status()) {
+		case InvokedObject::NoCall:
+			cout << "Method not invoked for custom thread" << endl;
+			return TestFail;
+		case InvokedObject::CallReceived:
+			cout << "Method invoked in incorrect thread for direct call" << endl;
+			return TestFail;
+		default:
+			break;
+		}
+
+		if (object_.value() != 42) {
+			cout << "Method invoked with incorrect value for direct call" << endl;
+			return TestFail;
+		}
+
 		/*
 		 * Test invoking a method that takes reference arguments. This
 		 * targets compilation, there's no need to check runtime