* [PATCH] tests: skip thread-using tests when threading is disabled
@ 2020-01-05 18:30 Jim Meyering
2020-01-05 19:59 ` Bruno Haible
0 siblings, 1 reply; 2+ messages in thread
From: Jim Meyering @ 2020-01-05 18:30 UTC (permalink / raw)
To: bug-gnulib@gnu.org List
[-- 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tests: skip thread-using tests when threading is disabled
2020-01-05 18:30 [PATCH] tests: skip thread-using tests when threading is disabled Jim Meyering
@ 2020-01-05 19:59 ` Bruno Haible
0 siblings, 0 replies; 2+ messages in thread
From: Bruno Haible @ 2020-01-05 19:59 UTC (permalink / raw)
To: bug-gnulib; +Cc: Jim Meyering
[-- Attachment #1: Type: text/plain, Size: 454 bytes --]
Hi Jim,
> 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.
Thanks for this. I prefer to move the #if around most of the file,
- because the main() function here already is quite complex,
- so that there's less trouble if someone wants to use --avoid=thread
some day.
Pushed the attached patch.
Bruno
[-- Attachment #2: 0001-tests-skip-thread-using-tests-when-threading-is-disa.patch --]
[-- Type: text/x-patch, Size: 3703 bytes --]
From a7903da07d3d18c23314aa0815adbb4058fd7cec 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 | 17 +++++++++++++++++
tests/test-setlocale_null-mt-all.c | 17 +++++++++++++++++
tests/test-setlocale_null-mt-one.c | 17 +++++++++++++++++
4 files changed, 61 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index c8a9dbf..6d5228e 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-05 Bruno Haible <bruno@clisp.org>
tests: Avoid GCC over-optimization caused by _GL_ARG_NONNULL attributes.
diff --git a/tests/test-nl_langinfo-mt.c b/tests/test-nl_langinfo-mt.c
index 55f9db9..de6cd99 100644
--- a/tests/test-nl_langinfo-mt.c
+++ b/tests/test-nl_langinfo-mt.c
@@ -18,6 +18,8 @@
#include <config.h>
+#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS
+
/* Specification. */
#include <langinfo.h>
@@ -236,3 +238,18 @@ main (int argc, char *argv[])
return 0;
}
+
+#else
+
+/* No multithreading available. */
+
+#include <stdio.h>
+
+int
+main ()
+{
+ 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 a4f91d9..19bdb55 100644
--- a/tests/test-setlocale_null-mt-all.c
+++ b/tests/test-setlocale_null-mt-all.c
@@ -18,6 +18,8 @@
#include <config.h>
+#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS
+
/* Specification. */
#include <locale.h>
@@ -131,6 +133,21 @@ main (int argc, char *argv[])
return 0;
}
+#else
+
+/* No multithreading available. */
+
+#include <stdio.h>
+
+int
+main ()
+{
+ fputs ("Skipping test: multithreading not enabled\n", stderr);
+ return 77;
+}
+
+#endif
+
/* Without locking, the results of this test would be:
glibc OK
musl libc crash < 10 sec
diff --git a/tests/test-setlocale_null-mt-one.c b/tests/test-setlocale_null-mt-one.c
index dc9d4aa..fd6083a 100644
--- a/tests/test-setlocale_null-mt-one.c
+++ b/tests/test-setlocale_null-mt-one.c
@@ -18,6 +18,8 @@
#include <config.h>
+#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS
+
/* Specification. */
#include <locale.h>
@@ -131,6 +133,21 @@ main (int argc, char *argv[])
return 0;
}
+#else
+
+/* No multithreading available. */
+
+#include <stdio.h>
+
+int
+main ()
+{
+ fputs ("Skipping test: multithreading not enabled\n", stderr);
+ return 77;
+}
+
+#endif
+
/* Without locking, the results of this test would be:
glibc OK
musl libc OK
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-05 19:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-05 18:30 [PATCH] tests: skip thread-using tests when threading is disabled Jim Meyering
2020-01-05 19:59 ` Bruno Haible
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).