mirror of https://github.com/wolfSSL/wolfssl.git
Unit test: rework to be able to run API tests individually
Change API test cases to return a result. Test success is now TEST_SUCCESS (1). Test result can be returned with use of macro TEST_RES_CHECK(). Always print the id, name of the test and the result (skipped or otherwise) before and after running the test case. Changed test case output to go to stderr. Fixed some formatting. Add option to take index and/or name of test case to run. Added option to list all API tests. Added option to only run API tests. Added options to show usage.pull/5825/head
parent
7aa796bdbd
commit
e4e53ab7ca
8753
tests/api.c
8753
tests/api.c
File diff suppressed because it is too large
Load Diff
57
tests/unit.c
57
tests/unit.c
|
@ -33,6 +33,7 @@
|
||||||
#include <wolfssl/wolfcrypt/fips_test.h>
|
#include <wolfssl/wolfcrypt/fips_test.h>
|
||||||
|
|
||||||
|
|
||||||
|
int allTesting = 1;
|
||||||
int myoptind = 0;
|
int myoptind = 0;
|
||||||
char* myoptarg = NULL;
|
char* myoptarg = NULL;
|
||||||
int unit_test(int argc, char** argv);
|
int unit_test(int argc, char** argv);
|
||||||
|
@ -44,6 +45,21 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
#endif
|
#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 unit_test(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -154,12 +170,50 @@ int unit_test(int argc, char** argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* HAVE_FIPS && HAVE_FIPS_VERSION == 5 */
|
#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
|
#ifdef WOLFSSL_ALLOW_SKIP_UNIT_TESTS
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ApiTest();
|
ApiTest();
|
||||||
|
|
||||||
|
if (!allTesting) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = HashTest()) != 0) {
|
if ((ret = HashTest()) != 0) {
|
||||||
fprintf(stderr, "hash test failed with %d\n", ret);
|
fprintf(stderr, "hash test failed with %d\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -172,8 +226,6 @@ int unit_test(int argc, char** argv)
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_W64_WRAPPER */
|
#endif /* WOLFSSL_W64_WRAPPER */
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_QUIC
|
#ifdef WOLFSSL_QUIC
|
||||||
if ((ret = QuicTest()) != 0) {
|
if ((ret = QuicTest()) != 0) {
|
||||||
printf("quic test failed with %d\n", ret);
|
printf("quic test failed with %d\n", ret);
|
||||||
|
@ -182,6 +234,7 @@ int unit_test(int argc, char** argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SrpTest();
|
SrpTest();
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NO_WOLFSSL_CIPHER_SUITE_TEST
|
#ifndef NO_WOLFSSL_CIPHER_SUITE_TEST
|
||||||
#if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER)
|
#if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER)
|
||||||
|
|
|
@ -110,7 +110,11 @@
|
||||||
#define AssertPtrLE(x, y) AssertPtr(x, y, <=, >)
|
#define AssertPtrLE(x, y) AssertPtr(x, y, <=, >)
|
||||||
|
|
||||||
|
|
||||||
|
void ApiTest_PrintTestCases(void);
|
||||||
|
int ApiTest_RunIdx(int idx);
|
||||||
|
int ApiTest_RunName(char* name);
|
||||||
void ApiTest(void);
|
void ApiTest(void);
|
||||||
|
|
||||||
int SuiteTest(int argc, char** argv);
|
int SuiteTest(int argc, char** argv);
|
||||||
int HashTest(void);
|
int HashTest(void);
|
||||||
void SrpTest(void);
|
void SrpTest(void);
|
||||||
|
|
Loading…
Reference in New Issue