1 Description: Remove usage of PATH_MAX in tests to fix FTBFS on Hurd.
2 jcowgill: Removed Changelog changes
3 Author: Pino Toscano <toscano.pino@tiscali.it>
4 Origin: backport, https://github.com/mpruett/audiofile/commit/34c261034f1193a783196618f0052112e00fbcfe
5 Bug: https://github.com/mpruett/audiofile/pull/17
6 Bug-Debian: https://bugs.debian.org/762595
8 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
10 --- a/test/TestUtilities.cpp
11 +++ b/test/TestUtilities.cpp
13 #include "TestUtilities.h"
21 bool createTemporaryFile(const std::string &prefix, std::string *path)
22 @@ -35,12 +35,12 @@ bool createTemporaryFile(const std::stri
26 -bool createTemporaryFile(const char *prefix, char *path)
27 +bool createTemporaryFile(const char *prefix, char **path)
29 - snprintf(path, PATH_MAX, "/tmp/%s-XXXXXX", prefix);
30 - int fd = ::mkstemp(path);
36 + std::string pathString;
37 + bool result = createTemporaryFile(prefix, &pathString);
39 + *path = ::strdup(pathString.c_str());
42 --- a/test/TestUtilities.h
43 +++ b/test/TestUtilities.h
44 @@ -53,7 +53,7 @@ extern "C" {
48 -bool createTemporaryFile(const char *prefix, char *path);
49 +bool createTemporaryFile(const char *prefix, char **path);
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);
59 - char testFileName[PATH_MAX];
60 - if (!createTemporaryFile("floatto24", testFileName))
62 + if (!createTemporaryFile("floatto24", &testFileName))
64 fprintf(stderr, "Could not create temporary file.\n");
66 @@ -182,6 +182,7 @@ int main (int argc, char **argv)
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);
80 - char testFileName[PATH_MAX];
81 - if (!createTemporaryFile("sixteen-to-eight", testFileName))
83 + if (!createTemporaryFile("sixteen-to-eight", &testFileName))
85 fprintf(stderr, "Could not create temporary file.\n");
87 @@ -113,6 +113,7 @@ int main (int argc, char **argv)
95 --- a/test/testchannelmatrix.c
96 +++ b/test/testchannelmatrix.c
99 #include "TestUtilities.h"
101 -static char sTestFileName[PATH_MAX];
102 +static char *sTestFileName;
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,
110 - unlink(sTestFileName);
113 + unlink(sTestFileName);
114 + free(sTestFileName);
118 void ensure (int condition, const char *message)
119 @@ -76,7 +80,7 @@ int main (void)
120 afInitFileFormat(setup, AF_FILE_AIFFC);
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
132 #include "TestUtilities.h"
134 -static char sTestFileName[PATH_MAX];
135 +static char *sTestFileName;
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);
143 - unlink(sTestFileName);
146 + unlink(sTestFileName);
147 + free(sTestFileName);
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);
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
165 #include "TestUtilities.h"
167 -static char sTestFileName[PATH_MAX];
168 +static char *sTestFileName;
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);
176 - unlink(sTestFileName);
179 + unlink(sTestFileName);
180 + free(sTestFileName);
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);
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
198 #include "TestUtilities.h"
200 -static char sTestFileName[PATH_MAX];
201 +static char *sTestFileName;
203 #define FRAME_COUNT 200
210 - unlink(sTestFileName);
211 + unlink(sTestFileName);
213 + free(sTestFileName);
217 void ensure (int condition, const char *message)
218 @@ -127,7 +131,7 @@ int testmarkers (int fileformat)
222 - ensure(createTemporaryFile("testmarkers", sTestFileName),
223 + ensure(createTemporaryFile("testmarkers", &sTestFileName),
224 "could not create temporary file");
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);
233 - char testFileName[PATH_MAX];
234 - if (!createTemporaryFile("twentyfour", testFileName))
235 + char *testFileName;
236 + if (!createTemporaryFile("twentyfour", &testFileName))
238 fprintf(stderr, "could not create temporary file\n");
240 @@ -239,6 +239,7 @@ int main (int argc, char **argv)
243 unlink(testFileName);
244 + free(testFileName);
248 --- a/test/twentyfour2.c
249 +++ b/test/twentyfour2.c
252 #include "TestUtilities.h"
254 -static char sTestFileName[PATH_MAX];
255 +static char *sTestFileName;
257 #define FRAME_COUNT 10000
264 - unlink(sTestFileName);
265 + unlink(sTestFileName);
267 + free(sTestFileName);
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);
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
285 #include "TestUtilities.h"
287 -static char sTestFileName[PATH_MAX];
288 +static char *sTestFileName;
290 #define FRAME_COUNT 16
291 #define SAMPLE_COUNT FRAME_COUNT
292 @@ -62,9 +62,13 @@ void testalaw (int fileFormat);
299 - unlink(sTestFileName);
300 + unlink(sTestFileName);
302 + free(sTestFileName);
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);
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
320 #include "TestUtilities.h"
322 -static char sTestFileName[PATH_MAX];
323 +static char *sTestFileName;
330 - unlink(sTestFileName);
331 + unlink(sTestFileName);
333 + free(sTestFileName);
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);
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
351 #include "TestUtilities.h"
353 -static char sTestFileName[PATH_MAX];
354 +static char *sTestFileName;
356 #define FRAME_COUNT 16
357 #define SAMPLE_COUNT FRAME_COUNT
358 @@ -62,9 +62,13 @@ void testulaw (int fileFormat);
365 - unlink(sTestFileName);
366 + unlink(sTestFileName);
368 + free(sTestFileName);
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);
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);