projects/guix·blob java-team · refs

198 lines · 5.3 KiB

1Taken from
2https://git.savannah.gnu.org/cgit/gdbm.git/commit/?id=5be83b4c5da7c6a68817908b19f8925af09e9b2c
3https://git.savannah.gnu.org/cgit/gdbm.git/commit/?id=6f165a8e1745dbd9b88f6fb6882dff7997cfdf74
4https://git.savannah.gnu.org/cgit/gdbm.git/commit/?id=aa9baca52ad155ae501ba586ff7b08f4b08e5434
5Can be removed with 1.26.
6
7From 5be83b4c5da7c6a68817908b19f8925af09e9b2c Mon Sep 17 00:00:00 2001
8From: Sergey Poznyakoff <[email protected]>
9Date: Thu, 10 Apr 2025 17:31:56 +0300
10Subject: Fix timeout calculation in lockwait signal test.
11
12* tests/t_lockwait.c (runtest_signal): mark start time right
13after setting alarm, not before it.
14---
15 tests/t_lockwait.c | 5 ++---
16 1 file changed, 2 insertions(+), 3 deletions(-)
17
18diff --git a/tests/t_lockwait.c b/tests/t_lockwait.c
19index a5e74c8..3547af7 100644
20--- a/tests/t_lockwait.c
21+++ b/tests/t_lockwait.c
22@@ -323,9 +323,6 @@ runtest_signal (struct timespec *ts)
23 struct sigaction act;
24 struct timeval now;
25
26- gettimeofday (&now, NULL);
27- start = tv_to_ms (&now);
28-
29 if (pipe (sig_fd))
30 {
31 perror ("pipe");
32@@ -341,6 +338,8 @@ runtest_signal (struct timespec *ts)
33 return -1;
34 }
35 alarm (ts_to_ms (&ts[1]) / MILLI);
36+ gettimeofday (&now, NULL);
37+ start = tv_to_ms (&now);
38 }
39
40 op.lock_wait = GDBM_LOCKWAIT_SIGNAL;
41--
42cgit v1.1
43
44From 6f165a8e1745dbd9b88f6fb6882dff7997cfdf74 Mon Sep 17 00:00:00 2001
45From: Sergey Poznyakoff <[email protected]>
46Date: Thu, 10 Apr 2025 21:07:41 +0300
47Subject: More fixes to lockwait test
48
49* tests/t_lockwait.c (sighan): Close fd.
50(runtest_signal): compensate for alarm(2) second precision
51---
52 tests/t_lockwait.c | 4 +++-
53 1 file changed, 3 insertions(+), 1 deletion(-)
54
55diff --git a/tests/t_lockwait.c b/tests/t_lockwait.c
56index 3547af7..b378819 100644
57--- a/tests/t_lockwait.c
58+++ b/tests/t_lockwait.c
59@@ -170,6 +170,7 @@ static void
60 sighan (int sig)
61 {
62 write (sig_fd[1], &sig, sizeof (sig));
63+ close (sig_fd[1]);
64 }
65
66 static int runtest_retry (struct timespec *ts);
67@@ -364,7 +365,8 @@ runtest_signal (struct timespec *ts)
68
69 pfd.fd = sig_fd[0];
70 pfd.events = POLLIN;
71- switch (poll (&pfd, 1, ts_to_ms (&ts[1]) - tv_to_ms (&now) + start)) {
72+ switch (poll (&pfd, 1,
73+ ts_to_ms (&ts[1]) - tv_to_ms (&now) + start + MILLI)) {
74 case 1:
75 break;
76
77--
78cgit v1.1
79
80From aa9baca52ad155ae501ba586ff7b08f4b08e5434 Mon Sep 17 00:00:00 2001
81From: Sergey Poznyakoff <[email protected]>
82Date: Fri, 11 Apr 2025 07:53:58 +0300
83Subject: Adjust timeouts for setitimer interface in lockwait test.
84
85* tests/t_lockwait.c: Setitimer (at least on some systems) restarts
86the timer set by alarm(2). To calculate the ETA of SIGALRM, call
87alarm after gdbm_open_ext returns.
88---
89 tests/t_lockwait.c | 66 ++++++++++++++++++++++++++++++++----------------------
90 1 file changed, 39 insertions(+), 27 deletions(-)
91
92diff --git a/tests/t_lockwait.c b/tests/t_lockwait.c
93index b378819..dfae838 100644
94--- a/tests/t_lockwait.c
95+++ b/tests/t_lockwait.c
96@@ -322,7 +322,6 @@ runtest_signal (struct timespec *ts)
97 if (!(ts[1].tv_sec == 0 && ts[1].tv_nsec == 0))
98 {
99 struct sigaction act;
100- struct timeval now;
101
102 if (pipe (sig_fd))
103 {
104@@ -338,9 +337,6 @@ runtest_signal (struct timespec *ts)
105 fprintf (stderr, "%s: sigaction: %s", progname, strerror (errno));
106 return -1;
107 }
108- alarm (ts_to_ms (&ts[1]) / MILLI);
109- gettimeofday (&now, NULL);
110- start = tv_to_ms (&now);
111 }
112
113 op.lock_wait = GDBM_LOCKWAIT_SIGNAL;
114@@ -354,42 +350,58 @@ runtest_signal (struct timespec *ts)
115 }
116 gdbm_close (dbf);
117
118- if (start > 0)
119+ if (!(ts[1].tv_sec == 0 && ts[1].tv_nsec == 0))
120 {
121 struct pollfd pfd;
122 struct timeval now;
123- int sig;
124+ int n, t, sig;
125
126- restart:
127+ alarm (ts_to_ms (&ts[1]) / MILLI);
128 gettimeofday (&now, NULL);
129+ start = tv_to_ms (&now);
130
131 pfd.fd = sig_fd[0];
132 pfd.events = POLLIN;
133- switch (poll (&pfd, 1,
134- ts_to_ms (&ts[1]) - tv_to_ms (&now) + start + MILLI)) {
135- case 1:
136- break;
137
138- case 0:
139- fprintf (stderr, "%s: failed waiting for alarm\n", progname);
140- return 1;
141-
142- default:
143- if (errno == EINTR) goto restart;
144- fprintf (stderr, "%s: poll: %s\n", progname, strerror (errno));
145- return 1;
146- }
147-
148- if (read (sig_fd[0], &sig, sizeof (sig)) != sizeof (sig))
149+ do
150 {
151- fprintf (stderr, "%s: read: %s\n", progname, strerror (errno));
152- return 1;
153+ gettimeofday (&now, NULL);
154+ t = ts_to_ms (&ts[1]) - tv_to_ms (&now) + start + MILLI;
155+ if (t < 0)
156+ {
157+ n = 0;
158+ break;
159+ }
160 }
161- close (sig_fd[0]);
162- if (sig != SIGALRM)
163+ while ((n = poll (&pfd, 1, t)) == -1 && errno == EINTR);
164+
165+ switch (n)
166 {
167- fprintf (stderr, "%s: unexpected data read\n", progname);
168+ case 1:
169+ if (read (sig_fd[0], &sig, sizeof (sig)) != sizeof (sig))
170+ {
171+ fprintf (stderr, "%s: read: %s\n", progname, strerror (errno));
172+ return 1;
173+ }
174+ close (sig_fd[0]);
175+ if (sig != SIGALRM)
176+ {
177+ fprintf (stderr, "%s: unexpected data read\n", progname);
178+ return 1;
179+ }
180+ break;
181+
182+ case 0:
183+ fprintf (stderr, "%s: failed waiting for alarm\n", progname);
184 return 1;
185+
186+ default:
187+ if (errno != EINTR)
188+ {
189+ fprintf (stderr, "%s: poll: %s\n",
190+ progname, strerror (errno));
191+ return 1;
192+ }
193 }
194 }
195
196--
197cgit v1.1
198