Skip to content

Commit

Permalink
tests: Work around the strerror_s(3) limitation.
Browse files Browse the repository at this point in the history
Strerror_s(3) does not detect the short buffer, and that cannot be covered by
pal.

Signed-off-by: Seigo Tanimura <[email protected]>
  • Loading branch information
altimeter-130ft committed Jan 18, 2024
1 parent b09f688 commit 0de702a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/internal/pal.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,18 @@ static void test_pal_strerror_r_smallbuf()

ret = flb_strerror_r(EINVAL, buf, sizeof(buf));

TEST_CHECK(ERANGE == ret);
TEST_CHECK(NULL != memchr(buf, '\0', sizeof(buf)));
TEST_CHECK(0 == strlen(buf));
/*
* If the flb_strerror_r() implementation is strerror_s(3), the short
* buffer cannot be detected; it seems such the condition is not a runtime
* constraint violation.
*
* Only check here that the returned string is terminated as long as the
* status is successful.
*/
if (0 == ret) {
TEST_CHECK(NULL != memchr(buf, '\0', sizeof(buf)));
TEST_CHECK(0 == strlen(buf));
}
}

static void test_pal_strerror_r_error_unknown()
Expand Down

0 comments on commit 0de702a

Please sign in to comment.