ostree-sysroot: add debug option to help testing
authorJonathan Lebon <jlebon@redhat.com>
Fri, 19 Feb 2016 16:58:08 +0000 (11:58 -0500)
committerJonathan Lebon <jlebon@redhat.com>
Fri, 19 Feb 2016 16:58:08 +0000 (11:58 -0500)
If ostree is run in a test setup where it operates as root in a tmp
directory, it might cause issues to flag the deployments as immutable.
The test harness might simply be doing an `rm -rf` (effectively the case
for gnome-desktop-testing-runner), which will then fail.

We add a new debug option to the ostree_sysroot object using GLib's
GDebugKey functionality to allow our tests to communicate to ostree that
we don't want immutable deployments.

src/libostree/ostree-sysroot-deploy.c
src/libostree/ostree-sysroot-private.h
src/libostree/ostree-sysroot.c
tests/libtest.sh

index 3dcf39ff0d4e0f590698131734ee350db00e0c14..aa0349512dbbca2943c103b238576c5484b95bdc 100644 (file)
@@ -2035,9 +2035,12 @@ ostree_sysroot_deploy_tree (OstreeSysroot     *self,
                                       cancellable, error))
     goto out;
 
-  if (!ostree_sysroot_deployment_set_mutable (self, new_deployment, FALSE,
-                                              cancellable, error))
-    goto out;
+  if (!(self->debug_flags & OSTREE_SYSROOT_DEBUG_MUTABLE_DEPLOYMENTS))
+    {
+      if (!ostree_sysroot_deployment_set_mutable (self, new_deployment, FALSE,
+                                                  cancellable, error))
+        goto out;
+    }
 
   { ostree_cleanup_sepolicy_fscreatecon gpointer dummy = NULL;
 
index 0c38e269bdd013e384d6ecb73dd275b7f018d6a9..e0dc24fd071029044aa5f9a59c02d23f7de92ba8 100644 (file)
 
 G_BEGIN_DECLS
 
+typedef enum {
+
+  /* Don't flag deployments as immutable. */
+  OSTREE_SYSROOT_DEBUG_MUTABLE_DEPLOYMENTS = 1 << 0
+
+} OstreeSysrootDebugFlags;
+
 struct OstreeSysroot {
   GObject parent;
 
@@ -46,6 +53,7 @@ struct OstreeSysroot {
   /* Only access through ostree_sysroot_get_repo() */
   OstreeRepo *repo;
 
+  OstreeSysrootDebugFlags debug_flags;
 };
 
 #define OSTREE_SYSROOT_LOCKFILE "ostree/lock"
index 7a4686d8e3fb9a0dcc3e6474d856990d4c10d1d5..5ad2713ae83e40d425335fd3b107e1b5568b23c4 100644 (file)
@@ -153,6 +153,13 @@ ostree_sysroot_class_init (OstreeSysrootClass *klass)
 static void
 ostree_sysroot_init (OstreeSysroot *self)
 {
+  const GDebugKey keys[] = {
+    { "mutable-deployments", OSTREE_SYSROOT_DEBUG_MUTABLE_DEPLOYMENTS },
+  };
+
+  self->debug_flags = g_parse_debug_string (g_getenv("OSTREE_SYSROOT_DEBUG"),
+                                            keys, G_N_ELEMENTS (keys));
+
   self->sysroot_fd = -1;
   self->lock = (GLnxLockFile)GLNX_LOCK_FILE_INIT;
 }
index bd806f6df566b4b8c9e90105dda9e73387f1d0de..8cc4345faa042a9b35b08547dd5f5de52eb2403c 100644 (file)
@@ -22,6 +22,10 @@ test_tmpdir=$(pwd)
 
 export G_DEBUG=fatal-warnings
 
+# Don't flag deployments as immutable so that test harnesses can
+# easily clean up.
+export OSTREE_SYSROOT_DEBUG=mutable-deployments
+
 export TEST_GPG_KEYID_1="472CDAFA"
 export TEST_GPG_KEYID_2="CA950D41"
 export TEST_GPG_KEYID_3="DF444D67"