testsuite.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /* testsuite.c
  2. *
  3. * Copyright (C) 2006-2023 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <wolfssl/wolfcrypt/settings.h>
  25. #include <wolfssl/wolfcrypt/types.h>
  26. #include <wolfssl/ssl.h>
  27. #include <wolfssl/test.h>
  28. #include <wolfcrypt/test/test.h>
  29. #ifndef SINGLE_THREADED
  30. #ifdef OPENSSL_EXTRA
  31. #include <wolfssl/openssl/ssl.h>
  32. #endif
  33. #include <wolfssl/wolfcrypt/sha256.h>
  34. #include <wolfssl/wolfcrypt/ecc.h>
  35. #include <examples/echoclient/echoclient.h>
  36. #include <examples/echoserver/echoserver.h>
  37. #include <examples/server/server.h>
  38. #include <examples/client/client.h>
  39. #include "tests/utils.h"
  40. #ifndef NO_SHA256
  41. void file_test(const char* file, byte* check);
  42. #endif
  43. #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT)
  44. #ifdef HAVE_STACK_SIZE
  45. static THREAD_RETURN simple_test(func_args *args);
  46. #else
  47. static void simple_test(func_args *args);
  48. #endif
  49. static int test_tls(func_args* server_args);
  50. #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
  51. defined(HAVE_CRL) && defined(HAVE_CRL_MONITOR)
  52. static int test_crl_monitor(void);
  53. #endif
  54. static void show_ciphers(void);
  55. static void cleanup_output(void);
  56. static int validate_cleanup_output(void);
  57. enum {
  58. NUMARGS = 3
  59. };
  60. static const char *outputName;
  61. #endif
  62. int myoptind = 0;
  63. char* myoptarg = NULL;
  64. #ifndef NO_TESTSUITE_MAIN_DRIVER
  65. static int testsuite_test(int argc, char** argv);
  66. int main(int argc, char** argv)
  67. {
  68. return testsuite_test(argc, argv);
  69. }
  70. #endif /* NO_TESTSUITE_MAIN_DRIVER */
  71. #ifdef HAVE_STACK_SIZE
  72. /* Wrap TLS echo client to free thread locals. */
  73. static void *echoclient_test_wrapper(void* args) {
  74. echoclient_test(args);
  75. #if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS)
  76. wc_ecc_fp_free(); /* free per thread cache */
  77. #endif
  78. return (void *)0;
  79. }
  80. #endif
  81. int testsuite_test(int argc, char** argv)
  82. {
  83. #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
  84. (!defined(WOLF_CRYPTO_CB_ONLY_RSA) && !defined(WOLF_CRYPTO_CB_ONLY_ECC))
  85. func_args server_args;
  86. tcp_ready ready;
  87. #if !defined(NETOS)
  88. THREAD_TYPE serverThread;
  89. int ret;
  90. #endif
  91. #ifndef USE_WINDOWS_API
  92. const char *tempDir = NULL;
  93. char tempName[128];
  94. int tempName_len;
  95. int tempName_Xnum;
  96. #else
  97. char tempName[] = "fnXXXXXX";
  98. const int tempName_len = 8;
  99. const int tempName_Xnum = 6;
  100. #endif
  101. #ifdef HAVE_STACK_SIZE
  102. void *serverThreadStackContext = NULL;
  103. #endif
  104. #ifndef USE_WINDOWS_API
  105. #ifdef XGETENV
  106. tempDir = XGETENV("TMPDIR");
  107. if (tempDir == NULL)
  108. #endif
  109. {
  110. tempDir = "/tmp";
  111. }
  112. XSTRLCPY(tempName, tempDir, sizeof(tempName));
  113. XSTRLCAT(tempName, "/testsuite-output-XXXXXX", sizeof(tempName));
  114. tempName_len = (int)XSTRLEN(tempName);
  115. tempName_Xnum = 6;
  116. #endif /* !USE_WINDOWS_API */
  117. #ifdef HAVE_WNR
  118. if (wc_InitNetRandom(wnrConfig, NULL, 5000) != 0) {
  119. err_sys("Whitewood netRandom global config failed");
  120. return -1237;
  121. }
  122. #endif /* HAVE_WNR */
  123. StartTCP();
  124. server_args.argc = argc;
  125. server_args.argv = argv;
  126. wolfSSL_Init();
  127. #if defined(DEBUG_WOLFSSL) && !defined(HAVE_VALGRIND)
  128. wolfSSL_Debugging_ON();
  129. #endif
  130. #if !defined(WOLFSSL_TIRTOS)
  131. ChangeToWolfRoot();
  132. #endif
  133. #ifdef WOLFSSL_TIRTOS
  134. fdOpenSession(Task_self());
  135. #endif
  136. server_args.signal = &ready;
  137. InitTcpReady(&ready);
  138. #ifndef NO_CRYPT_TEST
  139. /* wc_ test */
  140. #ifdef HAVE_STACK_SIZE
  141. StackSizeCheck(&server_args, wolfcrypt_test);
  142. #else
  143. wolfcrypt_test(&server_args);
  144. #endif
  145. if (server_args.return_code != 0) return server_args.return_code;
  146. #endif
  147. /* Simple wolfSSL client server test */
  148. #ifdef HAVE_STACK_SIZE
  149. StackSizeCheck(&server_args, (THREAD_RETURN (*)(void *))simple_test);
  150. #else
  151. simple_test(&server_args);
  152. #endif
  153. if (server_args.return_code != 0) return server_args.return_code;
  154. #if !defined(NETOS)
  155. /* Echo input wolfSSL client server test */
  156. #ifdef HAVE_STACK_SIZE
  157. StackSizeCheck_launch(&server_args, echoserver_test, &serverThread,
  158. &serverThreadStackContext);
  159. #else
  160. start_thread(echoserver_test, &server_args, &serverThread);
  161. #endif
  162. /* Create unique file name */
  163. outputName = mymktemp(tempName, tempName_len, tempName_Xnum);
  164. if (outputName == NULL) {
  165. printf("Could not create unique file name");
  166. return EXIT_FAILURE;
  167. }
  168. ret = test_tls(&server_args);
  169. if (ret != 0) {
  170. cleanup_output();
  171. return ret;
  172. }
  173. /* Server won't quit unless TLS test has worked. */
  174. #ifdef HAVE_STACK_SIZE
  175. fputs("reaping echoserver_test: ", stdout);
  176. StackSizeCheck_reap(serverThread, serverThreadStackContext);
  177. #else
  178. join_thread(serverThread);
  179. #endif
  180. if (server_args.return_code != 0) {
  181. cleanup_output();
  182. return server_args.return_code;
  183. }
  184. #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
  185. defined(HAVE_CRL) && defined(HAVE_CRL_MONITOR)
  186. ret = test_crl_monitor();
  187. if (ret != 0) {
  188. cleanup_output();
  189. return ret;
  190. }
  191. #endif
  192. #endif /* !NETOS */
  193. show_ciphers();
  194. #if !defined(NETOS)
  195. ret = validate_cleanup_output();
  196. if (ret != 0)
  197. return EXIT_FAILURE;
  198. #endif
  199. wolfSSL_Cleanup();
  200. FreeTcpReady(&ready);
  201. #ifdef WOLFSSL_TIRTOS
  202. fdCloseSession(Task_self());
  203. #endif
  204. #ifdef HAVE_WNR
  205. if (wc_FreeNetRandom() < 0)
  206. err_sys("Failed to free netRandom context");
  207. #endif /* HAVE_WNR */
  208. printf("\nAll tests passed!\n");
  209. #else
  210. (void)argc;
  211. (void)argv;
  212. #endif /* !NO_WOLFSSL_SERVER && !NO_WOLFSSL_CLIENT */
  213. return EXIT_SUCCESS;
  214. }
  215. #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
  216. defined(HAVE_CRL) && defined(HAVE_CRL_MONITOR)
  217. #define CRL_MONITOR_TEST_ROUNDS 6
  218. #define CRL_MONITOR_REM_FILE_ATTEMPTS 20
  219. static int test_crl_monitor(void)
  220. {
  221. func_args server_args;
  222. func_args client_args;
  223. THREAD_TYPE serverThread;
  224. tcp_ready ready;
  225. char buf[128];
  226. char tmpDir[16];
  227. char rounds[4];
  228. char portNum[8];
  229. const char* serverArgv[] = {
  230. "testsuite",
  231. "-A", "certs/ca-cert.pem",
  232. "--crl-dir", tmpDir,
  233. "-C", rounds,
  234. "--quieter",
  235. "-x",
  236. "-p", "0"
  237. };
  238. const char* clientArgv[] = {
  239. "testsuite",
  240. "-C",
  241. "-c", "certs/server-cert.pem",
  242. "-k", "certs/server-key.pem",
  243. "--quieter",
  244. "-H", "exitWithRet",
  245. "-p", portNum
  246. };
  247. int ret = -1;
  248. int i = -1, j;
  249. printf("\nRunning CRL monitor test\n");
  250. sprintf(rounds, "%d", CRL_MONITOR_TEST_ROUNDS);
  251. XMEMSET(&server_args, 0, sizeof(func_args));
  252. XMEMSET(&client_args, 0, sizeof(func_args));
  253. /* Create temp dir */
  254. if (create_tmp_dir(tmpDir, sizeof(tmpDir) - 1) == NULL) {
  255. fprintf(stderr, "Failed to create tmp dir");
  256. goto cleanup;
  257. }
  258. server_args.argv = (char**)serverArgv;
  259. server_args.argc = sizeof(serverArgv) / sizeof(*serverArgv);
  260. client_args.signal = server_args.signal = &ready;
  261. client_args.argv = (char**)clientArgv;
  262. client_args.argc = sizeof(clientArgv) / sizeof(*clientArgv);
  263. InitTcpReady(&ready);
  264. start_thread(server_test, &server_args, &serverThread);
  265. wait_tcp_ready(&server_args);
  266. sprintf(portNum, "%d", server_args.signal->port);
  267. for (i = 0; i < CRL_MONITOR_TEST_ROUNDS; i++) {
  268. int expectFail;
  269. if (i % 2 == 0) {
  270. /* succeed on even rounds */
  271. sprintf(buf, "%s/%s", tmpDir, "crl.pem");
  272. if (STAGE_FILE("certs/crl/crl.pem", buf) != 0) {
  273. fprintf(stderr, "[%d] Failed to copy file to %s\n", i, buf);
  274. goto cleanup;
  275. }
  276. sprintf(buf, "%s/%s", tmpDir, "crl.revoked");
  277. /* The monitor can be holding the file handle and this will cause
  278. * the remove call to fail. Let's give the monitor a some time to
  279. * finish up. */
  280. for (j = 0; j < CRL_MONITOR_REM_FILE_ATTEMPTS; j++) {
  281. /* i == 0 since there is nothing to delete in the first round */
  282. if (i == 0 || rem_file(buf) == 0)
  283. break;
  284. XSLEEP_MS(100);
  285. }
  286. if (j == CRL_MONITOR_REM_FILE_ATTEMPTS) {
  287. fprintf(stderr, "[%d] Failed to remove file %s\n", i, buf);
  288. goto cleanup;
  289. }
  290. expectFail = 0;
  291. }
  292. else {
  293. /* fail on odd rounds */
  294. sprintf(buf, "%s/%s", tmpDir, "crl.revoked");
  295. if (STAGE_FILE("certs/crl/crl.revoked", buf) != 0) {
  296. fprintf(stderr, "[%d] Failed to copy file to %s\n", i, buf);
  297. goto cleanup;
  298. }
  299. sprintf(buf, "%s/%s", tmpDir, "crl.pem");
  300. /* The monitor can be holding the file handle and this will cause
  301. * the remove call to fail. Let's give the monitor a some time to
  302. * finish up. */
  303. for (j = 0; j < CRL_MONITOR_REM_FILE_ATTEMPTS; j++) {
  304. if (rem_file(buf) == 0)
  305. break;
  306. XSLEEP_MS(100);
  307. }
  308. if (j == CRL_MONITOR_REM_FILE_ATTEMPTS) {
  309. fprintf(stderr, "[%d] Failed to remove file %s\n", i, buf);
  310. goto cleanup;
  311. }
  312. expectFail = 1;
  313. }
  314. /* Give server a moment to register the file change */
  315. XSLEEP_MS(100);
  316. client_args.return_code = 0;
  317. client_test(&client_args);
  318. if (!expectFail) {
  319. if (client_args.return_code != 0) {
  320. fprintf(stderr, "[%d] Incorrect return %d\n", i,
  321. client_args.return_code);
  322. goto cleanup;
  323. }
  324. }
  325. else {
  326. if (client_args.return_code == 0) {
  327. fprintf(stderr, "[%d] Expected failure\n", i);
  328. goto cleanup;
  329. }
  330. }
  331. }
  332. join_thread(serverThread);
  333. ret = 0;
  334. cleanup:
  335. if (ret != 0 && i >= 0)
  336. fprintf(stderr, "test_crl_monitor failed on iteration %d\n", i);
  337. sprintf(buf, "%s/%s", tmpDir, "crl.pem");
  338. rem_file(buf);
  339. sprintf(buf, "%s/%s", tmpDir, "crl.revoked");
  340. rem_file(buf);
  341. (void)rem_dir(tmpDir);
  342. return ret;
  343. }
  344. #endif
  345. #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
  346. (!defined(WOLF_CRYPTO_CB_ONLY_RSA) && !defined(WOLF_CRYPTO_CB_ONLY_ECC))
  347. /* Perform a basic TLS handshake.
  348. *
  349. * First connection to echo a file.
  350. * Second to tell TLS server to quit.
  351. *
  352. * @param [in,out] server_args Object sent to server thread.
  353. * @return 0 on success.
  354. * @return echoclient error return code on failure.
  355. */
  356. static int test_tls(func_args* server_args)
  357. {
  358. func_args echo_args;
  359. char* myArgv[NUMARGS];
  360. char arg[3][128];
  361. printf("\nRunning TLS test\n");
  362. /* Set up command line arguments for echoclient to send input file
  363. * and write echoed data to temporary output file. */
  364. myArgv[0] = arg[0];
  365. myArgv[1] = arg[1];
  366. myArgv[2] = arg[2];
  367. echo_args.argc = 3;
  368. echo_args.argv = myArgv;
  369. XSTRLCPY(arg[0], "testsuite", sizeof(arg[0]));
  370. XSTRLCPY(arg[1], "input", sizeof(arg[1]));
  371. XSTRLCPY(arg[2], outputName, sizeof(arg[2]));
  372. /* Share the signal, it has the new port number in it. */
  373. echo_args.signal = server_args->signal;
  374. /* Ready to execute client - wait for server to be ready. */
  375. wait_tcp_ready(server_args);
  376. /* Do a client TLS connection. */
  377. #ifdef HAVE_STACK_SIZE
  378. fputs("echoclient_test #1: ", stdout);
  379. StackSizeCheck(&echo_args, echoclient_test_wrapper);
  380. #else
  381. echoclient_test(&echo_args);
  382. #endif
  383. if (echo_args.return_code != 0)
  384. return echo_args.return_code;
  385. #ifdef WOLFSSL_DTLS
  386. /* Ensure server is ready for UDP data. */
  387. wait_tcp_ready(server_args);
  388. #endif
  389. /* Next client connection - send quit to shutdown server. */
  390. echo_args.argc = 2;
  391. XSTRLCPY(arg[1], "quit", sizeof(arg[1]));
  392. /* Do a client TLS connection. */
  393. #ifdef HAVE_STACK_SIZE
  394. fputs("echoclient_test #2: ", stdout);
  395. StackSizeCheck(&echo_args, echoclient_test_wrapper);
  396. #else
  397. echoclient_test(&echo_args);
  398. #endif
  399. if (echo_args.return_code != 0)
  400. return echo_args.return_code;
  401. return 0;
  402. }
  403. /* Show cipher suites available. */
  404. static void show_ciphers(void)
  405. {
  406. char ciphers[WOLFSSL_CIPHER_LIST_MAX_SIZE];
  407. XMEMSET(ciphers, 0, sizeof(ciphers));
  408. wolfSSL_get_ciphers(ciphers, sizeof(ciphers)-1);
  409. printf("ciphers = %s\n", ciphers);
  410. }
  411. /* Cleanup temporary output file. */
  412. static void cleanup_output(void)
  413. {
  414. remove(outputName);
  415. }
  416. /* Validate output equals input using a hash. Remove temporary output file.
  417. *
  418. * @return 0 on success.
  419. * @return 1 on failure.
  420. */
  421. static int validate_cleanup_output(void)
  422. {
  423. #ifndef NO_SHA256
  424. byte input[WC_SHA256_DIGEST_SIZE];
  425. byte output[WC_SHA256_DIGEST_SIZE];
  426. file_test("input", input);
  427. file_test(outputName, output);
  428. #endif
  429. cleanup_output();
  430. #ifndef NO_SHA256
  431. if (memcmp(input, output, sizeof(input)) != 0)
  432. return 1;
  433. #endif
  434. return 0;
  435. }
  436. /* Simple server.
  437. *
  438. * @param [in] args Object for server data in thread.
  439. * @return Return code.
  440. */
  441. #ifdef HAVE_STACK_SIZE
  442. static THREAD_RETURN simple_test(func_args* args)
  443. #else
  444. static void simple_test(func_args* args)
  445. #endif
  446. {
  447. THREAD_TYPE serverThread;
  448. int i;
  449. func_args svrArgs;
  450. char *svrArgv[9];
  451. char argvs[9][32];
  452. func_args cliArgs;
  453. char *cliArgv[NUMARGS];
  454. char argvc[3][32];
  455. printf("\nRunning simple test\n");
  456. for (i = 0; i < 9; i++)
  457. svrArgv[i] = argvs[i];
  458. for (i = 0; i < 3; i++)
  459. cliArgv[i] = argvc[i];
  460. XSTRLCPY(argvs[0], "SimpleServer", sizeof(argvs[0]));
  461. svrArgs.argc = 1;
  462. svrArgs.argv = svrArgv;
  463. svrArgs.return_code = 0;
  464. #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_SNIFFER) && \
  465. !defined(WOLFSSL_TIRTOS)
  466. XSTRLCPY(argvs[svrArgs.argc++], "-p", sizeof(argvs[svrArgs.argc]));
  467. XSTRLCPY(argvs[svrArgs.argc++], "0", sizeof(argvs[svrArgs.argc]));
  468. #endif
  469. /* Set the last arg later, when it is known. */
  470. args->return_code = 0;
  471. svrArgs.signal = args->signal;
  472. start_thread(server_test, &svrArgs, &serverThread);
  473. wait_tcp_ready(&svrArgs);
  474. /* Setting the actual port number. */
  475. XSTRLCPY(argvc[0], "SimpleClient", sizeof(argvc[0]));
  476. cliArgs.argv = cliArgv;
  477. cliArgs.return_code = 0;
  478. #ifndef USE_WINDOWS_API
  479. cliArgs.argc = NUMARGS;
  480. XSTRLCPY(argvc[1], "-p", sizeof(argvc[1]));
  481. (void)snprintf(argvc[2], sizeof(argvc[2]), "%d", (int)svrArgs.signal->port);
  482. #else
  483. cliArgs.argc = 1;
  484. #endif
  485. client_test(&cliArgs);
  486. if (cliArgs.return_code != 0) {
  487. args->return_code = cliArgs.return_code;
  488. #ifdef HAVE_STACK_SIZE
  489. return (THREAD_RETURN)0;
  490. #else
  491. return;
  492. #endif
  493. }
  494. join_thread(serverThread);
  495. if (svrArgs.return_code != 0) args->return_code = svrArgs.return_code;
  496. #ifdef HAVE_STACK_SIZE
  497. return (THREAD_RETURN)0;
  498. #endif
  499. }
  500. #endif /* !NO_WOLFSSL_SERVER && !NO_WOLFSSL_CLIENT */
  501. #ifndef NO_SHA256
  502. /* Create SHA-256 hash of the file based on filename.
  503. *
  504. * @param [in] file Name of file.
  505. * @param [out] check Buffer to hold SHA-256 hash.
  506. */
  507. void file_test(const char* file, byte* check)
  508. {
  509. FILE* f;
  510. int i = 0, j, ret;
  511. wc_Sha256 sha256;
  512. byte buf[1024];
  513. byte shasum[WC_SHA256_DIGEST_SIZE];
  514. ret = wc_InitSha256(&sha256);
  515. if (ret != 0) {
  516. printf("Can't wc_InitSha256 %d\n", ret);
  517. return;
  518. }
  519. if( !( f = fopen( file, "rb" ) )) {
  520. printf("Can't open %s\n", file);
  521. return;
  522. }
  523. while( ( i = (int)fread(buf, 1, sizeof(buf), f )) > 0 ) {
  524. if (ferror(f)) {
  525. printf("I/O error reading %s\n", file);
  526. fclose(f);
  527. return;
  528. }
  529. ret = wc_Sha256Update(&sha256, buf, (word32)i);
  530. if (ret != 0) {
  531. printf("Can't wc_Sha256Update %d\n", ret);
  532. fclose(f);
  533. return;
  534. }
  535. if (feof(f))
  536. break;
  537. }
  538. ret = wc_Sha256Final(&sha256, shasum);
  539. wc_Sha256Free(&sha256);
  540. if (ret != 0) {
  541. printf("Can't wc_Sha256Final %d\n", ret);
  542. fclose(f);
  543. return;
  544. }
  545. XMEMCPY(check, shasum, sizeof(shasum));
  546. for(j = 0; j < WC_SHA256_DIGEST_SIZE; ++j )
  547. printf( "%02x", shasum[j] );
  548. printf(" %s\n", file);
  549. fclose(f);
  550. }
  551. #endif
  552. #else /* SINGLE_THREADED */
  553. int myoptind = 0;
  554. char* myoptarg = NULL;
  555. int main(int argc, char** argv)
  556. {
  557. func_args wolfcrypt_test_args;
  558. wolfcrypt_test_args.argc = argc;
  559. wolfcrypt_test_args.argv = argv;
  560. wolfSSL_Init();
  561. ChangeToWolfRoot();
  562. /* No TLS - only doing cryptographic algorithm testing. */
  563. wolfcrypt_test(&wolfcrypt_test_args);
  564. if (wolfcrypt_test_args.return_code != 0)
  565. return wolfcrypt_test_args.return_code;
  566. wolfSSL_Cleanup();
  567. printf("\nAll tests passed!\n");
  568. return EXIT_SUCCESS;
  569. }
  570. #endif /* SINGLE_THREADED */