#include "libglnx.h"
#include "libostreetest.h"
+/* Return a newly-allocated mkdtemp/g_mkdtemp template path under TEST_TMPDIR
+ * (falling back to /var/tmp), e.g. "ostree-xattrs-test.XXXXXX". */
+char *
+ot_test_tmpdir_template (const char *basename_template)
+{
+ const char *test_tmpdir = g_getenv ("TEST_TMPDIR") ?: "/var/tmp";
+ return g_build_filename (test_tmpdir, basename_template, NULL);
+}
+
/* This function hovers in a quantum superposition of horrifying and
* beautiful. Future generations may interpret it as modern art.
*/
gboolean ot_test_run_libtest (const char *cmd, GError **error);
+char *ot_test_tmpdir_template (const char *basename_template);
+
OstreeRepo *ot_test_setup_repo (GCancellable *cancellable, GError **error);
gboolean ot_check_relabeling (gboolean *can_relabel, GError **error);
g_auto (GLnxTmpDir) tmpd = {
0,
};
- // Use /var/tmp to hope we get xattr support
- glnx_mkdtempat (AT_FDCWD, "/var/tmp/ostree-xattrs-test.XXXXXX", 0700, &tmpd, error);
+ // Use TEST_TMPDIR (or /var/tmp as fallback) to hope we get xattr support
+ g_autofree char *tmpd_tmpl = ot_test_tmpdir_template ("ostree-xattrs-test.XXXXXX");
+ glnx_mkdtempat (AT_FDCWD, tmpd_tmpl, 0700, &tmpd, error);
g_assert_no_error (local_error);
const char value[] = "foo";
if (r != 0)
{
- g_autofree gchar *message = g_strdup_printf (
- "Unable to set extended attributes in /var/tmp: %s", g_strerror (errno));
+ g_autofree gchar *message = g_strdup_printf ("Unable to set extended attributes in %s: %s",
+ tmpd_tmpl, g_strerror (errno));
g_test_skip (message);
return;
}
#include <stdlib.h>
#include <string.h>
+#include "libostreetest.h"
#include "ostree-libarchive-private.h"
#include <archive.h>
#include <archive_entry.h>
uid_t uid = getuid ();
gid_t gid = getgid ();
- td->tmpd = g_mkdtemp (g_strdup ("/var/tmp/test-libarchive-import-XXXXXX"));
+ td->tmpd = g_mkdtemp (ot_test_tmpdir_template ("test-libarchive-import-XXXXXX"));
g_assert_cmpint (0, ==, chdir (td->tmpd));
td->fd = openat (AT_FDCWD, "foo.tar.gz", O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, 0644);