[libc-commits] [libc] [libc][NFC] Use specific EXPECT/ASSERT macros to test errno (PR #79573)

via libc-commits libc-commits at lists.llvm.org
Fri Jan 26 05:24:42 PST 2024


================
@@ -58,6 +65,15 @@
 #define ASSERT_NE(val1, val2)                                                  \
   __CHECK_NE(__FILE__, __LINE__, (val1), (val2), true)
 
+////////////////////////////////////////////////////////////////////////////////
+// Errno checks.
+
+#define EXPECT_ERRNO_EQ(VAL) EXPECT_EQ(VAL, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(libc_errno))
+
+#define EXPECT_ERRNO() EXPECT_NE(static_cast<int>(libc_errno), 0)
----------------
lntue wrote:

Shall we consistently choose one between `ASSERT_ERRNO_EQ(0)` and `ASSERT_ERRNO()`?  I see that both are used below.  Maybe just pick the former one, and drop `ASSERT_ERRNO()` form, since the former one is essential for other value.

https://github.com/llvm/llvm-project/pull/79573


More information about the libc-commits mailing list