Merge pull request #4982 from bmiklautz/ctest_asan_fixes

Fix issues with multiple tests if address sanitation is on
This commit is contained in:
akallabeth 2018-11-07 16:11:02 +01:00 committed by GitHub
commit cf43406dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 21 deletions

View File

@ -58,7 +58,7 @@ static BOOL test_ClearDecompressExample(UINT32 nr, UINT32 width, UINT32 height,
goto fail; goto fail;
status = clear_decompress(clear, pSrcData, SrcSize, width, height, status = clear_decompress(clear, pSrcData, SrcSize, width, height,
pDstData, PIXEL_FORMAT_XRGB32, 0, 1, 1, width, height, pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, width, height,
NULL); NULL);
printf("clear_decompress example %"PRIu32" status: %d\n", nr, status); printf("clear_decompress example %"PRIu32" status: %d\n", nr, status);
fflush(stdout); fflush(stdout);

View File

@ -19,7 +19,7 @@ char* crypto_cert_subject_common_name_wo_length(X509* xcert)
return crypto_cert_subject_common_name(xcert, & length); return crypto_cert_subject_common_name(xcert, & length);
} }
const char* certificate_path() char* certificate_path()
{ {
/* /*
Assume the .pem file is in the same directory as this source file. Assume the .pem file is in the same directory as this source file.
@ -45,12 +45,12 @@ const char* certificate_path()
else else
{ {
/* No dirsep => relative path in same directory */ /* No dirsep => relative path in same directory */
return filename; return _strdup(filename);
} }
} }
const certificate_test_t certificate_tests[] = const certificate_test_t certificate_tests[] =
{ {
{ {
ENABLED, ENABLED,
@ -78,6 +78,7 @@ const certificate_test_t certificate_tests[] =
"Certificate e-mail", "Certificate e-mail",
crypto_cert_get_email, crypto_cert_get_email,
"testjean.testmartin@test.example.com" "testjean.testmartin@test.example.com"
}, },
{ {
@ -93,10 +94,10 @@ const certificate_test_t certificate_tests[] =
crypto_cert_issuer, crypto_cert_issuer,
"CN = ADMINISTRATION CENTRALE DES TESTS, C = FR, O = MINISTERE DES TESTS, OU = 0002 110014016" "CN = ADMINISTRATION CENTRALE DES TESTS, C = FR, O = MINISTERE DES TESTS, OU = 0002 110014016"
}, },
}; };
int TestCertificateFile(const char* certificate_path, const certificate_test_t* certificate_tests, int TestCertificateFile(const char* certificate_path, const certificate_test_t* certificate_tests,
int count) int count)
{ {
@ -112,6 +113,7 @@ int TestCertificateFile(const char* certificate_path, const certificate_test_t*
} }
certificate = PEM_read_X509(certificate_file, 0, 0, 0); certificate = PEM_read_X509(certificate_file, 0, 0, 0);
fclose(certificate_file);
if (!certificate) if (!certificate)
{ {
@ -148,6 +150,7 @@ int TestCertificateFile(const char* certificate_path, const certificate_test_t*
certificate_tests[i].expected_result); certificate_tests[i].expected_result);
success = -1; success = -1;
} }
free(result);
} }
else else
{ {
@ -157,13 +160,16 @@ int TestCertificateFile(const char* certificate_path, const certificate_test_t*
} }
fail: fail:
fclose(certificate_file); X509_free(certificate);
return success; return success;
} }
int Test_x509_cert_info(int argc, char* argv[]) int Test_x509_cert_info(int argc, char* argv[])
{ {
return TestCertificateFile(certificate_path(), certificate_tests, ARRAYSIZE(certificate_tests)); char* cert_path = certificate_path();
int ret = TestCertificateFile(cert_path, certificate_tests, ARRAYSIZE(certificate_tests));
free(cert_path);
return ret;
} }

View File

@ -60,6 +60,7 @@ static COMMAND_LINE_ARGUMENT_A args[] =
int TestCmdLine(int argc, char* argv[]) int TestCmdLine(int argc, char* argv[])
{ {
int status; int status;
int ret = -1;
DWORD flags; DWORD flags;
long width = 0; long width = 0;
long height = 0; long height = 0;
@ -70,12 +71,19 @@ int TestCmdLine(int argc, char* argv[])
flags = COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_SIGIL_PLUS_MINUS; flags = COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_SIGIL_PLUS_MINUS;
testArgc = string_list_length(testArgv); testArgc = string_list_length(testArgv);
command_line = string_list_copy(testArgv); command_line = string_list_copy(testArgv);
if (!command_line)
{
printf("Argument duplication failed (not enough memory?)\n");
return ret;
}
status = CommandLineParseArgumentsA(testArgc, command_line, args, flags, NULL, NULL, NULL); status = CommandLineParseArgumentsA(testArgc, command_line, args, flags, NULL, NULL, NULL);
if (status != 0) if (status != 0)
{ {
printf("CommandLineParseArgumentsA failure: %d\n", status); printf("CommandLineParseArgumentsA failure: %d\n", status);
return -1; goto out;
} }
arg = CommandLineFindArgumentA(args, "w"); arg = CommandLineFindArgumentA(args, "w");
@ -83,7 +91,7 @@ int TestCmdLine(int argc, char* argv[])
if (strcmp("1024", arg->Value) != 0) if (strcmp("1024", arg->Value) != 0)
{ {
printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value); printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value);
return -1; goto out;
} }
arg = CommandLineFindArgumentA(args, "h"); arg = CommandLineFindArgumentA(args, "h");
@ -91,7 +99,7 @@ int TestCmdLine(int argc, char* argv[])
if (strcmp("768", arg->Value) != 0) if (strcmp("768", arg->Value) != 0)
{ {
printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value); printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value);
return -1; goto out;
} }
arg = CommandLineFindArgumentA(args, "f"); arg = CommandLineFindArgumentA(args, "f");
@ -99,7 +107,7 @@ int TestCmdLine(int argc, char* argv[])
if (arg->Value) if (arg->Value)
{ {
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name); printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
return -1; goto out;
} }
arg = CommandLineFindArgumentA(args, "admin"); arg = CommandLineFindArgumentA(args, "admin");
@ -107,7 +115,7 @@ int TestCmdLine(int argc, char* argv[])
if (!arg->Value) if (!arg->Value)
{ {
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name); printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
return -1; goto out;
} }
arg = CommandLineFindArgumentA(args, "multimon"); arg = CommandLineFindArgumentA(args, "multimon");
@ -115,7 +123,7 @@ int TestCmdLine(int argc, char* argv[])
if (!arg->Value) if (!arg->Value)
{ {
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name); printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
return -1; goto out;
} }
arg = CommandLineFindArgumentA(args, "v"); arg = CommandLineFindArgumentA(args, "v");
@ -123,7 +131,7 @@ int TestCmdLine(int argc, char* argv[])
if (strcmp("localhost:3389", arg->Value) != 0) if (strcmp("localhost:3389", arg->Value) != 0)
{ {
printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value); printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value);
return -1; goto out;
} }
arg = CommandLineFindArgumentA(args, "fonts"); arg = CommandLineFindArgumentA(args, "fonts");
@ -131,7 +139,7 @@ int TestCmdLine(int argc, char* argv[])
if (!arg->Value) if (!arg->Value)
{ {
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name); printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
return -1; goto out;
} }
arg = CommandLineFindArgumentA(args, "wallpaper"); arg = CommandLineFindArgumentA(args, "wallpaper");
@ -139,7 +147,7 @@ int TestCmdLine(int argc, char* argv[])
if (arg->Value) if (arg->Value)
{ {
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name); printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
return -1; goto out;
} }
arg = CommandLineFindArgumentA(args, "help"); arg = CommandLineFindArgumentA(args, "help");
@ -147,7 +155,7 @@ int TestCmdLine(int argc, char* argv[])
if (arg->Value) if (arg->Value)
{ {
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name); printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
return -1; goto out;
} }
arg = args; arg = args;
@ -168,14 +176,14 @@ int TestCmdLine(int argc, char* argv[])
width = strtol(arg->Value, NULL, 0); width = strtol(arg->Value, NULL, 0);
if (errno != 0) if (errno != 0)
return -1; goto out;
} }
CommandLineSwitchCase(arg, "h") CommandLineSwitchCase(arg, "h")
{ {
height = strtol(arg->Value, NULL, 0); height = strtol(arg->Value, NULL, 0);
if (errno != 0) if (errno != 0)
return -1; goto out;
} }
CommandLineSwitchDefault(arg) CommandLineSwitchDefault(arg)
{ {
@ -187,8 +195,11 @@ int TestCmdLine(int argc, char* argv[])
if ((width != 1024) || (height != 768)) if ((width != 1024) || (height != 768))
{ {
printf("Unexpected width and height: Actual: (%ldx%ld), Expected: (1024x768)\n", width, height); printf("Unexpected width and height: Actual: (%ldx%ld), Expected: (1024x768)\n", width, height);
return -1; goto out;
} }
ret = 0;
return 0; out:
string_list_free(command_line);
return ret;
} }