Merge pull request #3167 from dgarske/test_fixups

Fixes for `mutex_test` and API unit test `derSz`
This commit is contained in:
toddouska
2020-07-28 16:45:58 -07:00
committed by GitHub
3 changed files with 9 additions and 6 deletions

View File

@ -131,7 +131,7 @@
#endif #endif
#endif #endif
#if !defined(DER_SZ) #if !defined(DER_SZ)
#define DER_SZ (keySz * 2 + 1) #define DER_SZ(ks) (ks * 2 + 1)
#endif #endif
#endif #endif
#ifndef NO_ASN #ifndef NO_ASN
@ -20018,9 +20018,9 @@ static int test_wc_ecc_pointFns (void)
ecc_point* cpypt = NULL; ecc_point* cpypt = NULL;
int idx = 0; int idx = 0;
int keySz = KEY32; int keySz = KEY32;
byte der[DER_SZ]; byte der[DER_SZ(KEY32)];
word32 derlenChk = 0; word32 derlenChk = 0;
word32 derSz = (int)sizeof(der); word32 derSz = DER_SZ(KEY32);
/* Init stack variables. */ /* Init stack variables. */
XMEMSET(der, 0, derSz); XMEMSET(der, 0, derSz);

View File

@ -28493,12 +28493,15 @@ int mutex_test(void)
XFREE(mm, NULL, DYNAMIC_TYPE_MUTEX); XFREE(mm, NULL, DYNAMIC_TYPE_MUTEX);
#endif #endif
/* Can optionally enable advanced pthread tests using "ENABLE_PTHREAD_LOCKFREE_TESTS" */
#ifdef WOLFSSL_PTHREADS #ifdef WOLFSSL_PTHREADS
if (wc_InitMutex(&m) != 0) if (wc_InitMutex(&m) != 0)
return -12701; return -12701;
if (wc_LockMutex(&m) != 0) if (wc_LockMutex(&m) != 0)
return -12702; return -12702;
#if !defined(WOLFSSL_SOLARIS) #if !defined(WOLFSSL_SOLARIS) && defined(ENABLE_PTHREAD_LOCKFREE_TESTS)
/* trying to free a locked mutex is not portable behavior with pthread */
/* Attempting to destroy a locked mutex results in undefined behavior */
if (wc_FreeMutex(&m) != BAD_MUTEX_E) if (wc_FreeMutex(&m) != BAD_MUTEX_E)
return -12703; return -12703;
#endif #endif
@ -28506,7 +28509,8 @@ int mutex_test(void)
return -12704; return -12704;
if (wc_FreeMutex(&m) != 0) if (wc_FreeMutex(&m) != 0)
return -12705; return -12705;
#if !defined(WOLFSSL_NO_MUTEXLOCK_AFTER_FREE) #if !defined(WOLFSSL_SOLARIS) && defined(ENABLE_PTHREAD_LOCKFREE_TESTS)
/* Trying to use a pthread after free'ing is not portable behavior */
if (wc_LockMutex(&m) != BAD_MUTEX_E) if (wc_LockMutex(&m) != BAD_MUTEX_E)
return -12706; return -12706;
if (wc_UnLockMutex(&m) != BAD_MUTEX_E) if (wc_UnLockMutex(&m) != BAD_MUTEX_E)

View File

@ -1465,7 +1465,6 @@ extern void uITRON4_free(void *p) ;
#endif #endif
#ifdef WOLFSSL_SOLARIS #ifdef WOLFSSL_SOLARIS
#define WOLFSSL_NO_MUTEXLOCK_AFTER_FREE
/* Avoid naming clash with fp_zero from math.h > ieefp.h */ /* Avoid naming clash with fp_zero from math.h > ieefp.h */
#define WOLFSSL_DH_CONST #define WOLFSSL_DH_CONST
#endif #endif