[libcamera-devel,1/6] test: log: log_process: Log an error when failing due to incorrect message
diff mbox series

Message ID 20231206210524.20974-2-laurent.pinchart@ideasonboard.com
State Accepted
Commit 030fe617ef2a7064f45d5af515cd49b0a085c711
Headers show
Series
  • test: Miscellaneous fixes and improvements for unit tests
Related show

Commit Message

Laurent Pinchart Dec. 6, 2023, 9:05 p.m. UTC
One of the error paths in the test returns without logging a message,
which makes failures difficult to debug. Fix it by adding an error
message.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/log/log_process.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Kieran Bingham Dec. 7, 2023, 4:27 p.m. UTC | #1
Quoting Laurent Pinchart via libcamera-devel (2023-12-06 21:05:19)
> One of the error paths in the test returns without logging a message,
> which makes failures difficult to debug. Fix it by adding an error
> message.
> 


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  test/log/log_process.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp
> index 966b80cf3af7..17af7d74a1d5 100644
> --- a/test/log/log_process.cpp
> +++ b/test/log/log_process.cpp
> @@ -115,8 +115,11 @@ protected:
>                 close(fd);
>  
>                 string str(buf);
> -               if (str.find(message) == string::npos)
> +               if (str.find(message) == string::npos) {
> +                       cerr << "Received message is not correct (received "
> +                            << str.length() << " bytes)" << endl;
>                         return TestFail;
> +               }
>  
>                 return TestPass;
>         }
> -- 
> Regards,
> 
> Laurent Pinchart
>
Umang Jain Dec. 8, 2023, 7:11 a.m. UTC | #2
Hi Laurent,

On 12/7/23 2:35 AM, Laurent Pinchart via libcamera-devel wrote:
> One of the error paths in the test returns without logging a message,
> which makes failures difficult to debug. Fix it by adding an error
> message.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

> ---
>   test/log/log_process.cpp | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp
> index 966b80cf3af7..17af7d74a1d5 100644
> --- a/test/log/log_process.cpp
> +++ b/test/log/log_process.cpp
> @@ -115,8 +115,11 @@ protected:
>   		close(fd);
>   
>   		string str(buf);
> -		if (str.find(message) == string::npos)
> +		if (str.find(message) == string::npos) {
> +			cerr << "Received message is not correct (received "
> +			     << str.length() << " bytes)" << endl;
>   			return TestFail;
> +		}
>   
>   		return TestPass;
>   	}

Patch
diff mbox series

diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp
index 966b80cf3af7..17af7d74a1d5 100644
--- a/test/log/log_process.cpp
+++ b/test/log/log_process.cpp
@@ -115,8 +115,11 @@  protected:
 		close(fd);
 
 		string str(buf);
-		if (str.find(message) == string::npos)
+		if (str.find(message) == string::npos) {
+			cerr << "Received message is not correct (received "
+			     << str.length() << " bytes)" << endl;
 			return TestFail;
+		}
 
 		return TestPass;
 	}