@@ -101,10 +101,9 @@ int GetStdoutFdDup() {
101101
102102void Silence (int fd) {
103103 FILE* tmp = fopen (" /dev/null" , " w" );
104- FUZZTEST_CHECK (tmp) << " fopen() error: " << strerror (errno);
105- FUZZTEST_CHECK (dup2 (fileno (tmp), fd) != -1 ) << " dup2() error: " ,
106- strerror (errno);
107- FUZZTEST_CHECK (fclose (tmp) == 0 ) << " fclose() error: " << strerror (errno);
104+ FUZZTEST_PCHECK (tmp) << " fopen() error" ;
105+ FUZZTEST_PCHECK (dup2 (fileno (tmp), fd) != -1 ) << " dup2() error" ;
106+ FUZZTEST_PCHECK (fclose (tmp) == 0 ) << " fclose() error" ;
108107}
109108
110109// Only accepts 1 or 2 (stdout or stderr).
@@ -118,13 +117,11 @@ void DupAndSilence(int fd) {
118117 if (fd == STDOUT_FILENO) {
119118 FUZZTEST_CHECK (GetStdoutFdDup () != -1 ) << " GetStdoutFdDup() fails." ;
120119 stdout_file_ = fdopen (GetStdoutFdDup (), " w" );
121- FUZZTEST_CHECK (stdout_file_)
122- << " fdopen(GetStdoutFdDup()) error:" << strerror (errno);
120+ FUZZTEST_PCHECK (stdout_file_) << " fdopen(GetStdoutFdDup()) error" ;
123121 } else {
124122 FUZZTEST_CHECK (GetStderrFdDup () != -1 ) << " GetStderrFdDup() fails." ;
125123 auto file = fdopen (GetStderrFdDup (), " w" );
126- FUZZTEST_CHECK (file) << " fdopen(GetStderrFdDup()) error:"
127- << strerror (errno);
124+ FUZZTEST_PCHECK (file) << " fdopen(GetStderrFdDup()) error" ;
128125 absl::MutexLock lock (&stderr_file_guard_);
129126 stderr_file_ = file;
130127 }
@@ -147,20 +144,13 @@ void RestoreTargetStdoutAndStderr() {
147144 stderr_file_ = stderr;
148145 stderr_file_guard_.Unlock ();
149146 FUZZTEST_CHECK (silenced_stderr != stderr)
150- << " Error, calling RestoreStderr without calling"
151- " DupandSilenceStderr first." ;
152- FUZZTEST_CHECK (dup2 (fileno (silenced_stderr), STDERR_FILENO) != -1 )
153- << " dup2 error:" << strerror (errno);
154- FUZZTEST_CHECK (fclose (silenced_stderr) == 0 )
155- << " close() error:" << strerror (errno);
156-
147+ << " RestoreStderr was called without calling DupandSilenceStderr first." ;
148+ FUZZTEST_PCHECK (dup2 (fileno (silenced_stderr), STDERR_FILENO) != -1 );
149+ FUZZTEST_PCHECK (fclose (silenced_stderr) == 0 );
157150 FUZZTEST_CHECK (stdout_file_ != stdout)
158- << " Error, calling RestoreStdout without calling"
159- " DupandSilenceStdout first." ;
160- FUZZTEST_CHECK (dup2 (fileno (stdout_file_), STDOUT_FILENO) != -1 )
161- << " dup2() error:" << strerror (errno);
162- FUZZTEST_CHECK (fclose (stdout_file_) == 0 )
163- << " close() error:" << strerror (errno);
151+ << " RestoreStdout was called without calling DupandSilenceStdout first." ;
152+ FUZZTEST_PCHECK (dup2 (fileno (stdout_file_), STDOUT_FILENO) != -1 );
153+ FUZZTEST_PCHECK (fclose (stdout_file_) == 0 );
164154 stdout_file_ = stdout;
165155}
166156
0 commit comments