summaryrefslogtreecommitdiffstats
path: root/test/bioprinttest.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2017-04-25 00:21:28 +0200
committerAndy Polyakov <appro@openssl.org>2017-04-25 23:26:51 +0200
commitdd05be5d7809cb831718820eedd86269b2504180 (patch)
tree02ce291863551e70434453b535676f927f471f3b /test/bioprinttest.c
parentb69ae442a3b3e168d73c53dcd04bacf33eee8569 (diff)
test: don't make it more complicated than necessary.
Original rationale behind using write in testutil was to accommodate no-stdio builds. But is there evidence that no-stdio users would have write or pre-defined meaning for file descriptors 1 and 2? Correct answer is to provide way for no-stdio users who want to exercise tests to plug in own BIO, not to make assumption that they have write. And since we don't have to make such assumption, we can as well go for simplest that works with standard library as specified by C language standard. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'test/bioprinttest.c')
-rw-r--r--test/bioprinttest.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/test/bioprinttest.c b/test/bioprinttest.c
index 56aa0b0dec..2c2dc8c5d9 100644
--- a/test/bioprinttest.c
+++ b/test/bioprinttest.c
@@ -11,12 +11,6 @@
#include <stdio.h>
#include <string.h>
-#include <openssl/e_os2.h>
-#ifdef OPENSSL_SYS_WINDOWS
-# include <winsock.h>
-#else
-# include OPENSSL_UNISTD
-#endif
#include <openssl/bio.h>
#include "internal/numbers.h"
#include "testutil.h"
@@ -268,16 +262,21 @@ void test_close_streams(void)
int test_puts_stdout(const char *str)
{
- return write(1, str, strlen(str));
+ return fputs(str, stdout);
}
int test_puts_stderr(const char *str)
{
- return write(2, str, strlen(str));
+ return fputs(str, stderr);
}
static char vprint_buf[10240];
+/*
+ * This works out as long as caller doesn't use any "fancy" formats.
+ * But we are caller's caller, and test_str_eq is the only one called,
+ * and it uses only "%s", which is not "fancy"...
+ */
int test_vprintf_stdout(const char *fmt, va_list ap)
{
size_t len = vsnprintf(vprint_buf, sizeof(vprint_buf), fmt, ap);
@@ -298,10 +297,10 @@ int test_vprintf_stderr(const char *fmt, va_list ap)
int test_flush_stdout(void)
{
- return 0;
+ return fflush(stdout);
}
int test_flush_stderr(void)
{
- return 0;
+ return fflush(stderr);
}