Skip to content

Commit a17b3b4

Browse files
authored
Merge pull request #8831 from JeremiahM37/UnitTest
Unit test for wolfcrypt pkcs12 file to improve code coverage
2 parents 3078403 + a6580d3 commit a17b3b4

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

tests/api.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,34 @@ static int test_fileAccess(void)
700700
#endif
701701
return EXPECT_RESULT();
702702
}
703+
static int test_wc_FreeCertList(void)
704+
{
705+
EXPECT_DECLS;
706+
#if defined(HAVE_PKCS12) && !defined(NO_ASN) && \
707+
!defined(NO_PWDBASED) && !defined(NO_HMAC) && !defined(NO_CERTS) && \
708+
defined(USE_CERT_BUFFERS_2048)
709+
WC_DerCertList* list = NULL;
710+
void* heap = NULL;
711+
/* Test freeing a list with a single node */
712+
list = (WC_DerCertList*)XMALLOC(sizeof(WC_DerCertList),
713+
heap, DYNAMIC_TYPE_PKCS);
714+
ExpectNotNull(list);
715+
if (list != NULL) {
716+
list->buffer = (byte*)XMALLOC(10, heap, DYNAMIC_TYPE_PKCS);
717+
ExpectNotNull(list->buffer);
718+
if (list->buffer != NULL) {
719+
list->bufferSz = 10;
720+
list->next = NULL;
721+
wc_FreeCertList(list, heap);
722+
}
723+
else {
724+
XFREE(list, heap, DYNAMIC_TYPE_PKCS);
725+
list = NULL;
726+
}
727+
}
728+
#endif
729+
return EXPECT_RESULT();
730+
}
703731

704732
/*----------------------------------------------------------------------------*
705733
| Method Allocators
@@ -67030,6 +67058,7 @@ TEST_CASE testCases[] = {
6703067058
TEST_DECL(test_wc_LoadStaticMemory_ex),
6703167059
TEST_DECL(test_wc_LoadStaticMemory_CTX),
6703267060

67061+
TEST_DECL(test_wc_FreeCertList),
6703367062
/* Locking with Compat Mutex */
6703467063
TEST_DECL(test_wc_SetMutexCb),
6703567064
TEST_DECL(test_wc_LockMutex_ex),

0 commit comments

Comments
 (0)