Make kprintf_test resistant to limbo

This commit is contained in:
Justine Tunney 2022-11-13 14:26:19 -08:00
parent 711bd095db
commit a277170c9a
No known key found for this signature in database
GPG Key ID: BE714B4575D6E328
1 changed files with 7 additions and 4 deletions

View File

@ -245,13 +245,16 @@ TEST(ksnprintf, fuzzTheUnbreakable) {
TEST(kprintf, testFailure_wontClobberErrnoAndBypassesSystemCallSupport) {
int n;
const char *s = 0;
ASSERT_EQ(0, errno);
EXPECT_SYS(0, 3, dup(2));
EXPECT_SYS(0, 0, close(2));
// <LIMBO>
if (close(2)) _Exit(200);
n = __syscount;
EXPECT_EQ(n, __syscount);
EXPECT_EQ(0, errno);
EXPECT_SYS(0, 2, dup2(3, 2));
if (__syscount != n) _Exit(201);
if (errno != 0) _Exit(202);
if (dup2(3, 2) != 2) _Exit(203);
// </LIMBO>
EXPECT_SYS(0, 0, close(3));
}