1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-03 00:26:59 +02:00

Use __noreturn_ on error functions when coverage testing.

The errorInternalThrowSys*() functions were marked as returning during coverage testing even when they had no possibility to return, i.e. the error parameter was set to constant true. This meant the compiler would treat the functions as returning even when they would not.

Instead create completely separate functions for coverage to use for THROW_ON_SYS_ERROR*() that can return and leave the regular functions marked __noreturn__.
This commit is contained in:
David Steele
2020-04-14 11:43:50 -04:00
parent b7d8d61526
commit f03d1b5b7b
4 changed files with 104 additions and 74 deletions

View File

@ -261,7 +261,7 @@ testRun(void)
TRY_BEGIN()
{
errno = E2BIG;
THROW_SYS_ERROR(AssertError, "message");
THROW_ON_SYS_ERROR(true, AssertError, "message");
}
CATCH_ANY()
{
@ -271,6 +271,34 @@ testRun(void)
}
TRY_END();
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
{
errno = 0;
THROW_ON_SYS_ERROR_FMT(true, AssertError, "message %d", 77);
}
CATCH_ANY()
{
printf("%s\n", errorMessage());
assert(errorCode() == AssertError.code);
assert(strcmp(errorMessage(), "message 77") == 0);
}
TRY_END();
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
{
errno = E2BIG;
THROW_ON_SYS_ERROR_FMT(true, AssertError, "message %d", 77);
}
CATCH_ANY()
{
printf("%s\n", errorMessage());
assert(errorCode() == AssertError.code);
assert(strcmp(errorMessage(), "message 77: [7] Argument list too long") == 0);
}
TRY_END();
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
{