summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-10-01 15:39:46 -0400
committerMike Frysinger <vapier@gentoo.org>2011-10-01 15:39:46 -0400
commit8744dc172388922e873ebcb019dd478849a1ee98 (patch)
treea2df9a6819ebebb76ceb7ba225ad89c4c4271360
parentd174d2c46591b15bd875ee2f7e46a594eaf9eccb (diff)
tests: add fallback for mktemp()
If SuSv3 legacy support is disabled, then mktemp() isn't available, and we end up getting a lot of build errors. So add a fallback built on top of tempnam() since that currently cannot be disabled. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--test/test-skeleton.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test-skeleton.c b/test/test-skeleton.c
index 752158405..0be4aa10b 100644
--- a/test/test-skeleton.c
+++ b/test/test-skeleton.c
@@ -87,6 +87,28 @@ add_temp_file (const char *name)
}
}
+#if defined __UCLIBC__ && !defined __UCLIBC_SUSV3_LEGACY__
+/* mktemp() isn't available, so fake it with tempnam().
+ We make a lot of assumptions about the format of the
+ "template" name, but we aren't testing that, so eh. */
+__attribute__ ((unused))
+static char *mktemp(char *template)
+{
+ char *dir, *pfx, *s;
+
+ dir = strdup (template);
+ pfx = strrchr (dir, '/');
+ *pfx++ = '\0';
+ s = strstr (pfx, "XXXXXX");
+ *s = '\0';
+
+ s = tempnam (dir, pfx);
+ strcpy (template, s);
+ free (s);
+ return template;
+}
+#endif
+
/* Delete all temporary files. */
static void
delete_temp_files (void)