From 7c60cf0a5b15b956efb277a418b7ab9efe81d4ce Mon Sep 17 00:00:00 2001 From: Saleel Kudchadker Date: Mon, 31 Aug 2020 13:15:50 -0700 Subject: [PATCH] Fix hipPrintf* tests The test needs to check dup2 syscall status and not the errno val Change-Id: Ic88eb2047b839adbc9e12965b098d8960cd7e2b8 [ROCm/hip commit: 7720651f2d4ec38adc576e533462bc0908ac51e5] --- projects/hip/tests/src/printf/printf_common.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/projects/hip/tests/src/printf/printf_common.h b/projects/hip/tests/src/printf/printf_common.h index a2df88db9f..60b0aff46c 100644 --- a/projects/hip/tests/src/printf/printf_common.h +++ b/projects/hip/tests/src/printf/printf_common.h @@ -21,20 +21,17 @@ struct CaptureStream { orig_fd = fileno(original); saved_fd = dup(orig_fd); - temp_fd = mkstemp(tempname); - if (errno) { + if ((temp_fd = mkstemp(tempname)) == -1) { error(0, errno, "Error"); assert(false); } fflush(nullptr); - dup2(temp_fd, orig_fd); - if (errno) { + if (dup2(temp_fd, orig_fd) == -1) { error(0, errno, "Error"); assert(false); } - close(temp_fd); - if (errno) { + if (close(temp_fd) != 0) { error(0, errno, "Error"); assert(false); } @@ -44,13 +41,11 @@ struct CaptureStream { if (saved_fd == -1) return; fflush(nullptr); - dup2(saved_fd, orig_fd); - if (errno) { + if (dup2(saved_fd, orig_fd) == -1) { error(0, errno, "Error"); assert(false); } - close(saved_fd); - if (errno) { + if (close(saved_fd) != 0) { error(0, errno, "Error"); assert(false); } @@ -65,8 +60,7 @@ struct CaptureStream { ~CaptureStream() { restoreStream(); - remove(tempname); - if (errno) { + if (remove(tempname) != 0) { error(0, errno, "Error"); assert(false); }