[libcamera-devel] [PATCH v2] lc-compliance: Add test to call multiple configure()

Niklas Söderlund niklas.soderlund at ragnatech.se
Sat May 22 11:58:50 CEST 2021


Hi Nícolas,

Thanks for your work.

On 2021-05-18 15:46:01 -0300, Nícolas F. R. A. Prado wrote:
> Add a test to lc-compliance that calls configure() multiple times on the
> camera before starting to capture. This isn't a common pattern for
> applications but is allowed and so should be tested by lc-compliance.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado at collabora.com>
> ---
> Changes in v2:
> - Thanks to Niklas:
>   - Move roles vector inside the configure test
> 
>  src/lc-compliance/single_stream.cpp | 32 ++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lc-compliance/single_stream.cpp b/src/lc-compliance/single_stream.cpp
> index 8318b42f42d6..9159ea17fcf2 100644
> --- a/src/lc-compliance/single_stream.cpp
> +++ b/src/lc-compliance/single_stream.cpp
> @@ -33,6 +33,26 @@ Results::Result testRequestBalance(std::shared_ptr<Camera> camera,
>  		std::to_string(startCycles) + " start cycles" };
>  }
>  
> +Results::Result testMultipleConfigures(std::shared_ptr<Camera> camera,
> +				       StreamRole role, unsigned int numRequests)
> +{
> +	const std::vector<StreamRole> roles = { Raw, StillCapture, VideoRecording, Viewfinder };
> +	Results::Result ret;
> +
> +	SimpleCaptureBalanced capture(camera);
> +
> +	for (auto r: roles) {
> +		ret = capture.configure(r);
> +		if (ret.first == Results::Fail)
> +			return ret;
> +	}

With an added new line here,

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

> +	ret = capture.configure(role);
> +	if (ret.first != Results::Pass)
> +		return ret;
> +
> +	return capture.capture(numRequests);
> +}
> +
>  Results::Result testRequestUnbalance(std::shared_ptr<Camera> camera,
>  				     StreamRole role, unsigned int numRequests)
>  {
> @@ -55,7 +75,7 @@ Results testSingleStream(std::shared_ptr<Camera> camera)
>  	};
>  	static const std::vector<unsigned int> numRequests = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };
>  
> -	Results results(numRequests.size() * roles.size() * 3);
> +	Results results(numRequests.size() * roles.size() * 3 + roles.size());
>  
>  	for (const auto &role : roles) {
>  		std::cout << "= Test role " << role.first << std::endl;
> @@ -91,6 +111,16 @@ Results testSingleStream(std::shared_ptr<Camera> camera)
>  		std::cout << "* Test unbalanced stop" << std::endl;
>  		for (unsigned int num : numRequests)
>  			results.add(testRequestUnbalance(camera, role.second, num));
> +
> +		/*
> +		 * Test multiple configure()
> +		 *
> +		 * Makes sure that the camera supports being configured multiple
> +		 * times, with only the last one taking effect, before starting
> +		 * to capture.
> +		 */
> +		std::cout << "* Test multiple configure()" << std::endl;
> +		results.add(testMultipleConfigures(camera, role.second, numRequests.back()));
>  	}
>  
>  	return results;
> -- 
> 2.31.1
> 

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list