From e17f998c20a5926c90b2899a9040d76f0faeb4ce 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/clr commit: 99f1830ed6912918811c823c8cd4ec9a9d6c5d5e] --- .../hipamd/tests/src/printf/printf_common.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/projects/clr/hipamd/tests/src/printf/printf_common.h b/projects/clr/hipamd/tests/src/printf/printf_common.h index a2df88db9f..60b0aff46c 100644 --- a/projects/clr/hipamd/tests/src/printf/printf_common.h +++ b/projects/clr/hipamd/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); }