relesetools: Enable releasetools_test in presubmit.
About half of the testcases rely on external tools (i.e. the ones in
`otatools.zip`, which are external to releasetools module, but still
built by Android). It's WAI as releasetools scripts are mostly for
gluing purpose.
However, the current support in Soong doesn't allow packing the helper
modules as part of the built releasetools_test. This CL adds a decorator
that allows declaring external dependencies in testcases, which will be
skipped while running in presubmit. It doesn't affect local invocation
of `atest releasetools_test`.
Fixes: 112080715
Test: `atest releasetools_test`
Test: TreeHugger; check that releasetools_test is invoked (and test
passes).
Change-Id: I8fdeb6549023cf5ddeb79d610c7c37cf9f13d3cc
diff --git a/tools/releasetools/test_build_image.py b/tools/releasetools/test_build_image.py
index 1cebd0c..b24805f 100644
--- a/tools/releasetools/test_build_image.py
+++ b/tools/releasetools/test_build_image.py
@@ -18,12 +18,13 @@
import os.path
import common
+import test_utils
from build_image import (
- BuildImageError, CheckHeadroom, GetFilesystemCharacteristics, SetUpInDirAndFsConfig)
-from test_utils import ReleaseToolsTestCase
+ BuildImageError, CheckHeadroom, GetFilesystemCharacteristics,
+ SetUpInDirAndFsConfig)
-class BuildImageTest(ReleaseToolsTestCase):
+class BuildImageTest(test_utils.ReleaseToolsTestCase):
# Available: 1000 blocks.
EXT4FS_OUTPUT = (
@@ -48,6 +49,7 @@
self.assertRaises(
BuildImageError, CheckHeadroom, self.EXT4FS_OUTPUT, prop_dict)
+ @test_utils.SkipIfExternalToolsUnavailable()
def test_CheckHeadroom_WrongFsType(self):
prop_dict = {
'fs_type' : 'f2fs',
@@ -72,6 +74,7 @@
self.assertRaises(
AssertionError, CheckHeadroom, self.EXT4FS_OUTPUT, prop_dict)
+ @test_utils.SkipIfExternalToolsUnavailable()
def test_CheckHeadroom_WithMke2fsOutput(self):
"""Tests the result parsing from actual call to mke2fs."""
input_dir = common.MakeTempDir()
@@ -177,13 +180,14 @@
self.assertIn('fs-config-root\n', fs_config_data)
self.assertEqual('/', prop_dict['mount_point'])
+ @test_utils.SkipIfExternalToolsUnavailable()
def test_GetFilesystemCharacteristics(self):
input_dir = common.MakeTempDir()
output_image = common.MakeTempFile(suffix='.img')
command = ['mkuserimg_mke2fs', input_dir, output_image, 'ext4',
'/system', '409600', '-j', '0']
proc = common.Run(command)
- ext4fs_output, _ = proc.communicate()
+ proc.communicate()
self.assertEqual(0, proc.returncode)
output_file = common.MakeTempFile(suffix='.img')