projects/guix·blob java-team · refs

381 lines · 10.0 KiB

1Description: Remove usage of PATH_MAX in tests to fix FTBFS on Hurd.
2 jcowgill: Removed Changelog changes
3Author: Pino Toscano <[email protected]>
4Origin: backport, https://github.com/mpruett/audiofile/commit/34c261034f1193a783196618f0052112e00fbcfe
5Bug: https://github.com/mpruett/audiofile/pull/17
6Bug-Debian: https://bugs.debian.org/762595
7---
8This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
9
10--- a/test/TestUtilities.cpp
11+++ b/test/TestUtilities.cpp
12@@ -21,8 +21,8 @@
13 #include "TestUtilities.h"
14
15 #include <limits.h>
16-#include <stdio.h>
17 #include <stdlib.h>
18+#include <string.h>
19 #include <unistd.h>
20
21 bool createTemporaryFile(const std::string &prefix, std::string *path)
22@@ -35,12 +35,12 @@ bool createTemporaryFile(const std::stri
23 return true;
24 }
25
26-bool createTemporaryFile(const char *prefix, char *path)
27+bool createTemporaryFile(const char *prefix, char **path)
28 {
29- snprintf(path, PATH_MAX, "/tmp/%s-XXXXXX", prefix);
30- int fd = ::mkstemp(path);
31- if (fd < 0)
32- return false;
33- ::close(fd);
34- return true;
35+ *path = NULL;
36+ std::string pathString;
37+ bool result = createTemporaryFile(prefix, &pathString);
38+ if (result)
39+ *path = ::strdup(pathString.c_str());
40+ return result;
41 }
42--- a/test/TestUtilities.h
43+++ b/test/TestUtilities.h
44@@ -53,7 +53,7 @@ extern "C" {
45
46 #include <stdbool.h>
47
48-bool createTemporaryFile(const char *prefix, char *path);
49+bool createTemporaryFile(const char *prefix, char **path);
50
51 #ifdef __cplusplus
52 }
53--- a/test/floatto24.c
54+++ b/test/floatto24.c
55@@ -86,8 +86,8 @@ int main (int argc, char **argv)
56 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
57 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32);
58
59- char testFileName[PATH_MAX];
60- if (!createTemporaryFile("floatto24", testFileName))
61+ char *testFileName;
62+ if (!createTemporaryFile("floatto24", &testFileName))
63 {
64 fprintf(stderr, "Could not create temporary file.\n");
65 exit(EXIT_FAILURE);
66@@ -182,6 +182,7 @@ int main (int argc, char **argv)
67 }
68
69 unlink(testFileName);
70+ free(testFileName);
71
72 exit(EXIT_SUCCESS);
73 }
74--- a/test/sixteen-to-eight.c
75+++ b/test/sixteen-to-eight.c
76@@ -57,8 +57,8 @@ int main (int argc, char **argv)
77 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_UNSIGNED, 8);
78 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
79
80- char testFileName[PATH_MAX];
81- if (!createTemporaryFile("sixteen-to-eight", testFileName))
82+ char *testFileName;
83+ if (!createTemporaryFile("sixteen-to-eight", &testFileName))
84 {
85 fprintf(stderr, "Could not create temporary file.\n");
86 exit(EXIT_FAILURE);
87@@ -113,6 +113,7 @@ int main (int argc, char **argv)
88
89 afCloseFile(file);
90 unlink(testFileName);
91+ free(testFileName);
92
93 exit(EXIT_SUCCESS);
94 }
95--- a/test/testchannelmatrix.c
96+++ b/test/testchannelmatrix.c
97@@ -39,7 +39,7 @@
98
99 #include "TestUtilities.h"
100
101-static char sTestFileName[PATH_MAX];
102+static char *sTestFileName;
103
104 const short samples[] = {300, -300, 515, -515, 2315, -2315, 9154, -9154};
105 #define SAMPLE_COUNT (sizeof (samples) / sizeof (short))
106@@ -47,7 +47,11 @@ const short samples[] = {300, -300, 515,
107
108 void cleanup (void)
109 {
110- unlink(sTestFileName);
111+ if (sTestFileName)
112+ {
113+ unlink(sTestFileName);
114+ free(sTestFileName);
115+ }
116 }
117
118 void ensure (int condition, const char *message)
119@@ -76,7 +80,7 @@ int main (void)
120 afInitFileFormat(setup, AF_FILE_AIFFC);
121
122 /* Write stereo data to test file. */
123- ensure(createTemporaryFile("testchannelmatrix", sTestFileName),
124+ ensure(createTemporaryFile("testchannelmatrix", &sTestFileName),
125 "could not create temporary file");
126 file = afOpenFile(sTestFileName, "w", setup);
127 ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
128--- a/test/testdouble.c
129+++ b/test/testdouble.c
130@@ -38,7 +38,7 @@
131
132 #include "TestUtilities.h"
133
134-static char sTestFileName[PATH_MAX];
135+static char *sTestFileName;
136
137 const double samples[] =
138 {1.0, 0.6, -0.3, 0.95, 0.2, -0.6, 0.9, 0.4, -0.22, 0.125, 0.1, -0.4};
139@@ -48,7 +48,11 @@ void testdouble (int fileFormat);
140
141 void cleanup (void)
142 {
143- unlink(sTestFileName);
144+ if (sTestFileName)
145+ {
146+ unlink(sTestFileName);
147+ free(sTestFileName);
148+ }
149 }
150
151 void ensure (int condition, const char *message)
152@@ -96,7 +100,7 @@ void testdouble (int fileFormat)
153 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_DOUBLE, 64);
154 afInitChannels(setup, AF_DEFAULT_TRACK, 2);
155
156- ensure(createTemporaryFile("testdouble", sTestFileName),
157+ ensure(createTemporaryFile("testdouble", &sTestFileName),
158 "could not create temporary file");
159 file = afOpenFile(sTestFileName, "w", setup);
160 ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
161--- a/test/testfloat.c
162+++ b/test/testfloat.c
163@@ -38,7 +38,7 @@
164
165 #include "TestUtilities.h"
166
167-static char sTestFileName[PATH_MAX];
168+static char *sTestFileName;
169
170 const float samples[] =
171 {1.0, 0.6, -0.3, 0.95, 0.2, -0.6, 0.9, 0.4, -0.22, 0.125, 0.1, -0.4};
172@@ -48,7 +48,11 @@ void testfloat (int fileFormat);
173
174 void cleanup (void)
175 {
176- unlink(sTestFileName);
177+ if (sTestFileName)
178+ {
179+ unlink(sTestFileName);
180+ free(sTestFileName);
181+ }
182 }
183
184 void ensure (int condition, const char *message)
185@@ -96,7 +100,7 @@ void testfloat (int fileFormat)
186 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32);
187 afInitChannels(setup, AF_DEFAULT_TRACK, 2);
188
189- ensure(createTemporaryFile("testfloat", sTestFileName),
190+ ensure(createTemporaryFile("testfloat", &sTestFileName),
191 "could not create temporary file");
192 file = afOpenFile(sTestFileName, "w", setup);
193 ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
194--- a/test/testmarkers.c
195+++ b/test/testmarkers.c
196@@ -32,15 +32,19 @@
197
198 #include "TestUtilities.h"
199
200-static char sTestFileName[PATH_MAX];
201+static char *sTestFileName;
202
203 #define FRAME_COUNT 200
204
205 void cleanup (void)
206 {
207+ if (sTestFileName)
208+ {
209 #ifndef DEBUG
210- unlink(sTestFileName);
211+ unlink(sTestFileName);
212 #endif
213+ free(sTestFileName);
214+ }
215 }
216
217 void ensure (int condition, const char *message)
218@@ -127,7 +131,7 @@ int testmarkers (int fileformat)
219
220 int main (void)
221 {
222- ensure(createTemporaryFile("testmarkers", sTestFileName),
223+ ensure(createTemporaryFile("testmarkers", &sTestFileName),
224 "could not create temporary file");
225
226 testmarkers(AF_FILE_AIFF);
227--- a/test/twentyfour.c
228+++ b/test/twentyfour.c
229@@ -71,8 +71,8 @@ int main (int argc, char **argv)
230 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24);
231 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
232
233- char testFileName[PATH_MAX];
234- if (!createTemporaryFile("twentyfour", testFileName))
235+ char *testFileName;
236+ if (!createTemporaryFile("twentyfour", &testFileName))
237 {
238 fprintf(stderr, "could not create temporary file\n");
239 exit(EXIT_FAILURE);
240@@ -239,6 +239,7 @@ int main (int argc, char **argv)
241 exit(EXIT_FAILURE);
242 }
243 unlink(testFileName);
244+ free(testFileName);
245
246 exit(EXIT_SUCCESS);
247 }
248--- a/test/twentyfour2.c
249+++ b/test/twentyfour2.c
250@@ -45,15 +45,19 @@
251
252 #include "TestUtilities.h"
253
254-static char sTestFileName[PATH_MAX];
255+static char *sTestFileName;
256
257 #define FRAME_COUNT 10000
258
259 void cleanup (void)
260 {
261+ if (sTestFileName)
262+ {
263 #ifndef DEBUG
264- unlink(sTestFileName);
265+ unlink(sTestFileName);
266 #endif
267+ free(sTestFileName);
268+ }
269 }
270
271 void ensure (int condition, const char *message)
272@@ -78,7 +82,7 @@ int main (void)
273 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
274 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24);
275
276- ensure(createTemporaryFile("twentyfour2", sTestFileName),
277+ ensure(createTemporaryFile("twentyfour2", &sTestFileName),
278 "could not create temporary file");
279 file = afOpenFile(sTestFileName, "w", setup);
280 ensure(file != NULL, "could not open test file for writing");
281--- a/test/writealaw.c
282+++ b/test/writealaw.c
283@@ -53,7 +53,7 @@
284
285 #include "TestUtilities.h"
286
287-static char sTestFileName[PATH_MAX];
288+static char *sTestFileName;
289
290 #define FRAME_COUNT 16
291 #define SAMPLE_COUNT FRAME_COUNT
292@@ -62,9 +62,13 @@ void testalaw (int fileFormat);
293
294 void cleanup (void)
295 {
296+ if (sTestFileName)
297+ {
298 #ifndef DEBUG
299- unlink(sTestFileName);
300+ unlink(sTestFileName);
301 #endif
302+ free(sTestFileName);
303+ }
304 }
305
306 void ensure (int condition, const char *message)
307@@ -113,7 +117,7 @@ void testalaw (int fileFormat)
308 afInitFileFormat(setup, fileFormat);
309 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
310
311- ensure(createTemporaryFile("writealaw", sTestFileName),
312+ ensure(createTemporaryFile("writealaw", &sTestFileName),
313 "could not create temporary file");
314 file = afOpenFile(sTestFileName, "w", setup);
315 afFreeFileSetup(setup);
316--- a/test/writeraw.c
317+++ b/test/writeraw.c
318@@ -44,13 +44,17 @@
319
320 #include "TestUtilities.h"
321
322-static char sTestFileName[PATH_MAX];
323+static char *sTestFileName;
324
325 void cleanup (void)
326 {
327+ if (sTestFileName)
328+ {
329 #ifndef DEBUG
330- unlink(sTestFileName);
331+ unlink(sTestFileName);
332 #endif
333+ free(sTestFileName);
334+ }
335 }
336
337 void ensure (int condition, const char *message)
338@@ -84,7 +88,7 @@ int main (int argc, char **argv)
339 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
340 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
341
342- ensure(createTemporaryFile("writeraw", sTestFileName),
343+ ensure(createTemporaryFile("writeraw", &sTestFileName),
344 "could not create temporary file");
345 file = afOpenFile(sTestFileName, "w", setup);
346 ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing");
347--- a/test/writeulaw.c
348+++ b/test/writeulaw.c
349@@ -53,7 +53,7 @@
350
351 #include "TestUtilities.h"
352
353-static char sTestFileName[PATH_MAX];
354+static char *sTestFileName;
355
356 #define FRAME_COUNT 16
357 #define SAMPLE_COUNT FRAME_COUNT
358@@ -62,9 +62,13 @@ void testulaw (int fileFormat);
359
360 void cleanup (void)
361 {
362+ if (sTestFileName)
363+ {
364 #ifndef DEBUG
365- unlink(sTestFileName);
366+ unlink(sTestFileName);
367 #endif
368+ free(sTestFileName);
369+ }
370 }
371
372 void ensure (int condition, const char *message)
373@@ -113,7 +117,7 @@ void testulaw (int fileFormat)
374 afInitFileFormat(setup, fileFormat);
375 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
376
377- ensure(createTemporaryFile("writeulaw", sTestFileName),
378+ ensure(createTemporaryFile("writeulaw", &sTestFileName),
379 "could not create temporary file");
380 file = afOpenFile(sTestFileName, "w", setup);
381 afFreeFileSetup(setup);