adjustments to the example tests for Windows

This commit is contained in:
John Safranek 2013-03-27 10:22:50 -07:00
parent 7d287a6ba9
commit 547872683f
2 changed files with 27 additions and 34 deletions

View File

@ -47,11 +47,6 @@ char portFlag[] = "-p";
char flagSep[] = " ";
char svrPort[] = "0";
#ifdef USE_WINDOWS_API
#define SNPRINTF _snprintf
#else
#define SNPRINTF snprintf
#endif
#ifdef NO_OLD_TLS
/* 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;
size_t added = 0;
static int tests = 1;
char portNumber[6];
commandLine[0] = '\0';
for (i = 0; i < svr_argc; i++) {
@ -185,15 +179,17 @@ static int execute_test_case(int svr_argc, char** svr_argv,
strcat(commandLine, flagSep);
}
}
/* add port 0 */
if (svr_argc + 2 > MAX_ARGS)
printf("cannot add the magic port number flag to server\n");
else
{
svr_argv[svr_argc++] = portFlag;
svr_argv[svr_argc++] = svrPort;
svrArgs.argc = svr_argc;
}
#ifndef USE_WINDOWS_API
/* add port 0 */
if (svr_argc + 2 > MAX_ARGS)
printf("cannot add the magic port number flag to server\n");
else
{
svr_argv[svr_argc++] = portFlag;
svr_argv[svr_argc++] = svrPort;
svrArgs.argc = svr_argc;
}
#endif
printf("trying server command line[%d]: %s\n", tests, commandLine);
commandLine[0] = '\0';
@ -212,10 +208,10 @@ static int execute_test_case(int svr_argc, char** svr_argv,
if (added >= MAX_COMMAND_SZ)
printf("client command line too long\n");
else {
cli_argv[cli_argc] = nonblockFlag;
cli_argc++;
cli_argv[cli_argc++] = nonblockFlag;
strcat(commandLine, nonblockFlag);
strcat(commandLine, flagSep);
cliArgs.argc = cli_argc;
}
}
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;
start_thread(server_test, &svrArgs, &serverThread);
wait_tcp_ready(&svrArgs);
if (ready.port != 0)
{
if (cli_argc + 2 > MAX_ARGS)
printf("cannot add the magic port number flag to client\n");
else {
SNPRINTF(portNumber, sizeof(portNumber), "%d", ready.port);
cli_argv[cli_argc++] = portFlag;
cli_argv[cli_argc++] = portNumber;
cliArgs.argc = cli_argc;
#ifndef USE_WINDOWS_API
if (ready.port != 0)
{
if (cli_argc + 2 > MAX_ARGS)
printf("cannot add the magic port number flag to client\n");
else {
char portNumber[8];
snprintf(portNumber, sizeof(portNumber), "%d", ready.port);
cli_argv[cli_argc++] = portFlag;
cli_argv[cli_argc++] = portNumber;
cliArgs.argc = cli_argc;
}
}
}
#endif
/* start client */
client_test(&cliArgs);

View File

@ -39,12 +39,6 @@
#include "examples/server/server.h"
#include "ctaocrypt/test/test.h"
#ifdef USE_WINDOWS_API
#define SNPRINTF _snprintf
#else
#define SNPRINTF snprintf
#endif
void client_test(void*);
void file_test(const char* file, byte* hash);
@ -211,7 +205,7 @@ void simple_test(func_args* args)
#ifndef USE_WINDOWS_API
cliArgs.argc = NUMARGS;
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
client_test(&cliArgs);