[08/14] ldbl-128ibm-compat: Test double values

Message ID 20180621021023.17036-9-gabriel@inconstante.eti.br
State New
Headers show
Series
  • Functions with format string for IEEE128 on powercpc64le
Related show

Commit Message

Gabriel F. T. Gomes June 21, 2018, 2:10 a.m.
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.

	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c:
	(do_test_call_rarg): Add parameter and use it in the calls
	to *printf functions under test.
	(do_test): Add variable and use it in the calls to
	do_test_call_rarg and do_test_call_varg.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh:
	Modify expected result.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh:
	Likewise.
---
 .../ldbl-128ibm-compat/test-printf-ldbl-compat.c   | 23 ++++++-----
 .../ldbl-128ibm-compat/test-printf-ldbl-compat.sh  | 48 +++++++++++-----------
 .../ldbl-128ibm-compat/test-wprintf-ldbl-compat.c  | 18 ++++----
 .../ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh | 24 +++++------
 4 files changed, 58 insertions(+), 55 deletions(-)

-- 
2.14.4

Patch

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 936e85f8d6..eece753c0d 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -76,13 +76,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 ("%20s", "asprintf: ");
-  asprintf (&buffer, format, ld);
+  asprintf (&buffer, format, ld, d);
   if (buffer == NULL)
     printf ("Error using asprintf\n");
   else
@@ -93,24 +93,24 @@  do_test_call_rarg (FILE *stream, const char *format, long double ld)
   printf ("\n");
 
   printf ("%20s", "dprintf: ");
-  dprintf (1, format, ld);
+  dprintf (1, format, ld, d);
   printf ("\n");
 
   printf ("%20s", "fprintf: ");
-  fprintf (stdout, format, ld);
+  fprintf (stdout, format, ld, d);
   printf ("\n");
 
   printf ("%20s", "printf: ");
-  printf (format, ld);
+  printf (format, ld, d);
   printf ("\n");
 
   printf ("%20s", "snprintf: ");
-  snprintf (string, 127, format, ld);
+  snprintf (string, 127, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 
   printf ("%20s", "sprintf: ");
-  sprintf (string, format, ld);
+  sprintf (string, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 }
@@ -119,14 +119,15 @@  static int
 do_test (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, "%.60Lf", ld);
-  do_test_call_varg (stdout, "%.60Lf", ld);
+  do_test_call_rarg (stdout, "%.60Lf, %f", ld, d);
+  do_test_call_varg (stdout, "%.60Lf, %f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, "%.60La", ld);
-  do_test_call_varg (stdout, "%.60La", ld);
+  do_test_call_rarg (stdout, "%.60La, %a", ld, d);
+  do_test_call_varg (stdout, "%.60La, %a", ld, d);
 
   return 0;
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
index 62bc5d03a6..b728c32e40 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
@@ -30,30 +30,30 @@  ${test_program_prefix} \
   > ${test_program_output} || status=1
 
 cat <<'EOF' |
-          asprintf: -1.000000000000000000000000000000000000000000000000000000000000
-           dprintf: -1.000000000000000000000000000000000000000000000000000000000000
-           fprintf: -1.000000000000000000000000000000000000000000000000000000000000
-            printf: -1.000000000000000000000000000000000000000000000000000000000000
-          snprintf: -1.000000000000000000000000000000000000000000000000000000000000
-           sprintf: -1.000000000000000000000000000000000000000000000000000000000000
-         vasprintf: -1.000000000000000000000000000000000000000000000000000000000000
-          vdprintf: -1.000000000000000000000000000000000000000000000000000000000000
-          vfprintf: -1.000000000000000000000000000000000000000000000000000000000000
-           vprintf: -1.000000000000000000000000000000000000000000000000000000000000
-         vsnprintf: -1.000000000000000000000000000000000000000000000000000000000000
-          vsprintf: -1.000000000000000000000000000000000000000000000000000000000000
-          asprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-           dprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-           fprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-            printf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-          snprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-           sprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-         vasprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-          vdprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-          vfprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-           vprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-         vsnprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-          vsprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+          asprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+           dprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+           fprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+            printf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+          snprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+           sprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+         vasprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+          vdprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+          vfprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+           vprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+         vsnprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+          vsprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+          asprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+           dprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+           fprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+            printf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+          snprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+           sprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+         vasprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+          vdprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+          vfprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+           vprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+         vsnprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+          vsprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
 EOF
 cmp - ${test_program_output} > /dev/null 2>&1 ||
 {
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 67ddbc9194..71ac3e27fa 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
@@ -50,21 +50,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: ");
-  fwprintf (stream, format, ld);
+  fwprintf (stream, format, ld, d);
   wprintf (L"\n");
 
   wprintf (L"%20Ls", L"swprintf: ");
-  swprintf (string, 127, format, ld);
+  swprintf (string, 127, format, ld, d);
   wprintf (L"%Ls", string);
   wprintf (L"\n");
 
   wprintf (L"%20Ls", L"wprintf: ");
-  wprintf (format, ld);
+  wprintf (format, ld, d);
   wprintf (L"\n");
 }
 
@@ -72,14 +73,15 @@  static int
 do_test (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, L"%.60Lf", ld);
-  do_test_call_varg (stdout, L"%.60Lf", ld);
+  do_test_call_rarg (stdout, L"%.60Lf, %f", ld, d);
+  do_test_call_varg (stdout, L"%.60Lf, %f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, L"%.60La", ld);
-  do_test_call_varg (stdout, L"%.60La", ld);
+  do_test_call_rarg (stdout, L"%.60La, %a", ld, d);
+  do_test_call_varg (stdout, L"%.60La, %a", ld, d);
 
   return 0;
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh
index 029006eb5e..d05b3bdb71 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh
@@ -30,18 +30,18 @@  ${test_program_prefix} \
   > ${test_program_output} || status=1
 
 cat <<'EOF' |
-          fwprintf: -1.000000000000000000000000000000000000000000000000000000000000
-          swprintf: -1.000000000000000000000000000000000000000000000000000000000000
-           wprintf: -1.000000000000000000000000000000000000000000000000000000000000
-         vfwprintf: -1.000000000000000000000000000000000000000000000000000000000000
-         vswprintf: -1.000000000000000000000000000000000000000000000000000000000000
-          vwprintf: -1.000000000000000000000000000000000000000000000000000000000000
-          fwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-          swprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-           wprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-         vfwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-         vswprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
-          vwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+          fwprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+          swprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+           wprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+         vfwprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+         vswprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+          vwprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+          fwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+          swprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+           wprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+         vfwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+         vswprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+          vwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
 EOF
 cmp - ${test_program_output} > /dev/null 2>&1 ||
 {