aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2024-08-22 16:14:17 +0200
committerFlorian Weimer <fweimer@redhat.com>2024-08-26 16:46:45 +0200
commit34e52acd55d69964d14fb3188c5538442b8b32be (patch)
treea022183c41f1e8181a6fa0c56d2db7276867fb3a
parentinet: Avoid label at end of compound statement in tst-if_nameindex (diff)
downloadglibc-34e52acd55d69964d14fb3188c5538442b8b32be.tar.xz
glibc-34e52acd55d69964d14fb3188c5538442b8b32be.zip
support: Report errno constants in TEST_COMPARE failures
If the expression is errno, decode it as an errno constant using strerrorname_np. Reviewed-by: Arjun Shankar <arjun@redhat.com>
-rw-r--r--support/support_test_compare_failure.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/support/support_test_compare_failure.c b/support/support_test_compare_failure.c
index ae73d200cd..dba79e413f 100644
--- a/support/support_test_compare_failure.c
+++ b/support/support_test_compare_failure.c
@@ -17,7 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <limits.h>
#include <stdio.h>
+#include <string.h>
#include <support/check.h>
static void
@@ -31,7 +33,14 @@ report (const char *which, const char *expr, long long value, int positive,
printf ("%lld", value);
unsigned long long mask
= (~0ULL) >> (8 * (sizeof (unsigned long long) - size));
- printf (" (0x%llx); from: %s\n", (unsigned long long) value & mask, expr);
+ const char *errno_constant = NULL;
+ if (strcmp (expr, "errno") == 0
+ && positive && (unsigned long long int) value <= INT_MAX)
+ errno_constant = strerrorname_np (value);
+ printf (" (0x%llx", (unsigned long long) value & mask);
+ if (errno_constant != NULL)
+ printf (", %s", errno_constant);
+ printf ("); from: %s\n", expr);
}
void