提交 f044cd05 编写于 作者: R Richard Levitte

Avoid using BIO streams in bioprinttest.c

Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3243)
上级 a9c6d221
...@@ -7,8 +7,16 @@ ...@@ -7,8 +7,16 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#define TESTUTIL_NO_size_t_COMPARISON
#include <stdio.h> #include <stdio.h>
#include <string.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 <openssl/bio.h>
#include "internal/numbers.h" #include "internal/numbers.h"
#include "testutil.h" #include "testutil.h"
...@@ -245,3 +253,55 @@ int test_main(int argc, char **argv) ...@@ -245,3 +253,55 @@ int test_main(int argc, char **argv)
return run_tests(argv[0]); return run_tests(argv[0]);
} }
/*
* Replace testutil output routines. We do this to eliminate possible sources
* of BIO error
*/
void test_open_streams(void)
{
}
void test_close_streams(void)
{
}
int test_puts_stdout(const char *str)
{
return write(1, str, strlen(str));
}
int test_puts_stderr(const char *str)
{
return write(2, str, strlen(str));
}
static char vprint_buf[10240];
int test_vprintf_stdout(const char *fmt, va_list ap)
{
size_t len = vsnprintf(vprint_buf, sizeof(vprint_buf), fmt, ap);
if (len >= sizeof(vprint_buf))
return -1;
return test_puts_stdout(vprint_buf);
}
int test_vprintf_stderr(const char *fmt, va_list ap)
{
size_t len = vsnprintf(vprint_buf, sizeof(vprint_buf), fmt, ap);
if (len >= sizeof(vprint_buf))
return -1;
return test_puts_stderr(vprint_buf);
}
int test_flush_stdout(void)
{
return 0;
}
int test_flush_stderr(void)
{
return 0;
}
...@@ -176,7 +176,13 @@ DECLARE_COMPARISONS(char, char) ...@@ -176,7 +176,13 @@ DECLARE_COMPARISONS(char, char)
DECLARE_COMPARISONS(unsigned char, uchar) DECLARE_COMPARISONS(unsigned char, uchar)
DECLARE_COMPARISONS(long, long) DECLARE_COMPARISONS(long, long)
DECLARE_COMPARISONS(unsigned long, ulong) DECLARE_COMPARISONS(unsigned long, ulong)
/*
* Because this comparison uses a printf format specifier that's not
* universally known (yet), we provide an option to not have it declared.
*/
# ifndef TESTUTIL_NO_size_t_COMPARISON
DECLARE_COMPARISONS(size_t, size_t) DECLARE_COMPARISONS(size_t, size_t)
# endif
/* /*
* Pointer comparisons against other pointers and null. * Pointer comparisons against other pointers and null.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册