From 692a15c587c6d741cba6423319efcc957c45c9cb Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 12 Jun 2010 14:47:43 +0200 Subject: [PATCH] test-inttostr: avoid spurious failure on Solaris 9 * tests/test-inttostr.c (main): Skip the test when snprintf fails to accept "%ju". Reported by Bruno Haible. --- ChangeLog | 6 ++++++ tests/test-inttostr.c | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b6394d0e..88e01ab89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-06-12 Jim Meyering + + test-inttostr: avoid spurious failure on Solaris 9 + * tests/test-inttostr.c (main): Skip the test when snprintf fails + to accept "%ju". Reported by Bruno Haible. + 2010-06-11 Jim Meyering test-sys_socket: mark variables as used more readably diff --git a/tests/test-inttostr.c b/tests/test-inttostr.c index e53d22a06..bf18621e4 100644 --- a/tests/test-inttostr.c +++ b/tests/test-inttostr.c @@ -65,10 +65,22 @@ int main (void) { - CK (int, inttostr); - CK (unsigned int, uinttostr); - CK (off_t, offtostr); - CK (uintmax_t, umaxtostr); - CK (intmax_t, imaxtostr); - return 0; + char buf[2]; + + /* Ideally we would rely on the snprintf-posix module, in which case + this guard would not be required, but due to limitations in gnulib's + implementation (see modules/snprintf-posix), we cannot. */ + if (snprintf (buf, sizeof buf, "%ju", (uintmax_t) 3) == 1 + && buf[0] == '3' && buf[1] == '\0') + { + CK (int, inttostr); + CK (unsigned int, uinttostr); + CK (off_t, offtostr); + CK (uintmax_t, umaxtostr); + CK (intmax_t, imaxtostr); + return 0; + } + + /* snprintf doesn't accept %ju; skip this test. */ + return 77; } -- 2.11.0