From: Jim Meyering Date: Sat, 12 Jun 2010 12:47:43 +0000 (+0200) Subject: test-inttostr: avoid spurious failure on Solaris 9 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=692a15c587c6d741cba6423319efcc957c45c9cb;p=pspp 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. --- diff --git a/ChangeLog b/ChangeLog index 7b6394d0e6..88e01ab893 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 e53d22a064..bf18621e4c 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; }