Skip to content

Commit d751029

Browse files
Merge pull request #6945 from gojimmypi/PR-goto-alternate
introduce WARNING_OUT, when goto is not a hard error during tests
2 parents 8921a72 + e58fafc commit d751029

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const byte const_byte_array[] = "A+Gd\0\0\0";
133133
#include <time.h>
134134
#include <sys/time.h>
135135
#include <esp_log.h>
136+
#include <wolfcrypt/port/Espressif/esp32-crypt.h> /* */
136137
#elif defined(WOLFSSL_ZEPHYR)
137138
#include <stdio.h>
138139

@@ -716,8 +717,25 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_eax_test(void);
716717
/* General big buffer size for many tests. */
717718
#define FOURK_BUF 4096
718719

720+
#if defined(WOLFSSL_ESPIDF_ERROR_PAUSE)
721+
/* When defined, pause at error condition rather than exit with error. */
722+
#define ERROR_OUT(err, eLabel) \
723+
do { \
724+
ret = (err); \
725+
esp_ShowExtendedSystemInfo(); \
726+
ESP_LOGE("wolfcrypt_test", "ESP Error! ret = %d ", err); \
727+
while (1) { \
728+
vTaskDelay(60000); \
729+
} \
730+
/* Just to appease compiler, don't actually go to eLabel */ \
731+
goto eLabel; \
732+
} while (0)
733+
#else
734+
#define ERROR_OUT(err, eLabel) do { ret = (err); goto eLabel; } while (0)
735+
#endif
719736

720-
#define ERROR_OUT(err, eLabel) do { ret = (err); goto eLabel; } while (0)
737+
/* Not all unexpected conditions are actually errors .*/
738+
#define WARNING_OUT(err, eLabel) do { ret = (err); goto eLabel; } while (0)
721739

722740
static void render_error_message(const char* msg, wc_test_ret_t es)
723741
{
@@ -1903,7 +1921,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
19031921
#endif
19041922
{
19051923
wc_test_ret_t ret;
1906-
func_args args;
1924+
func_args args = { 0 };
19071925
#if defined(WOLFSSL_ESPIDF) || defined(WOLFSSL_SE050)
19081926
/* set dummy wallclock time. */
19091927
struct timeval utctime;
@@ -2005,16 +2023,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
20052023
while (1);
20062024
#endif
20072025

2008-
#ifdef WOLFSSL_ESPIDF
2009-
/* ESP_LOGI to print takes up a lot less memory than printf */
2010-
ESP_LOGI("wolfcrypt_test", "Exiting main with return code: % d\n", args.return_code);
2011-
#endif
2012-
2013-
/* everything else will use printf */
2014-
#if !defined(WOLFSSL_ESPIDF)
2015-
/* gate this for target platforms wishing to avoid printf reference */
20162026
printf("Exiting main with return code: %ld\n", (long int)args.return_code);
2017-
#endif
20182027

20192028
return args.return_code;
20202029
} /* wolfcrypt_test_main or wolf_test_task */
@@ -26770,7 +26779,8 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
2677026779

2677126780
/* only perform the below tests if the key size matches */
2677226781
if (dp == NULL && keySize > 0 && wc_ecc_size(userA) != keySize)
26773-
ERROR_OUT(ECC_CURVE_OID_E, done);
26782+
/* Not an error, just not a key size match */
26783+
WARNING_OUT(ECC_CURVE_OID_E, done);
2677426784

2677526785
#ifdef HAVE_ECC_DHE
2677626786
#if defined(ECC_TIMING_RESISTANT) && (!defined(HAVE_FIPS) || \
@@ -40550,7 +40560,7 @@ static int myDecryptionFunc(PKCS7* pkcs7, int encryptOID, byte* iv, int ivSz,
4055040560
#ifdef WOLFSSL_AES_256
4055140561
case AES256CBCb:
4055240562
if ((keySz != 32 ) || (ivSz != AES_BLOCK_SIZE))
40553-
ERROR_OUT(BAD_FUNC_ARG, out);
40563+
WARNING_OUT(BAD_FUNC_ARG, out);
4055440564
break;
4055540565
#endif
4055640566
#ifdef WOLFSSL_AES_128

0 commit comments

Comments
 (0)