summaryrefslogtreecommitdiff
path: root/extra/yassl/testsuite
diff options
context:
space:
mode:
authorunknown <msvensson@neptunus.(none)>2006-09-26 16:04:16 +0200
committerunknown <msvensson@neptunus.(none)>2006-09-26 16:04:16 +0200
commitf21ac7b6d1e58412fe229408cfb59c4117900449 (patch)
tree45c06319ed6808cdfe54ddf9fa71bf91defe71f5 /extra/yassl/testsuite
parent7bf40904e78b8feabcf3a978cb9981385d7130c4 (diff)
parent62d2cadb629e6e50680ff1b7e8f7496d69b44490 (diff)
downloadmariadb-git-f21ac7b6d1e58412fe229408cfb59c4117900449.tar.gz
Merge neptunus.(none):/home/msvensson/mysql/yassl_import/my50-yassl_import
into neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint extra/yassl/src/Makefile.am: Auto merged extra/yassl/taocrypt/benchmark/Makefile.am: Auto merged extra/yassl/taocrypt/src/Makefile.am: Auto merged extra/yassl/taocrypt/test/Makefile.am: Auto merged extra/yassl/testsuite/Makefile.am: Auto merged
Diffstat (limited to 'extra/yassl/testsuite')
-rw-r--r--extra/yassl/testsuite/Makefile.am2
-rw-r--r--extra/yassl/testsuite/test.hpp49
2 files changed, 43 insertions, 8 deletions
diff --git a/extra/yassl/testsuite/Makefile.am b/extra/yassl/testsuite/Makefile.am
index c433b0081dc..e8abffd6bb0 100644
--- a/extra/yassl/testsuite/Makefile.am
+++ b/extra/yassl/testsuite/Makefile.am
@@ -1,4 +1,4 @@
-INCLUDES = -I../include -I../taocrypt/include -I../mySTL
+INCLUDES = -I../include -I../taocrypt/include -I../taocrypt/mySTL
bin_PROGRAMS = testsuite
testsuite_SOURCES = testsuite.cpp ../taocrypt/test/test.cpp \
../examples/client/client.cpp ../examples/server/server.cpp \
diff --git a/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp
index 482d384d415..1279bc7f9d4 100644
--- a/extra/yassl/testsuite/test.hpp
+++ b/extra/yassl/testsuite/test.hpp
@@ -27,24 +27,27 @@
#endif /* _WIN32 */
-#if !defined(_SOCKLEN_T) && defined(_WIN32)
+#if !defined(_SOCKLEN_T) && (defined(_WIN32) || defined(__NETWARE__))
typedef int socklen_t;
#endif
+// Check type of third arg to accept
+#if defined(__hpux)
// HPUX doesn't use socklent_t for third parameter to accept
-#if !defined(__hpux)
- typedef socklen_t* ACCEPT_THIRD_T;
-#else
typedef int* ACCEPT_THIRD_T;
+#else
+ typedef socklen_t* ACCEPT_THIRD_T;
+#endif
+
+// Check if _POSIX_THREADS should be forced
+#if !defined(_POSIX_THREADS) && (defined(__NETWARE__) || defined(__hpux))
// HPUX does not define _POSIX_THREADS as it's not _fully_ implemented
-#ifndef _POSIX_THREADS
+// Netware supports pthreads but does not announce it
#define _POSIX_THREADS
#endif
-#endif
-
#ifndef _POSIX_THREADS
typedef unsigned int THREAD_RETURN;
@@ -148,6 +151,13 @@ inline void err_sys(const char* msg)
}
+static int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
+{
+ strncpy(passwd, "12345678", sz);
+ return 8;
+}
+
+
inline void store_ca(SSL_CTX* ctx)
{
// To allow testing from serveral dirs
@@ -168,6 +178,7 @@ inline void store_ca(SSL_CTX* ctx)
inline void set_certs(SSL_CTX* ctx)
{
store_ca(ctx);
+ SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
// To allow testing from serveral dirs
if (SSL_CTX_use_certificate_file(ctx, cert, SSL_FILETYPE_PEM)
@@ -193,6 +204,7 @@ inline void set_certs(SSL_CTX* ctx)
inline void set_serverCerts(SSL_CTX* ctx)
{
store_ca(ctx);
+ SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
// To allow testing from serveral dirs
if (SSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM)
@@ -258,13 +270,27 @@ inline void tcp_socket(SOCKET_T& sockfd, sockaddr_in& addr)
}
+inline void tcp_close(SOCKET_T& sockfd)
+{
+#ifdef _WIN32
+ closesocket(sockfd);
+#else
+ close(sockfd);
+#endif
+ sockfd = -1;
+}
+
+
inline void tcp_connect(SOCKET_T& sockfd)
{
sockaddr_in addr;
tcp_socket(sockfd, addr);
if (connect(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0)
+ {
+ tcp_close(sockfd);
err_sys("tcp connect failed");
+ }
}
@@ -274,9 +300,15 @@ inline void tcp_listen(SOCKET_T& sockfd)
tcp_socket(sockfd, addr);
if (bind(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0)
+ {
+ tcp_close(sockfd);
err_sys("tcp bind failed");
+ }
if (listen(sockfd, 3) != 0)
+ {
+ tcp_close(sockfd);
err_sys("tcp listen failed");
+ }
}
@@ -299,7 +331,10 @@ inline void tcp_accept(SOCKET_T& sockfd, int& clientfd, func_args& args)
clientfd = accept(sockfd, (sockaddr*)&client, (ACCEPT_THIRD_T)&client_len);
if (clientfd == -1)
+ {
+ tcp_close(sockfd);
err_sys("tcp accept failed");
+ }
}