[RFC,v2,12/16] apps: lc-compliance: Add message to `GTEST_SKIP()`
diff mbox series

Message ID 20250114182143.1773762-13-pobrn@protonmail.com
State Superseded
Headers show
Series
  • apps: lc-compliance: Multi-stream tests
Related show

Commit Message

Barnabás Pőcze Jan. 14, 2025, 6:22 p.m. UTC
Just like other gtest macros, `GTEST_SKIP()` returns an object
to which a formatted message can be added using the usual `<<`
stream operator. So use it instead of printing to `std::cout`.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
---
 src/apps/lc-compliance/helpers/capture.cpp | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Jacopo Mondi Jan. 22, 2025, 9:26 a.m. UTC | #1
Hi Barnabás

On Tue, Jan 14, 2025 at 06:22:47PM +0000, Barnabás Pőcze wrote:
> Just like other gtest macros, `GTEST_SKIP()` returns an object
> to which a formatted message can be added using the usual `<<`
> stream operator. So use it instead of printing to `std::cout`.
>
> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> ---
>  src/apps/lc-compliance/helpers/capture.cpp | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp
> index 91c4d4400..43db15d2d 100644
> --- a/src/apps/lc-compliance/helpers/capture.cpp
> +++ b/src/apps/lc-compliance/helpers/capture.cpp
> @@ -26,10 +26,8 @@ void Capture::configure(StreamRole role)
>  {
>  	config_ = camera_->generateConfiguration({ role });
>
> -	if (!config_) {
> -		std::cout << "Role not supported by camera" << std::endl;
> -		GTEST_SKIP();
> -	}
> +	if (!config_)
> +		GTEST_SKIP() << "Role not supported by camera";
>
>  	if (config_->validate() != CameraConfiguration::Valid) {
>  		config_.reset();
> @@ -85,10 +83,8 @@ void CaptureBalanced::capture(unsigned int numRequests)
>
>  	/* No point in testing less requests then the camera depth. */
>  	if (buffers.size() > numRequests) {
> -		std::cout << "Camera needs " + std::to_string(buffers.size())
> -			+ " requests, can't test only "
> -			+ std::to_string(numRequests) << std::endl;
> -		GTEST_SKIP();
> +		GTEST_SKIP() << "Camera needs " << buffers.size()
> +			     << " requests, can't test only " << numRequests;
>  	}
>
>  	queueCount_ = 0;
> --
> 2.48.0
>
>

Patch
diff mbox series

diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp
index 91c4d4400..43db15d2d 100644
--- a/src/apps/lc-compliance/helpers/capture.cpp
+++ b/src/apps/lc-compliance/helpers/capture.cpp
@@ -26,10 +26,8 @@  void Capture::configure(StreamRole role)
 {
 	config_ = camera_->generateConfiguration({ role });
 
-	if (!config_) {
-		std::cout << "Role not supported by camera" << std::endl;
-		GTEST_SKIP();
-	}
+	if (!config_)
+		GTEST_SKIP() << "Role not supported by camera";
 
 	if (config_->validate() != CameraConfiguration::Valid) {
 		config_.reset();
@@ -85,10 +83,8 @@  void CaptureBalanced::capture(unsigned int numRequests)
 
 	/* No point in testing less requests then the camera depth. */
 	if (buffers.size() > numRequests) {
-		std::cout << "Camera needs " + std::to_string(buffers.size())
-			+ " requests, can't test only "
-			+ std::to_string(numRequests) << std::endl;
-		GTEST_SKIP();
+		GTEST_SKIP() << "Camera needs " << buffers.size()
+			     << " requests, can't test only " << numRequests;
 	}
 
 	queueCount_ = 0;