Paul Eggert wrote:
> --- a/tests/test-c-strtod-mt.c
> +++ b/tests/test-c-strtod-mt.c
> @@ -104,6 +104,9 @@ main (int argc, char *argv[])
> if (setlocale (LC_ALL, "") == NULL)
> return 1;
>
> +#if (USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS \
> + || USE_WINDOWS_THREADS)
> +
> /* Create the threads. */
> gl_thread_create (thread1_func, NULL);
> gl_thread_create (thread2_func, NULL);
> @@ -119,6 +122,13 @@ main (int argc, char *argv[])
> }
>
> return 0;
> +
> +#else
> +
> + fputs ("Skipping test: multithreading not enabled\n", stderr);
> + return 77;
> +
> +#endif
> }
>
> #else
This code is already inside a
#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS ||
USE_WINDOWS_THREADS
condition. Therefore the #else branch here is dead code.
> diff --git a/tests/test-c-strtod-mt.sh b/tests/test-c-strtod-mt.sh
> index 8c0e6e9006..3e44ce6726 100755
> --- a/tests/test-c-strtod-mt.sh
> +++ b/tests/test-c-strtod-mt.sh
> @@ -20,11 +20,11 @@ else
> fi
>
> if test $LOCALE_FR != none; then
> - LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strtod-mt${EXEEXT} || exit 1
> + LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strtod-mt${EXEEXT} || exit
> fi
>
> if test $LOCALE_FR_UTF8 != none; then
> - LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-c-strtod-mt${EXEEXT} || exit 1
> + LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-c-strtod-mt${EXEEXT} || exit
> fi
>
> exit 0
I would write 'exit $?' instead of 'exit', for clarity. Yes, POSIX
<https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#exit>
specifies what 'exit' without argument means, but IMO it's an obscure feature.
Also, this code assumes that when test-c-strtod-mt is invoked twice and
it has exit status 77 in one case, it will have exit status 77 in the
other case as well. For maintainability it's better to not make such an
assumption.
2026-04-28 Bruno Haible <[email protected]>
c-strtod tests: Improve last patch.
* tests/test-c-strtof-mt.c: Revert addition of dead code.
* tests/test-c-strtod-mt.c: Likewise.
* tests/test-c-strtold-mt.c: Likewise.
* tests/test-c-strtof-mt.sh: Don't assume that if one invocation of the
test program has exit code 77, the other invocation will have exit code
77 as well.
* tests/test-c-strtod-mt.sh: Likewise.
* tests/test-c-strtold-mt.sh: Likewise.
diff --git a/tests/test-c-strtod-mt.c b/tests/test-c-strtod-mt.c
index 9e423f3758..f898a839e4 100644
--- a/tests/test-c-strtod-mt.c
+++ b/tests/test-c-strtod-mt.c
@@ -104,9 +104,6 @@ main (int argc, char *argv[])
if (setlocale (LC_ALL, "") == NULL)
return 1;
-#if (USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS \
- || USE_WINDOWS_THREADS)
-
/* Create the threads. */
gl_thread_create (thread1_func, NULL);
gl_thread_create (thread2_func, NULL);
@@ -122,13 +119,6 @@ main (int argc, char *argv[])
}
return 0;
-
-#else
-
- fputs ("Skipping test: multithreading not enabled\n", stderr);
- return 77;
-
-#endif
}
#else
diff --git a/tests/test-c-strtod-mt.sh b/tests/test-c-strtod-mt.sh
index 3e44ce6726..563816405b 100755
--- a/tests/test-c-strtod-mt.sh
+++ b/tests/test-c-strtod-mt.sh
@@ -19,12 +19,24 @@ else
exit 77
fi
+no_fail_status=0
+
if test $LOCALE_FR != none; then
- LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strtod-mt${EXEEXT} || exit
+ LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strtod-mt${EXEEXT}
+ case $? in
+ 0) ;;
+ 77) no_fail_status=77 ;;
+ *) exit 1 ;;
+ esac
fi
if test $LOCALE_FR_UTF8 != none; then
- LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-c-strtod-mt${EXEEXT} || exit
+ LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-c-strtod-mt${EXEEXT}
+ case $? in
+ 0) ;;
+ 77) no_fail_status=77 ;;
+ *) exit 1 ;;
+ esac
fi
-exit 0
+exit $no_fail_status
diff --git a/tests/test-c-strtof-mt.c b/tests/test-c-strtof-mt.c
index f80366790b..f0145a43bb 100644
--- a/tests/test-c-strtof-mt.c
+++ b/tests/test-c-strtof-mt.c
@@ -104,9 +104,6 @@ main (int argc, char *argv[])
if (setlocale (LC_ALL, "") == NULL)
return 1;
-#if (USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS \
- || USE_WINDOWS_THREADS)
-
/* Create the threads. */
gl_thread_create (thread1_func, NULL);
gl_thread_create (thread2_func, NULL);
@@ -122,13 +119,6 @@ main (int argc, char *argv[])
}
return 0;
-
-#else
-
- fputs ("Skipping test: multithreading not enabled\n", stderr);
- return 77;
-
-#endif
}
#else
diff --git a/tests/test-c-strtof-mt.sh b/tests/test-c-strtof-mt.sh
index f580e88c0f..c812668f2d 100755
--- a/tests/test-c-strtof-mt.sh
+++ b/tests/test-c-strtof-mt.sh
@@ -19,12 +19,24 @@ else
exit 77
fi
+no_fail_status=0
+
if test $LOCALE_FR != none; then
- LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strtof-mt${EXEEXT} || exit
+ LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strtof-mt${EXEEXT}
+ case $? in
+ 0) ;;
+ 77) no_fail_status=77 ;;
+ *) exit 1 ;;
+ esac
fi
if test $LOCALE_FR_UTF8 != none; then
- LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-c-strtof-mt${EXEEXT} || exit
+ LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-c-strtof-mt${EXEEXT}
+ case $? in
+ 0) ;;
+ 77) no_fail_status=77 ;;
+ *) exit 1 ;;
+ esac
fi
exit 0
diff --git a/tests/test-c-strtold-mt.c b/tests/test-c-strtold-mt.c
index 8b5fde38d9..110ea35af3 100644
--- a/tests/test-c-strtold-mt.c
+++ b/tests/test-c-strtold-mt.c
@@ -104,9 +104,6 @@ main (int argc, char *argv[])
if (setlocale (LC_ALL, "") == NULL)
return 1;
-#if (USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS \
- || USE_WINDOWS_THREADS)
-
/* Create the threads. */
gl_thread_create (thread1_func, NULL);
gl_thread_create (thread2_func, NULL);
@@ -122,13 +119,6 @@ main (int argc, char *argv[])
}
return 0;
-
-#else
-
- fputs ("Skipping test: multithreading not enabled\n", stderr);
- return 77;
-
-#endif
}
#else
diff --git a/tests/test-c-strtold-mt.sh b/tests/test-c-strtold-mt.sh
index 7394b2dfa7..b9c96c7b59 100755
--- a/tests/test-c-strtold-mt.sh
+++ b/tests/test-c-strtold-mt.sh
@@ -19,12 +19,24 @@ else
exit 77
fi
+no_fail_status=0
+
if test $LOCALE_FR != none; then
- LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strtold-mt${EXEEXT} || exit
+ LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strtold-mt${EXEEXT}
+ case $? in
+ 0) ;;
+ 77) no_fail_status=77 ;;
+ *) exit 1 ;;
+ esac
fi
if test $LOCALE_FR_UTF8 != none; then
- LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-c-strtold-mt${EXEEXT} || exit
+ LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-c-strtold-mt${EXEEXT}
+ case $? in
+ 0) ;;
+ 77) no_fail_status=77 ;;
+ *) exit 1 ;;
+ esac
fi
exit 0