Merge pull request #5825 from SparkiDev/api_test_sep

Unit test: rework to be able to run API tests individually
This commit is contained in:
David Garske
2022-11-29 18:11:57 -08:00
committed by GitHub
5 changed files with 4348 additions and 5615 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,7 @@
#include <wolfssl/wolfcrypt/fips_test.h>
int allTesting = 1;
int myoptind = 0;
char* myoptarg = NULL;
int unit_test(int argc, char** argv);
@@ -44,6 +45,21 @@ int main(int argc, char** argv)
}
#endif
/* Print usage options for unit test.
*/
static void UnitTest_Usage(void)
{
printf("Usage: ./tests/unit.test <options>\n");
printf(" -?, --help Display this usage information.\n");
printf(" --list List the API tests.\n");
printf(" --api Only perform API tests.\n");
printf(" -<number> Run the API test identified by number.\n");
printf(" Can be specified multiple times.\n");
printf(" -<string> Run the API test identified by name.\n");
printf(" Can be specified multiple times.\n");
printf(" <filename> Name of cipher suite testing file.\n");
}
int unit_test(int argc, char** argv)
{
int ret = 0;
@@ -154,39 +170,76 @@ int unit_test(int argc, char** argv)
}
#endif
#endif /* HAVE_FIPS && HAVE_FIPS_VERSION == 5 */
while (argc > 1) {
if (argv[1][0] != '-') {
break;
}
if (XSTRCMP(argv[1], "-?") == 0 || XSTRCMP(argv[1], "--help") == 0) {
UnitTest_Usage();
goto exit;
}
else if (XSTRCMP(argv[1], "--list") == 0) {
ApiTest_PrintTestCases();
goto exit;
}
else if (XSTRCMP(argv[1], "--api") == 0) {
}
else if (argv[1][1] >= '0' && argv[1][1] <= '9') {
ret = ApiTest_RunIdx(atoi(argv[1] + 1));
if (ret != 0) {
goto exit;
}
}
else {
ret = ApiTest_RunName(argv[1] + 1);
if (ret != 0) {
goto exit;
}
}
allTesting = 0;
argc--;
argv++;
}
#ifdef WOLFSSL_ALLOW_SKIP_UNIT_TESTS
if (argc == 1)
#endif
{
ApiTest();
if ( (ret = HashTest()) != 0){
if (!allTesting) {
goto exit;
}
if ((ret = HashTest()) != 0) {
fprintf(stderr, "hash test failed with %d\n", ret);
goto exit;
}
#ifdef WOLFSSL_W64_WRAPPER
#ifdef WOLFSSL_W64_WRAPPER
if ((ret = w64wrapper_test()) != 0) {
fprintf(stderr, "w64wrapper test failed with %d\n", ret);
goto exit;
}
#endif /* WOLFSSL_W64_WRAPPER */
#endif /* WOLFSSL_W64_WRAPPER */
#ifdef WOLFSSL_QUIC
if ((ret = QuicTest()) != 0) {
printf("quic test failed with %d\n", ret);
goto exit;
}
#endif
SrpTest();
}
#ifdef WOLFSSL_QUIC
if ( (ret = QuicTest()) != 0){
printf("quic test failed with %d\n", ret);
goto exit;
}
#endif
SrpTest();
#ifndef NO_WOLFSSL_CIPHER_SUITE_TEST
#if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER)
#ifndef SINGLE_THREADED
if ( (ret = SuiteTest(argc, argv)) != 0){
if ((ret = SuiteTest(argc, argv)) != 0) {
fprintf(stderr, "suite test failed with %d\n", ret);
goto exit;
}

View File

@@ -110,7 +110,11 @@
#define AssertPtrLE(x, y) AssertPtr(x, y, <=, >)
void ApiTest_PrintTestCases(void);
int ApiTest_RunIdx(int idx);
int ApiTest_RunName(char* name);
void ApiTest(void);
int SuiteTest(int argc, char** argv);
int HashTest(void);
void SrpTest(void);

View File

@@ -10395,7 +10395,7 @@ int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key,
for (i = 0; i < DSA_INTS - 1; i++)
GetASN_MP(&dataASN[(int)DSAKEYASN_IDX_VER + i], GetDsaInt(key, i));
/* Parse as simple form. */
ret = GetASN_Items(dsaKeyASN, dataASN, dsaPublicKeyASN_Length, 1, input,
ret = GetASN_Items(dsaKeyASN, dataASN, dsaPublicKeyASN_Length, 0, input,
inOutIdx, inSz);
if (ret != 0) {
/* Clear dynamic data items. */

View File

@@ -558,8 +558,6 @@ int StackSizeHWMReset(void)
fprintf(stderr, "%ld\t%s\n", (long int)HWM, msg); \
StackSizeHWMReset(); \
})
\
#define STACK_SIZE_CHECKPOINT_WITH_MAX_CHECK(max, ...) ({ \
ssize_t HWM = StackSizeHWM_OffsetCorrected(); \