[PATCH i-g-t 4/4] core: Apply the same treatment to the in errno message in __igt_fail_assert()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just like the it was done for the requirement message, display the errno
message only if errno is set, and display it at the end of the assert
message.

Signed-off-by: Damien Lespiau <damien.lespiau@xxxxxxxxx>
---
 lib/igt_core.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index e66d096..53f750a 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -682,11 +682,17 @@ void __igt_fail_assert(int exitcode, const char *file,
 {
 	va_list args;
 	int err = errno;
+	char *err_str = NULL;
+
+	if (err)
+		asprintf(&err_str, "Last errno: %i, %s\n", err, strerror(err));
 
 	printf("Test assertion failure function %s, file %s:%i:\n"
-	       "Last errno: %i, %s\n"
-	       "Failed assertion: %s\n",
-	       func, file, line, err, strerror(err), assertion);
+	       "Failed assertion: %s\n"
+	       "%s",
+	       func, file, line, assertion, err_str ?: "");
+
+	free(err_str);
 
 	if (f) {
 		va_start(args, f);
-- 
1.8.3.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux