Introduce sigtimedwait() and sigwaitinfo()

This change also invents sigcountset() and strsignal_r() and improves
the quality of siginfo_t handling.
This commit is contained in:
Justine Tunney 2022-10-10 07:36:07 -07:00
parent 7ae556463a
commit 467a332e38
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
41 changed files with 887 additions and 345 deletions

View file

@ -49,10 +49,6 @@ static uint64_t Rando(void) {
return x;
}
void SetUp(void) {
__print_maps();
}
static const struct {
const char *want;
const char *fmt;
@ -356,6 +352,30 @@ TEST(ksnprintf, badUtf16) {
}
}
TEST(ksnprintf, negativeOverflowIdiom_isSafe) {
int i, n;
char golden[11];
struct {
char underflow[11];
char buf[11];
char overflow[11];
} u;
memset(golden, -1, 11);
memset(u.underflow, -1, 11);
memset(u.overflow, -1, 11);
i = 0;
n = 11;
i += ksnprintf(u.buf + i, n - i, "hello");
ASSERT_STREQ("hello", u.buf);
i += ksnprintf(u.buf + i, n - i, " world");
ASSERT_STREQ("hello w...", u.buf);
i += ksnprintf(u.buf + i, n - i, " i love you");
ASSERT_STREQ("hello w...", u.buf);
ASSERT_EQ(i, 5 + 6 + 11);
ASSERT_EQ(0, memcmp(golden, u.underflow, 11));
ASSERT_EQ(0, memcmp(golden, u.overflow, 11));
}
TEST(ksnprintf, truncation) {
char buf[16] = {0};
rngset(buf, sizeof(buf) - 1, lemur64, -1);