forked from wolfSSL/wolfssl
adjustments to the example tests for Windows
This commit is contained in:
@@ -47,11 +47,6 @@ char portFlag[] = "-p";
|
|||||||
char flagSep[] = " ";
|
char flagSep[] = " ";
|
||||||
char svrPort[] = "0";
|
char svrPort[] = "0";
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_API
|
|
||||||
#define SNPRINTF _snprintf
|
|
||||||
#else
|
|
||||||
#define SNPRINTF snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NO_OLD_TLS
|
#ifdef NO_OLD_TLS
|
||||||
/* if the protocol version is less than tls 1.2 return 1, else 0 */
|
/* if the protocol version is less than tls 1.2 return 1, else 0 */
|
||||||
@@ -132,7 +127,6 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
int i;
|
int i;
|
||||||
size_t added = 0;
|
size_t added = 0;
|
||||||
static int tests = 1;
|
static int tests = 1;
|
||||||
char portNumber[6];
|
|
||||||
|
|
||||||
commandLine[0] = '\0';
|
commandLine[0] = '\0';
|
||||||
for (i = 0; i < svr_argc; i++) {
|
for (i = 0; i < svr_argc; i++) {
|
||||||
@@ -185,6 +179,7 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
strcat(commandLine, flagSep);
|
strcat(commandLine, flagSep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef USE_WINDOWS_API
|
||||||
/* add port 0 */
|
/* add port 0 */
|
||||||
if (svr_argc + 2 > MAX_ARGS)
|
if (svr_argc + 2 > MAX_ARGS)
|
||||||
printf("cannot add the magic port number flag to server\n");
|
printf("cannot add the magic port number flag to server\n");
|
||||||
@@ -194,6 +189,7 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
svr_argv[svr_argc++] = svrPort;
|
svr_argv[svr_argc++] = svrPort;
|
||||||
svrArgs.argc = svr_argc;
|
svrArgs.argc = svr_argc;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
printf("trying server command line[%d]: %s\n", tests, commandLine);
|
printf("trying server command line[%d]: %s\n", tests, commandLine);
|
||||||
|
|
||||||
commandLine[0] = '\0';
|
commandLine[0] = '\0';
|
||||||
@@ -212,10 +208,10 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
if (added >= MAX_COMMAND_SZ)
|
if (added >= MAX_COMMAND_SZ)
|
||||||
printf("client command line too long\n");
|
printf("client command line too long\n");
|
||||||
else {
|
else {
|
||||||
cli_argv[cli_argc] = nonblockFlag;
|
cli_argv[cli_argc++] = nonblockFlag;
|
||||||
cli_argc++;
|
|
||||||
strcat(commandLine, nonblockFlag);
|
strcat(commandLine, nonblockFlag);
|
||||||
strcat(commandLine, flagSep);
|
strcat(commandLine, flagSep);
|
||||||
|
cliArgs.argc = cli_argc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("trying client command line[%d]: %s\n", tests++, commandLine);
|
printf("trying client command line[%d]: %s\n", tests++, commandLine);
|
||||||
@@ -226,17 +222,20 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
svrArgs.signal = &ready;
|
svrArgs.signal = &ready;
|
||||||
start_thread(server_test, &svrArgs, &serverThread);
|
start_thread(server_test, &svrArgs, &serverThread);
|
||||||
wait_tcp_ready(&svrArgs);
|
wait_tcp_ready(&svrArgs);
|
||||||
|
#ifndef USE_WINDOWS_API
|
||||||
if (ready.port != 0)
|
if (ready.port != 0)
|
||||||
{
|
{
|
||||||
if (cli_argc + 2 > MAX_ARGS)
|
if (cli_argc + 2 > MAX_ARGS)
|
||||||
printf("cannot add the magic port number flag to client\n");
|
printf("cannot add the magic port number flag to client\n");
|
||||||
else {
|
else {
|
||||||
SNPRINTF(portNumber, sizeof(portNumber), "%d", ready.port);
|
char portNumber[8];
|
||||||
|
snprintf(portNumber, sizeof(portNumber), "%d", ready.port);
|
||||||
cli_argv[cli_argc++] = portFlag;
|
cli_argv[cli_argc++] = portFlag;
|
||||||
cli_argv[cli_argc++] = portNumber;
|
cli_argv[cli_argc++] = portNumber;
|
||||||
cliArgs.argc = cli_argc;
|
cliArgs.argc = cli_argc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* start client */
|
/* start client */
|
||||||
client_test(&cliArgs);
|
client_test(&cliArgs);
|
||||||
|
|
||||||
|
@@ -39,12 +39,6 @@
|
|||||||
#include "examples/server/server.h"
|
#include "examples/server/server.h"
|
||||||
#include "ctaocrypt/test/test.h"
|
#include "ctaocrypt/test/test.h"
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_API
|
|
||||||
#define SNPRINTF _snprintf
|
|
||||||
#else
|
|
||||||
#define SNPRINTF snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void client_test(void*);
|
void client_test(void*);
|
||||||
|
|
||||||
void file_test(const char* file, byte* hash);
|
void file_test(const char* file, byte* hash);
|
||||||
@@ -211,7 +205,7 @@ void simple_test(func_args* args)
|
|||||||
#ifndef USE_WINDOWS_API
|
#ifndef USE_WINDOWS_API
|
||||||
cliArgs.argc = NUMARGS;
|
cliArgs.argc = NUMARGS;
|
||||||
strcpy(cliArgs.argv[1], "-p");
|
strcpy(cliArgs.argv[1], "-p");
|
||||||
SNPRINTF(cliArgs.argv[2], sizeof(argc2c), "%d", svrArgs.signal->port);
|
snprintf(cliArgs.argv[2], sizeof(argc2c), "%d", svrArgs.signal->port);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
client_test(&cliArgs);
|
client_test(&cliArgs);
|
||||||
|
Reference in New Issue
Block a user