/** * Call module tests with verbose reporting. */ int test (void) { int report, count = 0; printf("\nPerforming tests\n"); printf("-----------------------------------------------------------\n"); printf("Crypto module......................................"); if (!(report = crypto_test())) printf("....[OK]\n"); else { printf("[%6d]\n", report); count += 1; } printf("Client module......................................"); if (!(report = client_test())) printf("....[OK]\n"); else { printf("[%6d]\n", report); count += 1; } printf("Parser module......................................"); if (!(report = parser_test())) printf("....[OK]\n"); else { printf("[%6d]\n", report); count += 1; } printf("-----------------------------------------------------------\n"); return count; }
int main(int argc, char** argv) { func_args args; args.argc = argc; args.argv = argv; args.return_code = 0; args.user_auth = NULL; WSTARTTCP(); #ifdef DEBUG_WOLFSSH wolfSSH_Debugging_ON(); #endif wolfSSH_Init(); ChangeToWolfSshRoot(); #ifndef NO_WOLFSSH_CLIENT client_test(&args); #endif wolfSSH_Cleanup(); return args.return_code; }
int main() { static char *argv[] = { "client", "-h", CYASSL_CALLEE_IP, "-p", CYASSL_CALLEE_PORT, "-v", CYASSL_SSL_VER, CYASSL_HTTP_GET } ; static func_args args = { 7 + CYASSL_HTTP_GET_COUNT, argv } ; init_time() ; init_filesystem (); net_initialize() ; osThreadCreate (osThread (tcp_poll), NULL); osDelay(50000) ; /* wait for DHCP */ #if defined(DEBUG_CYASSL) printf("Turning ON Debug message\n") ; CyaSSL_Debugging_ON() ; #endif if(args.argc == 7) printf("Simple SSL/TLS, ") ; else printf("HTTP GET, ") ; printf("Callee IP: %s, Port: %s, Version:%s\n", argv[2], argv[4], argv[6]) ; while(1) { client_test(&args) ; printf("Enter any key to iterate.\n") ; getchar() ; } }
int main(int argc, char** argv) { func_args args; #ifdef HAVE_CAVIUM int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID); if (ret != 0) err_sys("Cavium OpenNitroxDevice failed"); #endif /* HAVE_CAVIUM */ StartTCP(); args.argc = argc; args.argv = argv; CyaSSL_Init(); #if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL) CyaSSL_Debugging_ON(); #endif if (CurrentDir("client") || CurrentDir("build")) ChangeDirBack(2); #ifdef HAVE_STACK_SIZE StackSizeCheck(&args, client_test); #else client_test(&args); #endif CyaSSL_Cleanup(); #ifdef HAVE_CAVIUM CspShutdown(CAVIUM_DEV_ID); #endif return args.return_code; }
void Main_task(uint32_t initial_data) { int ret = 0; char filesystem_name[] = "a:"; char partman_name[] = "pm:"; MQX_FILE_PTR com_handle, sdcard_handle, filesystem_handle, partman_handle; printf("Starting client example... \n"); ret = sdcard_open(&com_handle, &sdcard_handle, &partman_handle, &filesystem_handle, partman_name, filesystem_name); if (ret != 0) { printf("error: sdcard_open(), ret = %d\n", ret); _mqx_exit(1); } printf("SD card installed to %s\n", filesystem_name); setup_ethernet(); setup_clock(); client_test(); ret = sdcard_close(&sdcard_handle, &partman_handle, &filesystem_handle, partman_name, filesystem_name); if (ret != 0) { printf("error: sdcard_close(), ret = %d\n", ret); _mqx_exit(1); } printf("SD card uninstalled.\n"); _mqx_exit(0); }
int main(int argc, char** argv) { func_args args; #ifdef HAVE_CAVIUM int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID); if (ret != 0) err_sys("Cavium OpenNitroxDevice failed"); #endif /* HAVE_CAVIUM */ StartTCP(); args.argc = argc; args.argv = argv; wolfSSL_Init(); #if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_MDK_SHELL) && !defined(STACK_TRAP) wolfSSL_Debugging_ON(); #endif ChangeToWolfRoot(); #ifdef HAVE_STACK_SIZE StackSizeCheck(&args, client_test); #else client_test(&args); #endif wolfSSL_Cleanup(); #ifdef HAVE_CAVIUM CspShutdown(CAVIUM_DEV_ID); #endif return args.return_code; }
void simple_test(func_args* args) { THREAD_TYPE serverThread; func_args svrArgs; char *svrArgv[NUMARGS]; char argc0s[32]; char argc1s[32]; char argc2s[32]; func_args cliArgs; char *cliArgv[NUMARGS]; char argc0c[32]; char argc1c[32]; char argc2c[32]; svrArgv[0] = argc0s; svrArgv[1] = argc1s; svrArgv[2] = argc2s; cliArgv[0] = argc0c; cliArgv[1] = argc1c; cliArgv[2] = argc2c; svrArgs.argc = 1; svrArgs.argv = svrArgv; svrArgs.return_code = 0; cliArgs.argc = 1; cliArgs.argv = cliArgv; cliArgs.return_code = 0; strcpy(svrArgs.argv[0], "SimpleServer"); #if !defined(USE_WINDOWS_API) && !defined(CYASSL_SNIFFER) svrArgs.argc = NUMARGS; strcpy(svrArgs.argv[1], "-p"); strcpy(svrArgs.argv[2], "0"); #endif /* Set the last arg later, when it is known. */ args->return_code = 0; svrArgs.signal = args->signal; start_thread(server_test, &svrArgs, &serverThread); wait_tcp_ready(&svrArgs); /* Setting the actual port number. */ strcpy(cliArgs.argv[0], "SimpleClient"); #ifndef USE_WINDOWS_API cliArgs.argc = NUMARGS; strcpy(cliArgs.argv[1], "-p"); snprintf(cliArgs.argv[2], sizeof(argc2c), "%d", svrArgs.signal->port); #endif client_test(&cliArgs); if (cliArgs.return_code != 0) { args->return_code = cliArgs.return_code; return; } join_thread(serverThread); if (svrArgs.return_code != 0) args->return_code = svrArgs.return_code; }
int main(int argc, char** argv) { func_args args; args.argc = argc; args.argv = argv; client_test(&args); yaSSL_CleanUp(); return args.return_code; }
static void execute_test_case(int svr_argc, char** svr_argv, int cli_argc, char** cli_argv) { 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]; int i; static int tests = 1; commandLine[0] = '\0'; for (i = 0; i < svr_argc; i++) { strcat(commandLine, svr_argv[i]); strcat(commandLine, " "); } printf("trying server command line[%d]: %s\n", tests, commandLine); commandLine[0] = '\0'; for (i = 0; i < cli_argc; i++) { strcat(commandLine, cli_argv[i]); strcat(commandLine, " "); } 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); }
int main(int argc, char** argv) { func_args args; StartTCP(); args.argc = argc; args.argv = argv; InitCyaSSL(); #ifdef DEBUG_CYASSL CyaSSL_Debugging_ON(); #endif client_test(&args); FreeCyaSSL(); return args.return_code; }
int main(int argc, char** argv) { func_args args; StartTCP(); args.argc = argc; args.argv = argv; CyaSSL_Init(); #ifdef DEBUG_CYASSL CyaSSL_Debugging_ON(); #endif if (CurrentDir("client") || CurrentDir("build")) ChangeDirBack(2); client_test(&args); CyaSSL_Cleanup(); return args.return_code; }
int main(int argc, char **argv) { struct timeval start, end, dt; struct timeval t1, t2, dt1, dt2, dt3; if (argc != 4) die("usage: client <server-address> <server-port> <send_buffer_size>"); int count = atoi(argv[3]); send_buffer_size = count * sysconf(_SC_PAGESIZE); recv_buffer_size = send_buffer_size; //send_buffer_size = atoi(argv[3]); //recv_buffer_size = send_buffer_size; gettimeofday(&start, NULL); client_test(argv[1], argv[2]);//set up connection and exchange buffer_key and buffer_addr; gettimeofday(&t1, NULL); //client_write((uint32_t) send_buffer_size); //printf("write once again\n"); client_write_once((uint32_t) send_buffer_size); gettimeofday(&t2, NULL); client_disconnect();//disconnect and free locked memory; gettimeofday(&end, NULL); timersub(&end, &start, &dt); timersub(&t1, &start, &dt1); timersub(&t2, &t1, &dt2); timersub(&end, &t2, &dt3); long job_usec = dt.tv_usec + 1000000 * dt.tv_sec; printf("dt1 = %ld\n", dt1.tv_usec+1000000*dt1.tv_sec); printf("dt2 = %ld\n", dt2.tv_usec+1000000*dt2.tv_sec); printf("dt3 = %ld\n", dt3.tv_usec+1000000*dt3.tv_sec); printf("time used for a whole transfer job_usec=%ld\n", job_usec); return 0; }
void Main_task(uint_32 initial_data) { int ret = 0; _mqx_int error_code, bytes; _mqx_uint param; _mqx_uint sz; MQX_FILE_PTR com_handle, sdcard_handle, filesystem_handle, partman_handle; MQX_FILE_PTR cert_file = NULL; char filesystem_name[] = "a:"; char partman_name[] = "pm:"; const char* fileName = "a:\certs\\client-key.der"; printf("Starting client example... \n"); ret = sdcard_open(&com_handle, &sdcard_handle, &partman_handle, &filesystem_handle, partman_name, filesystem_name); if (ret != 0) { printf("error: sdcard_open(), ret = %d\n", ret); _mqx_exit(1); } printf("SD card installed to %s\n", filesystem_name); setup_ethernet(); client_test(); ret = sdcard_close(&sdcard_handle, &partman_handle, &filesystem_handle, partman_name, filesystem_name); if (ret != 0) { printf("error: sdcard_close(), ret = %d\n", ret); _mqx_exit(1); } printf("SD card uninstalled.\n"); _mqx_exit(0); }
int main(int argc, char** argv) { func_args args; func_args server_args; tcp_ready ready; THREAD_TYPE serverThread; StartTCP(); args.argc = server_args.argc = argc; args.argv = server_args.argv = argv; /* CTaoCrypt test */ ctaocrypt_test(&args); if (args.return_code != 0) return args.return_code; /* Simple CyaSSL client server test */ InitCyaSSL(); InitTcpReady(&ready); server_args.signal = &ready; start_thread(server_test, &server_args, &serverThread); wait_tcp_ready(&server_args); client_test(&args); if (args.return_code != 0) return args.return_code; join_thread(serverThread); if (server_args.return_code != 0) return server_args.return_code; /* Echo input yaSSL client server test */ start_thread(echoserver_test, &server_args, &serverThread); wait_tcp_ready(&server_args); { func_args echo_args; char* myArgv[NUMARGS]; char argc0[32]; char argc1[32]; char argc2[32]; myArgv[0] = argc0; myArgv[1] = argc1; myArgv[2] = argc2; echo_args.argc = NUMARGS; echo_args.argv = myArgv; strcpy(echo_args.argv[0], "echoclient"); strcpy(echo_args.argv[1], "input"); strcpy(echo_args.argv[2], "output"); remove("output"); /* make sure OK */ echoclient_test(&echo_args); if (echo_args.return_code != 0) return echo_args.return_code; #ifdef CYASSL_DTLS wait_tcp_ready(&server_args); #endif /* send quit to echoserver */ echo_args.argc = 2; strcpy(echo_args.argv[1], "quit"); echoclient_test(&echo_args); if (echo_args.return_code != 0) return echo_args.return_code; join_thread(serverThread); if (server_args.return_code != 0) return server_args.return_code; } /* validate output equals input */ { byte input[MD5_DIGEST_SIZE]; byte output[MD5_DIGEST_SIZE]; file_test("input", input); file_test("output", output); if (memcmp(input, output, sizeof(input)) != 0) return -1; } FreeCyaSSL(); FreeTcpReady(&ready); printf("\nAll tests passed!\n"); return 0; }
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; }
int main (int argc, char *argv[] ) { lscp_client_t *pClient; char *pszHost = "localhost"; char szLine[1024]; int cchLine; lscp_status_t ret; #if defined(WIN32) if (WSAStartup(MAKEWORD(1, 1), &_wsaData) != 0) { fprintf(stderr, "lscp_client: WSAStartup failed.\n"); return -1; } #endif if (argc > 1) pszHost = argv[1]; pClient = lscp_client_create(pszHost, SERVER_PORT, client_callback, NULL); if (pClient == NULL) return -1; client_usage(); client_prompt(); while (fgets(szLine, sizeof(szLine) - 3, stdin)) { cchLine = strlen(szLine); while (cchLine > 0 && (szLine[cchLine - 1] == '\n' || szLine[cchLine - 1] == '\r')) cchLine--; szLine[cchLine] = '\0'; if (strcmp(szLine, "exit") == 0 || strcmp(szLine, "quit") == 0) break; else if (strcmp(szLine, "subscribe") == 0) lscp_client_subscribe(pClient); else if (strcmp(szLine, "unsubscribe") == 0) lscp_client_unsubscribe(pClient); else if (strcmp(szLine, "test") == 0) client_test(pClient); else if (cchLine > 0 && strcmp(szLine, "help") != 0) { szLine[cchLine++] = '\r'; szLine[cchLine++] = '\n'; szLine[cchLine] = '\0'; ret = lscp_client_query(pClient, szLine); printf("%s\n(errno = %d)\n", lscp_client_get_result(pClient), lscp_client_get_errno(pClient)); if (ret == LSCP_QUIT) break; } else client_usage(); client_prompt(); } lscp_client_destroy(pClient); #if defined(WIN32) WSACleanup(); #endif 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; }