-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc] Move ASSERT_ERRNO_* macro to ErrnoCheckingTest.h #158727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Move these macro away from Test.h, since the generic Test.h (and associated test framework library) doesn't #include or depend on any errno-handling logic. Conversely, all tests that directly ASSERT various errno values are now migrated to ErrnoCheckingTest framework, which clears it our / validates it after every use case.
@llvm/pr-subscribers-libc Author: Alexey Samsonov (vonosmas) ChangesMove these macro away from Test.h, since the generic Test.h (and associated test framework library) doesn't #include or depend on any errno-handling logic. Conversely, all tests that directly ASSERT various errno values are now migrated to ErrnoCheckingTest framework, which clears it our / validates it after every use case. Full diff: https://github.com/llvm/llvm-project/pull/158727.diff 4 Files Affected:
diff --git a/libc/test/UnitTest/ErrnoCheckingTest.h b/libc/test/UnitTest/ErrnoCheckingTest.h
index 4b7ff452f409c..5b1bc9441d830 100644
--- a/libc/test/UnitTest/ErrnoCheckingTest.h
+++ b/libc/test/UnitTest/ErrnoCheckingTest.h
@@ -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 {
diff --git a/libc/test/UnitTest/Test.h b/libc/test/UnitTest/Test.h
index e70fc51869624..6643e3882fd2b 100644
--- a/libc/test/UnitTest/Test.h
+++ b/libc/test/UnitTest/Test.h
@@ -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
diff --git a/libc/test/src/errno/CMakeLists.txt b/libc/test/src/errno/CMakeLists.txt
index b73962fb4de4d..264574204e6cb 100644
--- a/libc/test/src/errno/CMakeLists.txt
+++ b/libc/test/src/errno/CMakeLists.txt
@@ -12,4 +12,5 @@ add_libc_unittest(
errno_test.cpp
DEPENDS
libc.src.errno.errno
+ libc.test.UnitTest.ErrnoCheckingTest
)
diff --git a/libc/test/src/errno/errno_test.cpp b/libc/test/src/errno/errno_test.cpp
index de82b0077f177..32fb3ec764063 100644
--- a/libc/test/src/errno/errno_test.cpp
+++ b/libc/test/src/errno/errno_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/libc_errno.h"
+#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/Test.h"
TEST(LlvmLibcErrnoTest, Basic) {
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/196/builds/12105 Here is the relevant piece of the build log for the reference
|
Build is green since then, looks like a transient error |
Move these macro away from Test.h, since the generic Test.h (and associated test framework library) doesn't #include or depend on any errno-handling logic. Conversely, all tests that directly ASSERT various errno values are now migrated to ErrnoCheckingTest framework, which clears it our / validates it after every use case.
Move these macro away from Test.h, since the generic Test.h (and associated test framework library) doesn't #include or depend on any errno-handling logic. Conversely, all tests that directly ASSERT various errno values are now migrated to ErrnoCheckingTest framework, which clears it our / validates it after every use case.