From: Pádraig Brady Date: Sun, 8 Feb 2026 19:34:13 +0000 (+0000) Subject: tests: getlimits: output error strings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8732e7e95ed65e90838ac35639b03e7fd700f12a;p=thirdparty%2Fcoreutils.git tests: getlimits: output error strings * src/getlimits.c (main): Iterate over defined errnos, and output shell compatible error strings. * tests/Coreutils.pm: Adjust so shell quotes are stripped. --- diff --git a/bootstrap.conf b/bootstrap.conf index 07ab7e7e6f..1cab8a8049 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -85,6 +85,7 @@ gnulib_modules=" dup2 endian environ + errno-iter error euidaccess exclude @@ -274,6 +275,7 @@ gnulib_modules=" stpcpy str_endswith strdup-posix + strerrorname_np stringeq strnlen strnumcmp diff --git a/src/getlimits.c b/src/getlimits.c index 6113988a25..86224a3d0b 100644 --- a/src/getlimits.c +++ b/src/getlimits.c @@ -22,6 +22,7 @@ #include #include +#include "errno-iter.h" #include "ftoastr.h" #include "system.h" #include "ioblksize.h" @@ -129,6 +130,16 @@ PRINT_FLOATTYPE (print_FLT, float, ftoastr, FLT_BUFSIZE_BOUND) PRINT_FLOATTYPE (print_DBL, double, dtoastr, DBL_BUFSIZE_BOUND) PRINT_FLOATTYPE (print_LDBL, long double, ldtoastr, LDBL_BUFSIZE_BOUND) +static int +print_errno (void *name, int e) +{ + char const *err_name = name ? name : strerrorname_np (e); + if (err_name) + printf ("%s=%s\n", err_name, + quotearg_style (shell_escape_quoting_style, strerror (e))); + return 0; +} + int main (int argc, char **argv) { @@ -192,5 +203,21 @@ main (int argc, char **argv) printf ("SIGRTMAX=%jd\n", (intmax_t) SIGRTMAX); printf ("IO_BUFSIZE=%ju\n", (uintmax_t) IO_BUFSIZE); + /* Errnos */ + errno_iterate (print_errno, NULL); + /* Common errno aliases */ +#if defined ENOTEMPTY && ENOTEMPTY == EEXIST + print_errno ((char*)"ENOTEMPTY", EEXIST); +#endif +#if defined ENOTSUP && ENOTSUP == EOPNOTSUPP + print_errno ((char*)"ENOTSUP", EOPNOTSUPP); +#endif +#if defined EWOULDBLOCK && EWOULDBLOCK == EAGAIN + print_errno ((char*)"EWOULDBLOCK", EAGAIN); +#endif +#if defined EDEADLOCK && EDEADLOCK == EDEADLK + print_errno ((char*)"EDEADLOCK", EDEADLK); +#endif + return EXIT_SUCCESS; } diff --git a/tests/Coreutils.pm b/tests/Coreutils.pm index 393a8c8dfc..376609d731 100644 --- a/tests/Coreutils.pm +++ b/tests/Coreutils.pm @@ -21,6 +21,7 @@ use vars qw($VERSION @ISA @EXPORT); use FileHandle; use File::Compare qw(compare); +use Text::ParseWords qw(shellwords); @ISA = qw(Exporter); ($VERSION = '$Revision: 1.5 $ ') =~ tr/[0-9].//cd; @@ -213,7 +214,12 @@ sub getlimits() { my $NV; open $NV, "getlimits |" or die "Error running getlimits\n"; - my %limits = map {split /=|\n/} <$NV>; + my %limits = map { + chomp; + my ($k, $v) = split /=/, $_, 2; + $v = (shellwords($v))[0] if defined $v; + ($k, $v) + } <$NV>; return \%limits; }