devmode-test: switch from mount_helper to chromite.lib.image_lib

The local mount_helper API is built on the mount_gpt_image.sh script
which can be a bit crufty/opaque when flakes/failures are hit.  Switch
to the pure Python chromite.lib.image_lib API which has better logging
and error triaging.  It also has better recovery when kernels flake.

This also has a nicer property of only having to mount the single
partition that we care about (stateful) rather than extraneous ones
we don't care about (rootfs).

BUG=chromium:1000719
TEST=`devinstall_test.py --verbose betty chromiumos_test_image.bin` still passes

Change-Id: I8a9fe29dd047fe0cc4e7a32a6f05fcbb8b326bbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crostestutils/+/1808025
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/devmode-test/devinstall_test.py b/devmode-test/devinstall_test.py
index 97512a1..bb62de3 100755
--- a/devmode-test/devinstall_test.py
+++ b/devmode-test/devinstall_test.py
@@ -28,11 +28,11 @@
 from chromite.lib import cros_build_lib
 from chromite.lib import cros_logging as logging
 from chromite.lib import dev_server_wrapper
+from chromite.lib import image_lib
 from chromite.lib import osutils
 from chromite.lib import remote_access
 from chromite.lib import vm
 
-from crostestutils.lib import mount_helper
 from crostestutils.lib import test_helper
 
 
@@ -93,16 +93,11 @@
   def _WipeDevInstall(self):
     """Wipes the devinstall state."""
     logging.info('Wiping /usr/local/bin from the image.')
-    r_mount_point = os.path.join(self.tmpdir, 'm')
-    s_mount_point = os.path.join(self.tmpdir, 's')
-    dev_image_path = os.path.join(s_mount_point, 'dev_image')
-    mount_helper.MountImage(self.working_image_path,
-                            r_mount_point, s_mount_point, read_only=False,
-                            safe=True)
-    try:
+    with image_lib.LoopbackPartitions(
+        self.working_image_path, destination=self.tmpdir) as image:
+      image.Mount(('STATE',), mount_opts=())
+      dev_image_path = os.path.join(self.tmpdir, 'dir-STATE', 'dev_image')
       osutils.RmDir(dev_image_path, sudo=True)
-    finally:
-      mount_helper.UnmountImage(r_mount_point, s_mount_point)
 
   def PrepareTest(self):
     """Pre-test modification to the image and env to setup test."""