bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: "bug-gnulib@gnu.org List" <bug-gnulib@gnu.org>
Subject: [PATCH] tests: skip thread-using tests when threading is disabled
Date: Sun, 5 Jan 2020 10:30:35 -0800	[thread overview]
Message-ID: <CA+8g5KHSx_m8PnqSx7HS3xuZ4nnJ_-D7X7kzDWiZMVAkmd=N_A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 783 bytes --]

I noticed this while preparing for a new release of sed.

I don't like copying the 4-term #if into so many files, but it already
appears in ten others. Note that this covers only the gnulib tests
used by sed. This probably deserves a full audit and/or auto-run tests
with gl_DISABLE_THREADS, but I am stopping with the proposed patch
below.
-----------
tests: skip thread-using tests when threading is disabled

sed's configure.ac specifies gl_DISABLE_THREADS, and that caused three
thread-using gnulib tests to fail. Add an #if-guarded exit (77) to each
of those, so they are skipped in this case.
* tests/test-nl_langinfo-mt.c (main): Exit 77 when threading is disabled.
* tests/test-setlocale_null-mt-all.c (main): Likewise.
* tests/test-setlocale_null-mt-one.c (main): Likewise.

[-- Attachment #2: gl-mt-skip.diff --]
[-- Type: application/octet-stream, Size: 3647 bytes --]

From 2f0e58f9c62755b6ec194d63985c7437bac487f5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Sun, 5 Jan 2020 10:25:27 -0800
Subject: [PATCH] tests: skip thread-using tests when threading is disabled

sed's configure.ac specifies gl_DISABLE_THREADS, and that caused three
thread-using gnulib tests to fail. Add an #if-guarded exit (77) to each
of those, so they are skipped in this case.
* tests/test-nl_langinfo-mt.c (main): Exit 77 when threading is disabled.
* tests/test-setlocale_null-mt-all.c (main): Likewise.
* tests/test-setlocale_null-mt-one.c (main): Likewise.
---
 ChangeLog                          | 10 ++++++++++
 tests/test-nl_langinfo-mt.c        |  5 +++++
 tests/test-setlocale_null-mt-all.c |  5 +++++
 tests/test-setlocale_null-mt-one.c |  5 +++++
 4 files changed, 25 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index a69db8585..61cb1c63e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-01-05  Jim Meyering  <meyering@fb.com>
+
+	tests: skip thread-using tests when threading is disabled
+	sed's configure.ac specifies gl_DISABLE_THREADS, and that caused three
+	thread-using gnulib tests to fail. Add an #if-guarded exit (77) to each
+	of those, so they are skipped in this case.
+	* tests/test-nl_langinfo-mt.c (main): Exit 77 when threading is disabled.
+	* tests/test-setlocale_null-mt-all.c (main): Likewise.
+	* tests/test-setlocale_null-mt-one.c (main): Likewise.
+
 2020-01-04  Jim Meyering  <meyering@fb.com>

 	update-copyright: reenable its always-skipped test
diff --git a/tests/test-nl_langinfo-mt.c b/tests/test-nl_langinfo-mt.c
index 55f9db98c..cc8b30119 100644
--- a/tests/test-nl_langinfo-mt.c
+++ b/tests/test-nl_langinfo-mt.c
@@ -192,6 +192,7 @@ threadN_func (void *arg)
 int
 main (int argc, char *argv[])
 {
+#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS
   if (setlocale (LC_ALL, LOCALE1) == NULL)
     {
       fprintf (stderr, "Skipping test: LOCALE1 not recognized\n");
@@ -235,4 +236,8 @@ main (int argc, char *argv[])
   }

   return 0;
+#else
+  fputs ("Skipping test: multithreading not enabled\n", stderr);
+  return 77;
+#endif
 }
diff --git a/tests/test-setlocale_null-mt-all.c b/tests/test-setlocale_null-mt-all.c
index a4f91d984..415b49b04 100644
--- a/tests/test-setlocale_null-mt-all.c
+++ b/tests/test-setlocale_null-mt-all.c
@@ -97,6 +97,7 @@ thread2_func (void *arg)
 int
 main (int argc, char *argv[])
 {
+#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS
   if (setlocale (LC_ALL, LOCALE1) == NULL)
     {
       fprintf (stderr, "Skipping test: LOCALE1 not recognized\n");
@@ -129,6 +130,10 @@ main (int argc, char *argv[])
   }

   return 0;
+#else
+  fputs ("Skipping test: multithreading not enabled\n", stderr);
+  return 77;
+#endif
 }

 /* Without locking, the results of this test would be:
diff --git a/tests/test-setlocale_null-mt-one.c b/tests/test-setlocale_null-mt-one.c
index dc9d4aa79..b2cbe9a98 100644
--- a/tests/test-setlocale_null-mt-one.c
+++ b/tests/test-setlocale_null-mt-one.c
@@ -97,6 +97,7 @@ thread2_func (void *arg)
 int
 main (int argc, char *argv[])
 {
+#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS
   if (setlocale (LC_ALL, LOCALE1) == NULL)
     {
       fprintf (stderr, "Skipping test: LOCALE1 not recognized\n");
@@ -129,6 +130,10 @@ main (int argc, char *argv[])
   }

   return 0;
+#else
+  fputs ("Skipping test: multithreading not enabled\n", stderr);
+  return 77;
+#endif
 }

 /* Without locking, the results of this test would be:
-- 
2.24.0.390.g083378cc35


             reply	other threads:[~2020-01-05 18:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-05 18:30 Jim Meyering [this message]
2020-01-05 19:59 ` [PATCH] tests: skip thread-using tests when threading is disabled Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+8g5KHSx_m8PnqSx7HS3xuZ4nnJ_-D7X7kzDWiZMVAkmd=N_A@mail.gmail.com' \
    --to=jim@meyering.net \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).