static int execute_test_case(int svr_argc, char** svr_argv, int cli_argc, char** cli_argv, int addNoVerify, int addNonBlocking) { #ifdef WOLFSSL_TIRTOS func_args cliArgs = {0}; func_args svrArgs = {0}; cliArgs.argc = cli_argc; cliArgs.argv = cli_argv; svrArgs.argc = svr_argc; svrArgs.argv = svr_argv; #else func_args cliArgs = {cli_argc, cli_argv, 0, NULL, NULL}; func_args svrArgs = {svr_argc, svr_argv, 0, NULL, NULL}; #endif tcp_ready ready; THREAD_TYPE serverThread; char commandLine[MAX_COMMAND_SZ]; char cipherSuite[MAX_SUITE_SZ+1]; int i; size_t added = 0; static int tests = 1; commandLine[0] = '\0'; for (i = 0; i < svr_argc; i++) { added += strlen(svr_argv[i]) + 2; if (added >= MAX_COMMAND_SZ) { printf("server command line too long\n"); break; } strcat(commandLine, svr_argv[i]); strcat(commandLine, flagSep); } if (IsValidCipherSuite(commandLine, cipherSuite) == 0) { #ifdef DEBUG_SUITE_TESTS printf("cipher suite %s not supported in build\n", cipherSuite); #endif return NOT_BUILT_IN; } #ifndef WOLFSSL_ALLOW_SSLV3 if (IsSslVersion(commandLine) == 1) { #ifdef DEBUG_SUITE_TESTS printf("protocol version on line %s is too old\n", commandLine); #endif return VERSION_TOO_OLD; } #endif #ifdef NO_OLD_TLS if (IsOldTlsVersion(commandLine) == 1) { #ifdef DEBUG_SUITE_TESTS printf("protocol version on line %s is too old\n", commandLine); #endif return VERSION_TOO_OLD; } #endif if (addNoVerify) { printf("repeating test with client cert request off\n"); added += 4; /* -d plus space plus terminator */ if (added >= MAX_COMMAND_SZ || svr_argc >= MAX_ARGS) printf("server command line too long\n"); else { svr_argv[svr_argc++] = noVerifyFlag; svrArgs.argc = svr_argc; strcat(commandLine, noVerifyFlag); strcat(commandLine, flagSep); } } if (addNonBlocking) { printf("repeating test with non blocking on\n"); added += 4; /* -N plus terminator */ if (added >= MAX_COMMAND_SZ || svr_argc >= MAX_ARGS) printf("server command line too long\n"); else { svr_argv[svr_argc++] = nonblockFlag; svrArgs.argc = svr_argc; strcat(commandLine, nonblockFlag); strcat(commandLine, flagSep); } } #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS) /* 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'; added = 0; for (i = 0; i < cli_argc; i++) { added += strlen(cli_argv[i]) + 2; if (added >= MAX_COMMAND_SZ) { printf("client command line too long\n"); break; } strcat(commandLine, cli_argv[i]); strcat(commandLine, flagSep); } if (addNonBlocking) { added += 4; /* -N plus space plus terminator */ if (added >= MAX_COMMAND_SZ) printf("client command line too long\n"); else { 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); InitTcpReady(&ready); #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); #endif /* start server */ svrArgs.signal = &ready; start_thread(server_test, &svrArgs, &serverThread); wait_tcp_ready(&svrArgs); #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS) 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); /* verify results */ if (cliArgs.return_code != 0) { printf("client_test failed\n"); exit(EXIT_FAILURE); } join_thread(serverThread); if (svrArgs.return_code != 0) { printf("server_test failed\n"); exit(EXIT_FAILURE); } #ifdef WOLFSSL_TIRTOS fdCloseSession(Task_self()); #endif FreeTcpReady(&ready); return 0; }
static int execute_test_case(int svr_argc, char** svr_argv, int cli_argc, char** cli_argv, int addNoVerify, int addNonBlocking) { func_args cliArgs = {cli_argc, cli_argv, 0, NULL}; func_args svrArgs = {svr_argc, svr_argv, 0, NULL}; tcp_ready ready; THREAD_TYPE serverThread; char commandLine[MAX_COMMAND_SZ]; char cipherSuite[MAX_SUITE_SZ+1]; int i; size_t added = 0; static int tests = 1; commandLine[0] = '\0'; for (i = 0; i < svr_argc; i++) { added += strlen(svr_argv[i]) + 2; if (added >= MAX_COMMAND_SZ) { printf("server command line too long\n"); break; } strcat(commandLine, svr_argv[i]); strcat(commandLine, " "); } if (IsValidCipherSuite(commandLine, cipherSuite) == 0) { #ifdef DEBUG_SUITE_TESTS printf("cipher suite %s not supported in build\n", cipherSuite); #endif return NOT_BUILT_IN; } #ifdef NO_OLD_TLS if (IsOldTlsVersion(commandLine) == 1) { #ifdef DEBUG_SUITE_TESTS printf("protocol version on line %s is too old\n", commandLine); #endif return VERSION_TOO_OLD; } #endif if (addNoVerify) { printf("repeating test with client cert request off\n"); added += 4; /* -d plus space plus terminator */ if (added >= MAX_COMMAND_SZ) printf("server command line too long\n"); else strcat(commandLine, "-d "); } if (addNonBlocking) { printf("repeating test with non blocking on\n"); added += 4; /* -N plus terminator */ if (added >= MAX_COMMAND_SZ) printf("server command line too long\n"); else strcat(commandLine, "-N "); } printf("trying server command line[%d]: %s\n", tests, commandLine); commandLine[0] = '\0'; added = 0; for (i = 0; i < cli_argc; i++) { added += strlen(cli_argv[i]) + 2; if (added >= MAX_COMMAND_SZ) { printf("client command line too long\n"); break; } strcat(commandLine, cli_argv[i]); strcat(commandLine, " "); } if (addNonBlocking) { added += 4; /* -N plus space plus terminator */ if (added >= MAX_COMMAND_SZ) printf("client command line too long\n"); else strcat(commandLine, "-N "); } printf("trying client command line[%d]: %s\n", tests++, commandLine); InitTcpReady(&ready); /* start server */ svrArgs.signal = &ready; start_thread(server_test, &svrArgs, &serverThread); wait_tcp_ready(&svrArgs); /* start client */ client_test(&cliArgs); /* verify results */ if (cliArgs.return_code != 0) { printf("client_test failed\n"); exit(EXIT_FAILURE); } join_thread(serverThread); if (svrArgs.return_code != 0) { printf("server_test failed\n"); exit(EXIT_FAILURE); } FreeTcpReady(&ready); return 0; }