]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use TEST_COMPARE_STRING in recently added test
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Tue, 6 Nov 2018 19:44:13 +0000 (17:44 -0200)
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Fri, 9 Nov 2018 00:42:01 +0000 (22:42 -0200)
The commit

commit 1df872fd74f730bcae3df201a229195445d2e18a
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Nov 7 12:42:44 2018 +0100

    support: Implement TEST_COMPARE_STRING

added the new macro TEST_COMPARE_STRING, which compares the output of
functions under test against expected strings, and, when there's a
mismatch, automatically reports an error and prints the differences.
This patch adapts recently added test cases to use this new macro.

Tested for powerpc64le (as is, and locally patched to intentionally fail
and produce error output).

* argp/tst-ldbl-argp.c (do_one_test): Use TEST_COMPARE_STRING,
instead of manually comparing and reporting mismatching strings.
* misc/tst-ldbl-error.c (do_one_test): Likewise.
* misc/tst-ldbl-warn.c (do_one_test): Likewise.

ChangeLog
argp/tst-ldbl-argp.c
misc/tst-ldbl-error.c
misc/tst-ldbl-warn.c

index f5a86565719a65c12147b81ee6bb8ee6482a0b8f..c75111bb08ee1d49ecf2333558ab0771a8a337ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-11-08  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
+
+       * argp/tst-ldbl-argp.c (do_one_test): Use TEST_COMPARE_STRING,
+       instead of manually comparing and reporting mismatching strings.
+       * misc/tst-ldbl-error.c (do_one_test): Likewise.
+       * misc/tst-ldbl-warn.c (do_one_test): Likewise.
+
 2018-11-08  Joseph Myers  <joseph@codesourcery.com>
 
        * sysdeps/unix/sysv/linux/kernel-features.h: Remove comment about
index 4465f812aff50faf0a4db209cbe37684b08a2798..231abeb18c21df71002b7f98c54b13a566b0cd4b 100644 (file)
@@ -73,14 +73,7 @@ do_one_test (const char *expected)
   struct support_capture_subprocess result;
   result = support_capture_subprocess ((void *) &do_test_call, NULL);
 
-  if (strcmp (result.err.buffer, expected) != 0)
-    {
-      support_record_failure ();
-      printf ("error:\n"
-             "    expected: '%s'\n"
-             "      actual: '%s'\n",
-             expected, result.err.buffer);
-    }
+  TEST_COMPARE_STRING (result.err.buffer, expected);
 
   return 0;
 }
index a02cb2772ab36abe0074d8c49fd56a07f8d42d81..76b2c8f784a36d37a5b9ccf94722fd8d22b54092 100644 (file)
@@ -95,14 +95,7 @@ do_one_test (void *callback, const char *expected, ...)
   message = strstr (result.err.buffer, needle);
 
   /* Verify that the output message is as expected.  */
-  if (strcmp (message, expected) != 0)
-    {
-      support_record_failure ();
-      printf ("error:\n"
-             "    expected: '%s'\n"
-             "      actual: '%s'\n",
-             expected, message);
-    }
+  TEST_COMPARE_STRING (message, expected);
 
   va_end (args);
 }
index 3ac0e4c873f8a10d4bea24ef55d8c49a67caf58f..69a528755cfc0fa9c290028dbc8b8a34c10e86f8 100644 (file)
@@ -61,11 +61,7 @@ do_one_test (int select, const char *format, va_list args,
 
   /* Close the in-memory stream and check the output buffer.  */
   xfclose_memstream (&stream);
-  if (strcmp (stream.buffer, expected) != 0)
-    FAIL_EXIT1 ("error:\n"
-               "    expected: '%s'\n"
-               "      actual: '%s'\n",
-               expected, stream.buffer);
+  TEST_COMPARE_STRING (stream.buffer, expected);
 
   if (stream.buffer != NULL)
     free (stream.buffer);