Fixes gcrypt testing on msys2/mingw
cover Fixes gcrypt testing on msys2/mingw
gcrypt: test_tls_psk_init should write binary file instead text file.
gcrypt: Enable crypto tests under msys2/mingw by implement custom qemu_socket= pair
Yonggang Luo (2):
gcrypt: test_tls_psk_init should write binary file instead text file.
gcrypt: Enable crypto tests under msys2/mingw
include/qemu/osdep.h | 1 + include/sysemu/os-win32.h | 5 +++ tests/crypto-tls-psk-helpers.c | 6 ++- tests/crypto-tls-x509-helpers.c | 6 ++- tests/crypto-tls-x509-helpers.h | 5 ++- tests/test-crypto-tlscredsx509.c | 47 +++++++++++--------- tests/test-crypto-tlssession.c | 64 +++++++++++++++------------ tests/test-io-channel-tls.c | 49 +++++++++++--------- util/osdep.c | 16 +++++++ util/oslib-win32.c | 76 ++++++++++++++++++++++++++++++++ 10 files changed, 198 insertions(+), 77 deletions(-)
--=20
2.28.0.windows.1
PATCH 1/2 gcrypt: test_tls_psk_init should write binary file instead text file.
On windows, if open file with "w", it's will automatically convert "\n" to "\r\n" when writing to file.
--- tests/crypto-tls-psk-helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/crypto-tls-psk-helpers.c +1 -1
@@ -32,7 +32,7 @@ void test_tls_psk_init(const char *pskfile) {FILE *fp; - fp =fopen (pskfile,"w" ); + fp =fopen (pskfile,"wb" );if (fp ==NULL ) {g_critical ("Failed to create pskfile %s" , pskfile);abort ();
Signature · 1 line
2.28.0.windows.1
Re: [PATCH 1/2] gcrypt: test_tls_psk_init should write binary file instead text file.
Quoted 14 lines · Yonggang Luo
On windows, if open file with "w", it's will automatically convert "\n" to "\r\n" when writing to file.
Signed-off-by Yonggang Luo <[email protected]>--- tests/crypto-tls-psk-helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/crypto-tls-psk-helpers.c +0
-0
tests/crypto-tls-psk-helpers.c void test_tls_psk_init(const char *pskfile) · line 38
Quoted 8 lines
tests/crypto-tls-psk-helpers.c +1
-1@@ -32,7 +32,7 @@ void test_tls_psk_init(const char *pskfile) {FILE *fp; - fp =fopen (pskfile,"w" ); + fp =fopen (pskfile,"wb" );if (fp ==NULL ) {g_critical ("Failed to create pskfile %s" , pskfile);abort ();
PATCH 2/2 gcrypt: Enable crypto tests under msys2/mingw
In reply to Yonggang LuoFixes following tests on msys2/mingw
'test-crypto-tlscredsx509'
test-crypto-tlssession'
'test-io-channel-tls'
These tests are failure with:
ERROR test-crypto-tlscredsx509 - missing test plan ERROR test-crypto-tlssession - missing test plan ERROR test-io-channel-tls - missing test plan
Because on win32 those test case are all disabled in the header
Add qemu_socket_pair for cross platform support
Convert file system handling functions to glib
Add qemu_link function instead posix only link function.
Use send ad recv from qemu that convert Windows Socks error to errno properly. Use g_remove instead unlink
Use g_mkdir instead mkdir
--- include/qemu/osdep.h | 1 + include/sysemu/os-win32.h | 5 +++ tests/crypto-tls-psk-helpers.c | 4 +- tests/crypto-tls-x509-helpers.c | 6 ++- tests/crypto-tls-x509-helpers.h | 5 ++- tests/test-crypto-tlscredsx509.c | 47 +++++++++++--------- tests/test-crypto-tlssession.c | 64 +++++++++++++++------------ tests/test-io-channel-tls.c | 49 +++++++++++--------- util/osdep.c | 16 +++++++ util/oslib-win32.c | 76 ++++++++++++++++++++++++++++++++ 10 files changed, 197 insertions(+), 76 deletions(-)
include/qemu/osdep.h +1 -0
@@ -505,6 +505,7 @@ int qemu_open_old(const char *name, int flags, ...);int qemu_open (const char *name,int flags,Error **errp);int qemu_create (const char *name,int flags,mode_t mode,Error **errp);int qemu_close (int fd); +int qemu_link (const char *exist_path1,const char *new_path2);int qemu_unlink (const char *name);#ifndef _WIN32int qemu_dup_flags (int fd,int flags);
include/sysemu/os-win32.h +5 -0
@@ -194,4 +194,9 @@ ssize_t qemu_recv_wrap(int sockfd, void *buf, size_t len, int flags);ssize_t qemu_recvfrom_wrap (int sockfd,void *buf,size_t len,int flags,struct sockaddr *addr,socklen_t *addrlen); +#undef socketpair +#define socketpair qemu_socketpair +int qemu_socketpair (int family,int type,int protocol,int channel[2 ]); + +#endif
tests/crypto-tls-psk-helpers.c +3 -1
@@ -26,6 +26,8 @@#include "crypto-tls-psk-helpers.h" #include "qemu/sockets.h" +#include <glib/gstdio.h> +#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT void test_tls_psk_init (const char *pskfile)
@@ -44,7 +46,7 @@ void test_tls_psk_init(const char *pskfile)void test_tls_psk_cleanup (const char *pskfile) { -unlink (pskfile); +qemu_unlink (pskfile); }#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */
tests/crypto-tls-x509-helpers.c +4 -2
@@ -23,6 +23,8 @@#include "crypto-tls-x509-helpers.h" #include "crypto/init.h" #include "qemu/sockets.h" +#include <glib.h> +#include <glib/gstdio.h> #ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT
@@ -133,7 +135,7 @@ void test_tls_init(const char *keyfile)void test_tls_cleanup (const char *keyfile) {asn1_delete_structure (&pkix_asn1); -unlink (keyfile); +qemu_unlink (keyfile); }/*
@@ -501,7 +503,7 @@ void test_tls_discard_cert(QCryptoTLSTestCertReq *req) req->crt =NULL ;if (getenv ("QEMU_TEST_DEBUG_CERTS" ) ==NULL ) { -unlink (req->filename); +qemu_unlink (req->filename); } }
tests/crypto-tls-x509-helpers.h +3 -2
@@ -24,8 +24,9 @@#include <gnutls/gnutls.h> #include <gnutls/x509.h> -#if !(definedWIN32 ) && \ - defined(CONFIG_TASN1 ) +#include "qemu/osdep.h" + +#if defined(CONFIG_TASN1 )# define QCRYPTO_HAVE_TLS_TEST_SUPPORT #endif
tests/test-crypto-tlscredsx509.c +25 -22
94 lines not on this page · raw message
tests/test-crypto-tlssession.c +36 -28
126 lines not on this page · raw message
tests/test-io-channel-tls.c +28 -21
89 lines not on this page · raw message
util/osdep.c +16 -0
@@ -414,6 +414,22 @@ int qemu_close(int fd)return close (fd); } +/* +* Create a symbolic link file from new_path2 to exist_path1 +*/ +int qemu_link (const char *exist_path1,const char *new_path2) +{ +#if defined(_WIN32) + g_autofree gchar *current_dir = g_get_current_dir(); + g_autofree gchar *full_path = g_build_filename( + current_dir, exist_path1,NULL ); +return CreateSymbolicLinkA (new_path2, full_path, +0 |SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE ) ?0 :-1 ; +#else +return link (exist_path1, new_path2); +#endif +} +/* * Delete a file from the filesystem, unless the filename is /dev/fdset/... *
util/oslib-win32.c +76 -0
79 lines not on this page · raw message
Signature · 1 line
2.28.0.windows.1