Skip to content

[libc][test] usellvm-project/libc/test/UnitTest/ErrnoSetterMatcher.h when applicable #79713

@SchrodingerZhu

Description

@SchrodingerZhu

#79573 introduces macros for errno handling.
For unit tests, this can be further improved by using ErrnoSetterMatcher(which can clear errno properly to avoid interference with other tests).

For example,

int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_EQ(max_priority, -1);
ASSERT_EQ(libc_errno, EINVAL);

can be refactored into

ASSERT_THAT(LIBC_NAMESPACE::sched_get_priority_max(policy), returns(EQ(-1)),with_errno(EQ(EINVAL)));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions