about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gabrielftg@linux.ibm.com>2019-07-11 11:47:06 -0300
committerGabriel F. T. Gomes <gabrielftg@linux.ibm.com>2019-11-22 18:12:37 -0300
commit5bbbd5ae057c8f862e65d9a230bccb2364f48f96 (patch)
treed11c663185dc3c8eac33ca7ac74eaf6a8aa66f9c
parent329037cead5f7930c6081d130b22e03b0ff5e3a8 (diff)
downloadglibc-5bbbd5ae057c8f862e65d9a230bccb2364f48f96.tar.gz
glibc-5bbbd5ae057c8f862e65d9a230bccb2364f48f96.tar.xz
glibc-5bbbd5ae057c8f862e65d9a230bccb2364f48f96.zip
ldbl-128ibm-compat: Test double values
A single format string can take double and long double parameters at the
same time.  Internally, these parameters are routed to the same
function, which correctly reads them and calls the underlying functions
responsible for the actual conversion to string.  This patch adds a new
case to test this scenario.

Tested for powerpc64le.

Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
-rw-r--r--sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c72
-rw-r--r--sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c71
-rw-r--r--sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c42
-rw-r--r--sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c42
4 files changed, 117 insertions, 110 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
index dce40b35fe..d57fd7bc92 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
@@ -83,14 +83,15 @@ do_test_call_varg (FILE *stream, const char *format, ...)
 }
 
 static void
-do_test_call_rarg (FILE *stream, const char *format, long double ld)
+do_test_call_rarg (FILE *stream, const char *format, long double ld,
+		   double d)
 {
   char *buffer = NULL;
   char string[128];
   int res;
 
   printf ("%20s", "__asprintf_chk: ");
-  res = __asprintf_chk (&buffer, 1, format, ld);
+  res = __asprintf_chk (&buffer, 1, format, ld, d);
   if (res == -1)
     printf ("Error using vasprintf\n");
   if (buffer == NULL)
@@ -103,24 +104,24 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld)
   printf ("\n");
 
   printf ("%20s", "__dprintf_chk: ");
-  __dprintf_chk (fileno (stream), 1, format, ld);
+  __dprintf_chk (fileno (stream), 1, format, ld, d);
   printf ("\n");
 
   printf ("%20s", "__fprintf_chk: ");
-  __fprintf_chk (stdout, 1, format, ld);
+  __fprintf_chk (stdout, 1, format, ld, d);
   printf ("\n");
 
   printf ("%20s", "__printf_chk: ");
-  __printf_chk (1, format, ld);
+  __printf_chk (1, format, ld, d);
   printf ("\n");
 
   printf ("%20s", "__snprintf_chk: ");
-  __snprintf_chk (string, 79, 1, 127, format, ld);
+  __snprintf_chk (string, 79, 1, 127, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 
   printf ("%20s", "__sprintf_chk: ");
-  __sprintf_chk (string, 1, 127, format, ld);
+  __sprintf_chk (string, 1, 127, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 }
@@ -129,14 +130,15 @@ static void
 do_test_call (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, "%.10Lf", ld);
-  do_test_call_varg (stdout, "%.10Lf", ld);
+  do_test_call_rarg (stdout, "%.10Lf, %.10f", ld, d);
+  do_test_call_varg (stdout, "%.10Lf, %.10f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, "%.10La", ld);
-  do_test_call_varg (stdout, "%.10La", ld);
+  do_test_call_rarg (stdout, "%.10La, %.10a", ld, d);
+  do_test_call_varg (stdout, "%.10La, %.10a", ld, d);
 }
 
 static int
@@ -147,30 +149,30 @@ do_test (void)
 
   /* Compare against the expected output.  */
   const char *expected =
-    "    __asprintf_chk: -1.0000000000\n"
-    "     __dprintf_chk: -1.0000000000\n"
-    "     __fprintf_chk: -1.0000000000\n"
-    "      __printf_chk: -1.0000000000\n"
-    "    __snprintf_chk: -1.0000000000\n"
-    "     __sprintf_chk: -1.0000000000\n"
-    "   __vasprintf_chk: -1.0000000000\n"
-    "    __vdprintf_chk: -1.0000000000\n"
-    "    __vfprintf_chk: -1.0000000000\n"
-    "     __vprintf_chk: -1.0000000000\n"
-    "   __vsnprintf_chk: -1.0000000000\n"
-    "    __vsprintf_chk: -1.0000000000\n"
-    "    __asprintf_chk: -0x1.0000000000p+0\n"
-    "     __dprintf_chk: -0x1.0000000000p+0\n"
-    "     __fprintf_chk: -0x1.0000000000p+0\n"
-    "      __printf_chk: -0x1.0000000000p+0\n"
-    "    __snprintf_chk: -0x1.0000000000p+0\n"
-    "     __sprintf_chk: -0x1.0000000000p+0\n"
-    "   __vasprintf_chk: -0x1.0000000000p+0\n"
-    "    __vdprintf_chk: -0x1.0000000000p+0\n"
-    "    __vfprintf_chk: -0x1.0000000000p+0\n"
-    "     __vprintf_chk: -0x1.0000000000p+0\n"
-    "   __vsnprintf_chk: -0x1.0000000000p+0\n"
-    "    __vsprintf_chk: -0x1.0000000000p+0\n";
+    "    __asprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __dprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __fprintf_chk: -1.0000000000, -1.0000000000\n"
+    "      __printf_chk: -1.0000000000, -1.0000000000\n"
+    "    __snprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __sprintf_chk: -1.0000000000, -1.0000000000\n"
+    "   __vasprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __vdprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __vfprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __vprintf_chk: -1.0000000000, -1.0000000000\n"
+    "   __vsnprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __vsprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __asprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __dprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __fprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      __printf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __snprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __sprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vasprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __vdprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __vfprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __vprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vsnprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __vsprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
index 939a6aad9c..2b8d424473 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -78,13 +78,13 @@ do_test_call_varg (FILE *stream, const char *format, ...)
 }
 
 static void
-do_test_call_rarg (FILE *stream, const char *format, long double ld)
+do_test_call_rarg (FILE *stream, const char *format, long double ld, double d)
 {
   char *buffer = NULL;
   char string[128];
 
   printf ("%15s", "asprintf: ");
-  asprintf (&buffer, format, ld);
+  asprintf (&buffer, format, ld, d);
   if (buffer == NULL)
     printf ("Error using asprintf\n");
   else
@@ -95,24 +95,24 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld)
   printf ("\n");
 
   printf ("%15s", "dprintf: ");
-  dprintf (fileno (stream), format, ld);
+  dprintf (fileno (stream), format, ld, d);
   printf ("\n");
 
   printf ("%15s", "fprintf: ");
-  fprintf (stream, format, ld);
+  fprintf (stream, format, ld, d);
   printf ("\n");
 
   printf ("%15s", "printf: ");
-  printf (format, ld);
+  printf (format, ld, d);
   printf ("\n");
 
   printf ("%15s", "snprintf: ");
-  snprintf (string, 127, format, ld);
+  snprintf (string, 127, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 
   printf ("%15s", "sprintf: ");
-  sprintf (string, format, ld);
+  sprintf (string, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 }
@@ -121,14 +121,15 @@ static void
 do_test_call (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, "%.10Lf", ld);
-  do_test_call_varg (stdout, "%.10Lf", ld);
+  do_test_call_rarg (stdout, "%.10Lf, %.10f", ld, d);
+  do_test_call_varg (stdout, "%.10Lf, %.10f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, "%.10La", ld);
-  do_test_call_varg (stdout, "%.10La", ld);
+  do_test_call_rarg (stdout, "%.10La, %.10a", ld, d);
+  do_test_call_varg (stdout, "%.10La, %.10a", ld, d);
 }
 
 static int
@@ -139,30 +140,30 @@ do_test (void)
 
   /* Compare against the expected output.  */
   const char *expected =
-    "     asprintf: -1.0000000000\n"
-    "      dprintf: -1.0000000000\n"
-    "      fprintf: -1.0000000000\n"
-    "       printf: -1.0000000000\n"
-    "     snprintf: -1.0000000000\n"
-    "      sprintf: -1.0000000000\n"
-    "    vasprintf: -1.0000000000\n"
-    "     vdprintf: -1.0000000000\n"
-    "     vfprintf: -1.0000000000\n"
-    "      vprintf: -1.0000000000\n"
-    "    vsnprintf: -1.0000000000\n"
-    "     vsprintf: -1.0000000000\n"
-    "     asprintf: -0x1.0000000000p+0\n"
-    "      dprintf: -0x1.0000000000p+0\n"
-    "      fprintf: -0x1.0000000000p+0\n"
-    "       printf: -0x1.0000000000p+0\n"
-    "     snprintf: -0x1.0000000000p+0\n"
-    "      sprintf: -0x1.0000000000p+0\n"
-    "    vasprintf: -0x1.0000000000p+0\n"
-    "     vdprintf: -0x1.0000000000p+0\n"
-    "     vfprintf: -0x1.0000000000p+0\n"
-    "      vprintf: -0x1.0000000000p+0\n"
-    "    vsnprintf: -0x1.0000000000p+0\n"
-    "     vsprintf: -0x1.0000000000p+0\n";
+    "     asprintf: -1.0000000000, -1.0000000000\n"
+    "      dprintf: -1.0000000000, -1.0000000000\n"
+    "      fprintf: -1.0000000000, -1.0000000000\n"
+    "       printf: -1.0000000000, -1.0000000000\n"
+    "     snprintf: -1.0000000000, -1.0000000000\n"
+    "      sprintf: -1.0000000000, -1.0000000000\n"
+    "    vasprintf: -1.0000000000, -1.0000000000\n"
+    "     vdprintf: -1.0000000000, -1.0000000000\n"
+    "     vfprintf: -1.0000000000, -1.0000000000\n"
+    "      vprintf: -1.0000000000, -1.0000000000\n"
+    "    vsnprintf: -1.0000000000, -1.0000000000\n"
+    "     vsprintf: -1.0000000000, -1.0000000000\n"
+    "     asprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      dprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      fprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "       printf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     snprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      sprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vasprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vdprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vfprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      vprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vsnprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vsprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
index f614004f27..0dcabec38a 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
@@ -53,21 +53,22 @@ do_test_call_varg (FILE *stream, const wchar_t *format, ...)
 }
 
 static void
-do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
+do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld,
+		   double d)
 {
   wchar_t string[128];
 
   wprintf (L"%20Ls", L"__fwprintf_chk: ");
-  __fwprintf_chk (stream, 1, format, ld);
+  __fwprintf_chk (stream, 1, format, ld, d);
   wprintf (L"\n");
 
   wprintf (L"%20Ls", L"__swprintf_chk: ");
-  __swprintf_chk (string, 79, 1, 127, format, ld);
+  __swprintf_chk (string, 79, 1, 127, format, ld, d);
   wprintf (L"%Ls", string);
   wprintf (L"\n");
 
   wprintf (L"%20Ls", L"__wprintf_chk: ");
-  __wprintf_chk (1, format, ld);
+  __wprintf_chk (1, format, ld, d);
   wprintf (L"\n");
 }
 
@@ -75,14 +76,15 @@ static void
 do_test_call (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, L"%.10Lf", ld);
-  do_test_call_varg (stdout, L"%.10Lf", ld);
+  do_test_call_rarg (stdout, L"%.10Lf, %.10f", ld, d);
+  do_test_call_varg (stdout, L"%.10Lf, %.10f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, L"%.10La", ld);
-  do_test_call_varg (stdout, L"%.10La", ld);
+  do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d);
+  do_test_call_varg (stdout, L"%.10La, %.10a", ld, d);
 }
 
 static int
@@ -93,18 +95,18 @@ do_test (void)
 
   /* Compare against the expected output.  */
   const char *expected =
-    "    __fwprintf_chk: -1.0000000000\n"
-    "    __swprintf_chk: -1.0000000000\n"
-    "     __wprintf_chk: -1.0000000000\n"
-    "   __vfwprintf_chk: -1.0000000000\n"
-    "   __vswprintf_chk: -1.0000000000\n"
-    "    __vwprintf_chk: -1.0000000000\n"
-    "    __fwprintf_chk: -0x1.0000000000p+0\n"
-    "    __swprintf_chk: -0x1.0000000000p+0\n"
-    "     __wprintf_chk: -0x1.0000000000p+0\n"
-    "   __vfwprintf_chk: -0x1.0000000000p+0\n"
-    "   __vswprintf_chk: -0x1.0000000000p+0\n"
-    "    __vwprintf_chk: -0x1.0000000000p+0\n";
+    "    __fwprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __swprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __wprintf_chk: -1.0000000000, -1.0000000000\n"
+    "   __vfwprintf_chk: -1.0000000000, -1.0000000000\n"
+    "   __vswprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __vwprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __fwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __swprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __wprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vfwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vswprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __vwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
index 71edfec235..def4337571 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
@@ -51,21 +51,22 @@ do_test_call_varg (FILE *stream, const wchar_t *format, ...)
 }
 
 static void
-do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
+do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld,
+		   double d)
 {
   wchar_t string[128];
 
   wprintf (L"%15Ls", L"fwprintf: ");
-  fwprintf (stream, format, ld);
+  fwprintf (stream, format, ld, d);
   wprintf (L"\n");
 
   wprintf (L"%15Ls", L"swprintf: ");
-  swprintf (string, 127, format, ld);
+  swprintf (string, 127, format, ld, d);
   wprintf (L"%Ls", string);
   wprintf (L"\n");
 
   wprintf (L"%15Ls", L"wprintf: ");
-  wprintf (format, ld);
+  wprintf (format, ld, d);
   wprintf (L"\n");
 }
 
@@ -73,14 +74,15 @@ static void
 do_test_call (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, L"%.10Lf", ld);
-  do_test_call_varg (stdout, L"%.10Lf", ld);
+  do_test_call_rarg (stdout, L"%.10Lf, %.10f", ld, d);
+  do_test_call_varg (stdout, L"%.10Lf, %.10f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, L"%.10La", ld);
-  do_test_call_varg (stdout, L"%.10La", ld);
+  do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d);
+  do_test_call_varg (stdout, L"%.10La, %.10a", ld, d);
 }
 
 static int
@@ -91,18 +93,18 @@ do_test (void)
 
   /* Compare against the expected output.  */
   const char *expected =
-    "     fwprintf: -1.0000000000\n"
-    "     swprintf: -1.0000000000\n"
-    "      wprintf: -1.0000000000\n"
-    "    vfwprintf: -1.0000000000\n"
-    "    vswprintf: -1.0000000000\n"
-    "     vwprintf: -1.0000000000\n"
-    "     fwprintf: -0x1.0000000000p+0\n"
-    "     swprintf: -0x1.0000000000p+0\n"
-    "      wprintf: -0x1.0000000000p+0\n"
-    "    vfwprintf: -0x1.0000000000p+0\n"
-    "    vswprintf: -0x1.0000000000p+0\n"
-    "     vwprintf: -0x1.0000000000p+0\n";
+    "     fwprintf: -1.0000000000, -1.0000000000\n"
+    "     swprintf: -1.0000000000, -1.0000000000\n"
+    "      wprintf: -1.0000000000, -1.0000000000\n"
+    "    vfwprintf: -1.0000000000, -1.0000000000\n"
+    "    vswprintf: -1.0000000000, -1.0000000000\n"
+    "     vwprintf: -1.0000000000, -1.0000000000\n"
+    "     fwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     swprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      wprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vfwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vswprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;