Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions libc/test/UnitTest/ErrnoCheckingTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
#include "src/__support/macros/config.h"
#include "test/UnitTest/Test.h"

// Define macro to validate the value stored in the errno and restore it
// to zero.

#define ASSERT_ERRNO_EQ(VAL) \
do { \
ASSERT_EQ(VAL, static_cast<int>(libc_errno)); \
libc_errno = 0; \
} while (0)
#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(libc_errno))
#define ASSERT_ERRNO_FAILURE() \
do { \
ASSERT_NE(0, static_cast<int>(libc_errno)); \
libc_errno = 0; \
} while (0)

namespace LIBC_NAMESPACE_DECL {
namespace testing {

Expand Down
15 changes: 0 additions & 15 deletions libc/test/UnitTest/Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@
#include "LibcTest.h"
#endif

// These are defined the same way for each framework, in terms of the macros
// they all provide.

#define ASSERT_ERRNO_EQ(VAL) \
do { \
ASSERT_EQ(VAL, static_cast<int>(libc_errno)); \
libc_errno = 0; \
} while (0)
#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(libc_errno))
#define ASSERT_ERRNO_FAILURE() \
do { \
ASSERT_NE(0, static_cast<int>(libc_errno)); \
libc_errno = 0; \
} while (0)

// Some macro utility to append file names with LIBC_TEST macro's value to be
// used in stdio tests.
#undef STR
Expand Down
1 change: 1 addition & 0 deletions libc/test/src/errno/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ add_libc_unittest(
errno_test.cpp
DEPENDS
libc.src.errno.errno
libc.test.UnitTest.ErrnoCheckingTest
)
1 change: 1 addition & 0 deletions libc/test/src/errno/errno_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "src/__support/libc_errno.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/Test.h"

TEST(LlvmLibcErrnoTest, Basic) {
Expand Down
Loading