test_image: Quick refactor to utilize partitions for loopback mounts

Update to script, and tests, to utilize paritions for loopback mounts,
versus offsets which are causing issues with the newer builder kernels.

BUG=chromium:1002184
TEST='https://ci.chromium.org/p/chromeos/builders/general/Try/b8902666560041157600'

Change-Id: I3575ab56fa02a749565e07c2e5dfab71549c6656
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1793419
Reviewed-by: Jason Clinton <jclinton@chromium.org>
Reviewed-by: David Burger <dburger@chromium.org>
Tested-by: Mike Nichols <mikenichols@chromium.org>
Commit-Queue: Mike Nichols <mikenichols@chromium.org>
diff --git a/scripts/test_image.py b/scripts/test_image.py
index 2cc7125..ee72adf 100644
--- a/scripts/test_image.py
+++ b/scripts/test_image.py
@@ -12,6 +12,7 @@
 
 from chromite.lib import constants
 from chromite.lib import commandline
+from chromite.lib import image_lib
 from chromite.lib import image_test_lib
 from chromite.lib import osutils
 from chromite.lib import path_util
@@ -103,7 +104,12 @@
   image_file = FindImage(opts.image)
   tmp_in_chroot = path_util.FromChrootPath('/tmp')
   with osutils.TempDir(base_dir=tmp_in_chroot) as temp_dir:
-    with osutils.MountImageContext(image_file, temp_dir):
+    with image_lib.LoopbackPartitions(image_file, temp_dir) as image:
+      # Due to the lack of mount context, we mount the partitions
+      # but do not reference directly.  This will be removed with the
+      # submission of http://crrev/c/1795578
+      _ = image.Mount((constants.PART_ROOT_A,))[0]
+      _ = image.Mount((constants.PART_STATE,))[0]
       with osutils.ChdirContext(temp_dir):
         result = runner.run(all_tests)