[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] tests: don’t skip if LONG_MAX < pid
From: |
Paul Eggert |
Subject: |
[PATCH 3/3] tests: don’t skip if LONG_MAX < pid |
Date: |
Fri, 29 Dec 2023 19:23:01 -0800 |
* modules/pthread_sigmask-tests, modules/sigprocmask-tests:
(Depends-on): Add inttypes.
* tests/test-pthread_sigmask1.c, tests/test-sigprocmask.c:
Include inttypes.h.
(main): Don’t skip test if pid exceeds LONG_MAX.
---
ChangeLog | 7 +++++++
modules/pthread_sigmask-tests | 1 +
modules/sigprocmask-tests | 1 +
tests/test-pthread_sigmask1.c | 12 +++---------
tests/test-sigprocmask.c | 12 +++---------
5 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 41a85b3cf1..02edd93ac7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2023-12-29 Paul Eggert <eggert@cs.ucla.edu>
+ tests: don’t skip if LONG_MAX < pid
+ * modules/pthread_sigmask-tests, modules/sigprocmask-tests:
+ (Depends-on): Add inttypes.
+ * tests/test-pthread_sigmask1.c, tests/test-sigprocmask.c:
+ Include inttypes.h.
+ (main): Don’t skip test if pid exceeds LONG_MAX.
+
Omit no-longer-needed pragmas
* lib/anytostr.c, lib/poll.c, lib/regex.c:
Omit pragmas that should no longer be needed.
diff --git a/modules/pthread_sigmask-tests b/modules/pthread_sigmask-tests
index e4e0d5b019..d40a013687 100644
--- a/modules/pthread_sigmask-tests
+++ b/modules/pthread_sigmask-tests
@@ -5,6 +5,7 @@ tests/signature.h
tests/macros.h
Depends-on:
+inttypes
sleep
pthread-thread
diff --git a/modules/sigprocmask-tests b/modules/sigprocmask-tests
index 80fcd81fea..aba383e20a 100644
--- a/modules/sigprocmask-tests
+++ b/modules/sigprocmask-tests
@@ -4,6 +4,7 @@ tests/signature.h
tests/macros.h
Depends-on:
+inttypes
sleep
configure.ac:
diff --git a/tests/test-pthread_sigmask1.c b/tests/test-pthread_sigmask1.c
index 06158f9d58..c728bba5e8 100644
--- a/tests/test-pthread_sigmask1.c
+++ b/tests/test-pthread_sigmask1.c
@@ -24,7 +24,7 @@
SIGNATURE_CHECK (pthread_sigmask, int, (int, const sigset_t *, sigset_t *));
#include <errno.h>
-#include <limits.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -45,15 +45,9 @@ int
main ()
{
sigset_t set;
- pid_t pid = getpid ();
+ intmax_t pid = getpid ();
char command[80];
- if (LONG_MAX < pid)
- {
- fputs ("Skipping test: pid too large\n", stderr);
- return 77;
- }
-
signal (SIGINT, sigint_handler);
sigemptyset (&set);
@@ -66,7 +60,7 @@ main ()
ASSERT (pthread_sigmask (SIG_BLOCK, &set, NULL) == 0);
/* Request a SIGINT signal from outside. */
- sprintf (command, "sh -c 'sleep 1; kill -INT %ld' &", (long) pid);
+ sprintf (command, "sh -c 'sleep 1; kill -INT %"PRIdMAX"' &", pid);
ASSERT (system (command) == 0);
/* Wait. */
diff --git a/tests/test-sigprocmask.c b/tests/test-sigprocmask.c
index 640a8e2eb0..f9cd86677f 100644
--- a/tests/test-sigprocmask.c
+++ b/tests/test-sigprocmask.c
@@ -24,7 +24,7 @@
SIGNATURE_CHECK (sigprocmask, int, (int, const sigset_t *, sigset_t *));
#include <errno.h>
-#include <limits.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -45,15 +45,9 @@ int
main ()
{
sigset_t set;
- pid_t pid = getpid ();
+ intmax_t pid = getpid ();
char command[80];
- if (LONG_MAX < pid)
- {
- fputs ("Skipping test: pid too large\n", stderr);
- return 77;
- }
-
signal (SIGINT, sigint_handler);
sigemptyset (&set);
@@ -67,7 +61,7 @@ main ()
ASSERT (sigprocmask (SIG_BLOCK, &set, NULL) == 0);
/* Request a SIGINT signal from outside. */
- sprintf (command, "sh -c 'sleep 1; kill -INT %ld' &", (long) pid);
+ sprintf (command, "sh -c 'sleep 1; kill -INT %"PRIdMAX"' &", pid);
ASSERT (system (command) == 0);
/* Wait. */
--
2.40.1