Skip to content

Commit

Permalink
tests/libostreetest: check $PWD not / for overlay
Browse files Browse the repository at this point in the history
This was originally part of #1199, but never got in. The work in #1218
is awesome for CI, though for the developer workflow, I find it much
easier to just set $TEST_TMPDIR to a non-overlayfs mount point. Teach
the test libraries to just look at $PWD rather than /.

Also export the function that does the overlayfs checking. Prep for a
future patch.

Closes: #1170
Approved by: cgwalters
  • Loading branch information
jlebon authored and rh-atomic-bot committed Sep 28, 2017
1 parent a8e8c5a commit 89f4926
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
47 changes: 31 additions & 16 deletions tests/libostreetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,44 @@ ot_test_setup_repo (GCancellable *cancellable,
return g_steal_pointer (&ret_repo);
}

gboolean
ot_check_for_overlay (gboolean *on_overlay,
GError **error)
{
/* Keep this in sync with the overlayfs bits in libtest.sh */
struct statfs stbuf;
const char *pwd = g_getenv ("PWD");
g_assert (pwd);
if (statfs (pwd, &stbuf) < 0)
return glnx_throw_errno (error);
#ifndef OVERLAYFS_SUPER_MAGIC
#define OVERLAYFS_SUPER_MAGIC 0x794c7630
#endif
*on_overlay = (stbuf.f_type == OVERLAYFS_SUPER_MAGIC);
return TRUE;
}

OstreeSysroot *
ot_test_setup_sysroot (GCancellable *cancellable,
GError **error)
{
if (!ot_test_run_libtest ("setup_os_repository \"archive\" \"syslinux\"", error))
return FALSE;

struct statfs stbuf;
{ g_autoptr(GString) buf = g_string_new ("mutable-deployments");
if (statfs ("/", &stbuf) < 0)
return glnx_null_throw_errno (error);
/* Keep this in sync with the overlayfs bits in libtest.sh */
#ifndef OVERLAYFS_SUPER_MAGIC
#define OVERLAYFS_SUPER_MAGIC 0x794c7630
#endif
if (stbuf.f_type == OVERLAYFS_SUPER_MAGIC)
{
g_print ("libostreetest: detected overlayfs\n");
g_string_append (buf, ",no-xattrs");
}
/* Make sure deployments are mutable */
g_setenv ("OSTREE_SYSROOT_DEBUG", buf->str, TRUE);
}
/* Keep this in sync with the overlayfs bits in libtest.sh */
gboolean on_overlay;
if (!ot_check_for_overlay (&on_overlay, error))
return FALSE;

g_autoptr(GString) buf = g_string_new ("mutable-deployments");
if (on_overlay)
{
g_print ("libostreetest: detected overlayfs\n");
g_string_append (buf, ",no-xattrs");
}

/* Make sure deployments are mutable */
g_setenv ("OSTREE_SYSROOT_DEBUG", buf->str, TRUE);

g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
return ostree_sysroot_new (sysroot_path);
Expand Down
3 changes: 3 additions & 0 deletions tests/libostreetest.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ gboolean ot_test_run_libtest (const char *cmd, GError **error);
OstreeRepo *ot_test_setup_repo (GCancellable *cancellable,
GError **error);

gboolean ot_check_for_overlay (gboolean *on_overlay,
GError **error);

OstreeSysroot *ot_test_setup_sysroot (GCancellable *cancellable,
GError **error);

Expand Down
2 changes: 1 addition & 1 deletion tests/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export OSTREE_GPG_HOME=${test_tmpdir}/gpghome/trusted
# See comment in ot-builtin-commit.c and https://github.com/ostreedev/ostree/issues/758
# Also keep this in sync with the bits in libostreetest.c
echo evaluating for overlayfs...
case $(stat -f --printf '%T' /) in
case $(stat -f --printf '%T' $PWD) in
overlayfs)
echo "overlayfs found; enabling OSTREE_NO_XATTRS"
export OSTREE_SYSROOT_DEBUG="${OSTREE_SYSROOT_DEBUG},no-xattrs"
Expand Down

0 comments on commit 89f4926

Please sign in to comment.