02_hurd.patch 10.0 KB

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