Merge "Scudo minimal runtime support for make"
diff --git a/core/Makefile b/core/Makefile
index 517410a..2ff9063 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -3045,33 +3045,42 @@
# -----------------------------------------------------------------
# host tools needed to build dist and OTA packages
-build_ota_package := true
-ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
-build_ota_package := false
-endif
ifeq ($(BUILD_OS),darwin)
-build_ota_package := false
-endif
-ifneq ($(strip $(SANITIZE_TARGET)),)
-build_ota_package := false
-endif
-ifeq ($(TARGET_PRODUCT),sdk)
-build_ota_package := false
-endif
-ifneq ($(filter generic%,$(TARGET_DEVICE)),)
-build_ota_package := false
-endif
-ifeq ($(TARGET_NO_KERNEL),true)
-build_ota_package := false
-endif
-ifeq ($(recovery_fstab),)
-build_ota_package := false
-endif
-ifeq ($(TARGET_BUILD_PDK),true)
-build_ota_package := false
+ build_ota_package := false
+ build_otatools_package := false
+else
+ # set build_ota_package, and allow opt-out below
+ build_ota_package := true
+ ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
+ build_ota_package := false
+ endif
+ ifneq ($(strip $(SANITIZE_TARGET)),)
+ build_ota_package := false
+ endif
+ ifeq ($(TARGET_PRODUCT),sdk)
+ build_ota_package := false
+ endif
+ ifneq ($(filter generic%,$(TARGET_DEVICE)),)
+ build_ota_package := false
+ endif
+ ifeq ($(TARGET_NO_KERNEL),true)
+ build_ota_package := false
+ endif
+ ifeq ($(recovery_fstab),)
+ build_ota_package := false
+ endif
+ ifeq ($(TARGET_BUILD_PDK),true)
+ build_ota_package := false
+ endif
+
+ # set build_otatools_package, and allow opt-out below
+ build_otatools_package := true
+ ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
+ build_otatools_package := false
+ endif
endif
-ifeq ($(build_ota_package),true)
+ifeq ($(build_otatools_package),true)
OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
$(HOST_OUT_EXECUTABLES)/aapt \
$(HOST_OUT_EXECUTABLES)/checkvintf \
@@ -3189,7 +3198,7 @@
.PHONY: otatools-package
otatools-package: $(BUILT_OTATOOLS_PACKAGE)
-endif # build_ota_package
+endif # build_otatools_package
# -----------------------------------------------------------------
# A zip of the directories that map to the target filesystem.
diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk
index 5171b8a..3590079 100644
--- a/core/cxx_stl_setup.mk
+++ b/core/cxx_stl_setup.mk
@@ -15,8 +15,7 @@
endif
ifeq ($($(my_prefix)OS),windows)
- # libc++ is not supported on mingw.
- my_cxx_stl := libstdc++
+ my_cxx_stl := libc++_static
endif
endif
else
@@ -38,9 +37,9 @@
endif
ifdef LOCAL_IS_HOST_MODULE
ifeq ($($(my_prefix)OS),windows)
- ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
- # libc++ is not supported on mingw.
- my_cxx_stl := libstdc++
+ ifneq ($(filter $(my_cxx_stl),libc++),)
+ # only libc++_static is supported on mingw.
+ my_cxx_stl := libc++_static
endif
endif
endif
@@ -52,8 +51,9 @@
darwin_dynamic_gcclibs := -lc -lSystem
darwin_static_gcclibs := NO_STATIC_HOST_BINARIES_ON_DARWIN
windows_dynamic_gcclibs := \
- -lmsvcr110 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 \
- -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt
+ -Wl,--start-group -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcr110 \
+ -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lpsapi \
+ -Wl,--end-group
windows_static_gcclibs := NO_STATIC_HOST_BINARIES_ON_WINDOWS
my_link_type := dynamic
@@ -100,6 +100,20 @@
my_cppflags += -nostdinc++
my_ldflags += -nodefaultlibs
my_cxx_ldlibs += $($($(my_prefix)OS)_$(my_link_type)_gcclibs)
+
+ ifeq ($($(my_prefix)OS),windows)
+ # Use SjLj exceptions for 32-bit. libgcc_eh implements SjLj
+ # exception model for 32-bit.
+ ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+ my_cppflags += -fsjlj-exceptions
+ endif
+ # Disable visibility annotations since we're using libc++ static
+ # library.
+ my_cppflags += -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
+ my_cppflags += -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS
+ # Use Win32 threads in libc++.
+ my_cppflags += -D_LIBCPP_HAS_THREAD_API_WIN32
+ endif
else
ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
my_static_libraries += libunwind_llvm
@@ -113,11 +127,7 @@
else ifeq ($(my_cxx_stl),ndk)
# Using an NDK STL. Handled in binary.mk.
else ifeq ($(my_cxx_stl),libstdc++)
- ifndef LOCAL_IS_HOST_MODULE
- $(error $(LOCAL_PATH): $(LOCAL_MODULE): libstdc++ is not supported for device modules)
- else ifneq ($($(my_prefix)OS),windows)
- $(error $(LOCAL_PATH): $(LOCAL_MODULE): libstdc++ is not supported on $($(my_prefix)OS))
- endif
+ $(error $(LOCAL_PATH): $(LOCAL_MODULE): libstdc++ is not supported)
else ifeq ($(my_cxx_stl),none)
ifdef LOCAL_IS_HOST_MODULE
my_cppflags += -nostdinc++
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index a56fd5e..14955f0 100644
--- a/core/dex_preopt_libart_boot.mk
+++ b/core/dex_preopt_libart_boot.mk
@@ -108,7 +108,7 @@
--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
--android-root=$(PRODUCT_OUT)/system \
- --multi-image --no-inline-from=core-oj.jar \
+ --no-inline-from=core-oj.jar \
--abort-on-hard-verifier-error \
--abort-on-soft-verifier-error \
$(PRODUCT_DEX_PREOPT_BOOT_FLAGS) $(GLOBAL_DEXPREOPT_FLAGS) $(ART_BOOT_IMAGE_EXTRA_ARGS) \
diff --git a/target/product/mainline_system.mk b/target/product/mainline_system.mk
index 8dec2d9..8d0611f 100644
--- a/target/product/mainline_system.mk
+++ b/target/product/mainline_system.mk
@@ -62,8 +62,10 @@
_my_whitelist := $(_base_mk_whitelist)
# Both /system and / are in system.img when PRODUCT_SHIPPING_API_LEVEL>=28.
+# Though we do have a new ramdisk partition for logical partitions.
_my_paths := \
$(TARGET_COPY_OUT_ROOT) \
$(TARGET_COPY_OUT_SYSTEM) \
+ $(TARGET_COPY_OUT_RAMDISK) \
$(call require-artifacts-in-path, $(_my_paths), $(_my_whitelist))
diff --git a/target/product/telephony_system.mk b/target/product/telephony_system.mk
index 3175c8a..0b1e8a2 100644
--- a/target/product/telephony_system.mk
+++ b/target/product/telephony_system.mk
@@ -18,6 +18,7 @@
# hardware, and install on the system partition.
PRODUCT_PACKAGES := \
+ ANS \
CarrierConfig \
CarrierDefaultApp \
Dialer \
diff --git a/target/product/vndk/current.txt b/target/product/vndk/current.txt
index b95060f..7d8409b 100644
--- a/target/product/vndk/current.txt
+++ b/target/product/vndk/current.txt
@@ -154,6 +154,7 @@
VNDK-core: android.hardware.wifi@1.2.so
VNDK-core: android.hidl.allocator@1.0.so
VNDK-core: android.hidl.memory.block@1.0.so
+VNDK-core: android.hidl.safe_union@1.0.so
VNDK-core: android.hidl.token@1.0.so
VNDK-core: android.hidl.token@1.0-utils.so
VNDK-core: android.system.net.netd@1.0.so
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index d5ab055..42f05a7 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -31,7 +31,6 @@
import re
import shlex
import shutil
-import subprocess
import sys
import common
@@ -52,54 +51,21 @@
Exception.__init__(self, message)
-def RunCommand(cmd, verbose=None, env=None):
- """Echo and run the given command.
-
- Args:
- cmd: the command represented as a list of strings.
- verbose: show commands being executed.
- env: a dictionary of additional environment variables.
- Returns:
- A tuple of the output and the exit code.
- """
- env_copy = None
- if env is not None:
- env_copy = os.environ.copy()
- env_copy.update(env)
- if verbose is None:
- verbose = OPTIONS.verbose
- if verbose:
- print("Running: " + " ".join(cmd))
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- env=env_copy)
- output, _ = p.communicate()
-
- if verbose:
- print(output.rstrip())
- return (output, p.returncode)
-
-
def GetVerityFECSize(partition_size):
cmd = ["fec", "-s", str(partition_size)]
- output, exit_code = RunCommand(cmd, False)
- if exit_code != 0:
- raise BuildImageError("Failed to GetVerityFECSize:\n{}".format(output))
+ output = common.RunAndCheckOutput(cmd, verbose=False)
return int(output)
def GetVerityTreeSize(partition_size):
cmd = ["build_verity_tree", "-s", str(partition_size)]
- output, exit_code = RunCommand(cmd, False)
- if exit_code != 0:
- raise BuildImageError("Failed to GetVerityTreeSize:\n{}".format(output))
+ output = common.RunAndCheckOutput(cmd, verbose=False)
return int(output)
def GetVerityMetadataSize(partition_size):
cmd = ["build_verity_metadata.py", "size", str(partition_size)]
- output, exit_code = RunCommand(cmd, False)
- if exit_code != 0:
- raise BuildImageError("Failed to GetVerityMetadataSize:\n{}".format(output))
+ output = common.RunAndCheckOutput(cmd, verbose=False)
return int(output)
@@ -125,10 +91,12 @@
Raises:
BuildImageError: On error.
"""
- env = {"POSIXLY_CORRECT": "1"}
+ env_copy = os.environ.copy()
+ env_copy["POSIXLY_CORRECT"] = "1"
cmd = ["du", "-s", path]
- output, exit_code = RunCommand(cmd, verbose=False, env=env)
- if exit_code != 0:
+ try:
+ output = common.RunAndCheckOutput(cmd, verbose=False, env=env_copy)
+ except common.ExternalError:
raise BuildImageError("Failed to get disk usage:\n{}".format(output))
# POSIX du returns number of blocks with block size 512
return int(output.split()[0]) * 512
@@ -160,16 +128,13 @@
The maximum image size.
Raises:
- BuildImageError: On error or getting invalid image size.
+ BuildImageError: On invalid image size.
"""
cmd = [avbtool, "add_%s_footer" % footer_type,
"--partition_size", str(partition_size), "--calc_max_image_size"]
cmd.extend(shlex.split(additional_args))
- output, exit_code = RunCommand(cmd)
- if exit_code != 0:
- raise BuildImageError(
- "Failed to calculate max image size:\n{}".format(output))
+ output = common.RunAndCheckOutput(cmd)
image_size = int(output)
if image_size <= 0:
raise BuildImageError(
@@ -250,9 +215,6 @@
salt: The salt to use (a hexadecimal string) or None.
additional_args: Additional arguments to pass to "avbtool add_hash_footer"
or "avbtool add_hashtree_footer".
-
- Raises:
- BuildImageError: On error.
"""
cmd = [avbtool, "add_%s_footer" % footer_type,
"--partition_size", partition_size,
@@ -266,10 +228,7 @@
cmd.extend(shlex.split(additional_args))
- output, exit_code = RunCommand(cmd)
- if exit_code != 0:
- raise BuildImageError(
- "Failed to add AVB footer:\n{}".format(output))
+ common.RunAndCheckOutput(cmd)
def AdjustPartitionSizeForVerity(partition_size, fec_supported):
@@ -324,19 +283,13 @@
padding_size):
cmd = ["fec", "-e", "-p", str(padding_size), sparse_image_path,
verity_path, verity_fec_path]
- output, exit_code = RunCommand(cmd)
- if exit_code != 0:
- raise BuildImageError(
- "Failed to build FEC data:\n{}".format(output))
+ common.RunAndCheckOutput(cmd)
def BuildVerityTree(sparse_image_path, verity_image_path):
cmd = ["build_verity_tree", "-A", FIXED_SALT, sparse_image_path,
verity_image_path]
- output, exit_code = RunCommand(cmd)
- if exit_code != 0:
- raise BuildImageError(
- "Failed to build verity tree:\n{}".format(output))
+ output = common.RunAndCheckOutput(cmd)
root, salt = output.split()
return root, salt
@@ -350,10 +303,7 @@
cmd.append("--signer_args=\"%s\"" % (' '.join(signer_args),))
if verity_disable:
cmd.append("--verity_disable")
- output, exit_code = RunCommand(cmd)
- if exit_code != 0:
- raise BuildImageError(
- "Failed to build verity metadata:\n{}".format(output))
+ common.RunAndCheckOutput(cmd)
def Append2Simg(sparse_image_path, unsparse_image_path, error_message):
@@ -367,9 +317,10 @@
BuildImageError: On error.
"""
cmd = ["append2simg", sparse_image_path, unsparse_image_path]
- output, exit_code = RunCommand(cmd)
- if exit_code != 0:
- raise BuildImageError("{}:\n{}".format(error_message, output))
+ try:
+ common.RunAndCheckOutput(cmd)
+ except:
+ raise BuildImageError(error_message)
def Append(target, file_to_append, error_message):
@@ -413,12 +364,11 @@
else:
return unsparse_image_path
inflate_command = ["simg2img", sparse_image_path, unsparse_image_path]
- inflate_output, exit_code = RunCommand(inflate_command)
- if exit_code != 0:
+ try:
+ common.RunAndCheckOutput(inflate_command)
+ except:
os.remove(unsparse_image_path)
- raise BuildImageError(
- "Error: '{}' failed with exit code {}:\n{}".format(
- inflate_command, exit_code, inflate_output))
+ raise
return unsparse_image_path
@@ -475,10 +425,7 @@
def ConvertBlockMapToBaseFs(block_map_file):
base_fs_file = common.MakeTempFile(prefix="script_gen_", suffix=".base_fs")
convert_command = ["blk_alloc_to_base_fs", block_map_file, base_fs_file]
- output, exit_code = RunCommand(convert_command)
- if exit_code != 0:
- raise BuildImageError(
- "Failed to call blk_alloc_to_base_fs:\n{}".format(output))
+ common.RunAndCheckOutput(convert_command)
return base_fs_file
@@ -729,12 +676,15 @@
raise BuildImageError(
"Error: unknown filesystem type: {}".format(fs_type))
- mkfs_output, exit_code = RunCommand(build_command)
- if exit_code != 0:
+ try:
+ mkfs_output = common.RunAndCheckOutput(build_command)
+ except:
try:
du = GetDiskUsage(in_dir)
du_str = "{} bytes ({} MB)".format(du, du // BYTES_IN_MB)
- except BuildImageError as e:
+ # Suppress any errors from GetDiskUsage() to avoid hiding the real errors
+ # from common.RunAndCheckOutput().
+ except Exception as e: # pylint: disable=broad-except
print(e, file=sys.stderr)
du_str = "unknown"
print(
@@ -750,10 +700,7 @@
int(prop_dict["image_size"]) // BYTES_IN_MB,
int(prop_dict["partition_size"]),
int(prop_dict["partition_size"]) // BYTES_IN_MB))
-
- raise BuildImageError(
- "Error: '{}' failed with exit code {}:\n{}".format(
- build_command, exit_code, mkfs_output))
+ raise
# Check if there's enough headroom space available for ext4 image.
if "partition_headroom" in prop_dict and fs_type.startswith("ext4"):
@@ -792,15 +739,12 @@
# Run e2fsck on the inflated image file
e2fsck_command = ["e2fsck", "-f", "-n", unsparse_image]
# TODO(b/112062612): work around e2fsck failure with SANITIZE_HOST=address
- env4e2fsck = {"ASAN_OPTIONS": "detect_odr_violation=0"}
- e2fsck_output, exit_code = RunCommand(e2fsck_command, env=env4e2fsck)
-
- os.remove(unsparse_image)
-
- if exit_code != 0:
- raise BuildImageError(
- "Error: '{}' failed with exit code {}:\n{}".format(
- e2fsck_command, exit_code, e2fsck_output))
+ env4e2fsck = os.environ.copy()
+ env4e2fsck["ASAN_OPTIONS"] = "detect_odr_violation=0"
+ try:
+ common.RunAndCheckOutput(e2fsck_command, env=env4e2fsck)
+ finally:
+ os.remove(unsparse_image)
def ImagePropFromGlobalDict(glob_dict, mount_point):
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index e381676..d1bfc8f 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -37,6 +37,7 @@
import blockimgdiff
import sparse_img
+
class Options(object):
def __init__(self):
platform_search_path = {
@@ -72,16 +73,13 @@
OPTIONS = Options()
-
# Values for "certificate" in apkcerts that mean special things.
SPECIAL_CERT_STRINGS = ("PRESIGNED", "EXTERNAL")
-
# The partitions allowed to be signed by AVB (Android verified boot 2.0).
AVB_PARTITIONS = ('boot', 'recovery', 'system', 'vendor', 'product',
'product_services', 'dtbo', 'odm')
-
# Partitions that should have their care_map added to META/care_map.pb
PARTITIONS_WITH_CARE_MAP = ('system', 'vendor', 'product', 'product_services',
'odm')
@@ -144,6 +142,36 @@
return subprocess.Popen(args, **kwargs)
+def RunAndCheckOutput(args, verbose=None, **kwargs):
+ """Runs the given command and returns the output.
+
+ Args:
+ args: The command represented as a list of strings.
+ verbose: Whether the commands should be shown (default to OPTIONS.verbose
+ if unspecified).
+ kwargs: Any additional args to be passed to subprocess.Popen(), such as env,
+ stdin, etc. stdout and stderr will default to subprocess.PIPE and
+ subprocess.STDOUT respectively unless caller specifies any of them.
+
+ Returns:
+ The output string.
+
+ Raises:
+ ExternalError: On non-zero exit from the command.
+ """
+ if verbose is None:
+ verbose = OPTIONS.verbose
+ proc = Run(args, verbose=verbose, **kwargs)
+ output, _ = proc.communicate()
+ if verbose:
+ print("{}".format(output.rstrip()))
+ if proc.returncode != 0:
+ raise ExternalError(
+ "Failed to run command '{}' (exit code {}):\n{}".format(
+ args, proc.returncode, output))
+ return output
+
+
def RoundUpTo4K(value):
rounded_up = value + 4095
return rounded_up - (rounded_up % 4096)
@@ -445,20 +473,13 @@
Returns:
A string of form "partition:rollback_index_location:key" that can be used to
build or verify vbmeta image.
-
- Raises:
- AssertionError: When it fails to extract the public key with avbtool.
"""
if key is None:
key = info_dict["avb_" + partition + "_key_path"]
avbtool = os.getenv('AVBTOOL') or info_dict["avb_avbtool"]
pubkey_path = MakeTempFile(prefix="avb-", suffix=".pubkey")
- proc = Run(
+ RunAndCheckOutput(
[avbtool, "extract_public_key", "--key", key, "--output", pubkey_path])
- stdoutdata, _ = proc.communicate()
- assert proc.returncode == 0, \
- "Failed to extract pubkey for {}:\n{}".format(
- partition, stdoutdata)
rollback_index_location = info_dict[
"avb_" + partition + "_rollback_index_location"]
@@ -561,10 +582,7 @@
fn = os.path.join(sourcedir, "recovery_dtbo")
cmd.extend(["--recovery_dtbo", fn])
- proc = Run(cmd)
- output, _ = proc.communicate()
- assert proc.returncode == 0, \
- "Failed to run mkbootimg of {}:\n{}".format(partition_name, output)
+ RunAndCheckOutput(cmd)
if (info_dict.get("boot_signer") == "true" and
info_dict.get("verity_key")):
@@ -579,10 +597,7 @@
cmd.extend([path, img.name,
info_dict["verity_key"] + ".pk8",
info_dict["verity_key"] + ".x509.pem", img.name])
- proc = Run(cmd)
- output, _ = proc.communicate()
- assert proc.returncode == 0, \
- "Failed to run boot_signer of {} image:\n{}".format(path, output)
+ RunAndCheckOutput(cmd)
# Sign the image if vboot is non-empty.
elif info_dict.get("vboot"):
@@ -600,10 +615,7 @@
info_dict["vboot_subkey"] + ".vbprivk",
img_keyblock.name,
img.name]
- proc = Run(cmd)
- proc.communicate()
- assert proc.returncode == 0, \
- "Failed to run vboot_signer of {} image:\n{}".format(path, output)
+ RunAndCheckOutput(cmd)
# Clean up the temp files.
img_unsigned.close()
@@ -620,11 +632,7 @@
args = info_dict.get("avb_" + partition_name + "_add_hash_footer_args")
if args and args.strip():
cmd.extend(shlex.split(args))
- proc = Run(cmd)
- output, _ = proc.communicate()
- assert proc.returncode == 0, \
- "Failed to run 'avbtool add_hash_footer' of {}:\n{}".format(
- partition_name, output)
+ RunAndCheckOutput(cmd)
img.seek(os.SEEK_SET, 0)
data = img.read()
@@ -696,12 +704,7 @@
cmd = ["unzip", "-o", "-q", filename, "-d", dirname]
if pattern is not None:
cmd.extend(pattern)
- proc = Run(cmd)
- stdoutdata, _ = proc.communicate()
- if proc.returncode != 0:
- raise ExternalError(
- "Failed to unzip input target-files \"{}\":\n{}".format(
- filename, stdoutdata))
+ RunAndCheckOutput(cmd)
tmp = MakeTempDir(prefix="targetfiles-")
m = re.match(r"^(.*[.]zip)\+(.*[.]zip)$", filename, re.IGNORECASE)
@@ -1280,7 +1283,7 @@
first_line = i + 4
f.close()
- Run([self.editor, "+%d" % (first_line,), self.pwfile]).communicate()
+ RunAndCheckOutput([self.editor, "+%d" % (first_line,), self.pwfile])
return self.ReadFile()
@@ -1408,10 +1411,7 @@
if isinstance(entries, basestring):
entries = [entries]
cmd = ["zip", "-d", zip_filename] + entries
- proc = Run(cmd)
- stdoutdata, _ = proc.communicate()
- assert proc.returncode == 0, \
- "Failed to delete {}:\n{}".format(entries, stdoutdata)
+ RunAndCheckOutput(cmd)
def ZipClose(zip_file):
@@ -1872,11 +1872,7 @@
'--output={}.new.dat.br'.format(self.path),
'{}.new.dat'.format(self.path)]
print("Compressing {}.new.dat with brotli".format(self.partition))
- proc = Run(brotli_cmd)
- stdoutdata, _ = proc.communicate()
- assert proc.returncode == 0, \
- 'Failed to compress {}.new.dat with brotli:\n{}'.format(
- self.partition, stdoutdata)
+ RunAndCheckOutput(brotli_cmd)
new_data_name = '{}.new.dat.br'.format(self.partition)
ZipWrite(output_zip,
diff --git a/tools/releasetools/test_build_image.py b/tools/releasetools/test_build_image.py
index 94c31ee..a2df278 100644
--- a/tools/releasetools/test_build_image.py
+++ b/tools/releasetools/test_build_image.py
@@ -23,7 +23,7 @@
import common
from build_image import (
AVBCalcMinPartitionSize, BLOCK_SIZE, BuildImageError, CheckHeadroom,
- RunCommand, SetUpInDirAndFsConfig)
+ SetUpInDirAndFsConfig)
class BuildImageTest(unittest.TestCase):
@@ -91,8 +91,9 @@
output_image = common.MakeTempFile(suffix='.img')
command = ['mkuserimg_mke2fs', input_dir, output_image, 'ext4',
'/system', '409600', '-j', '0']
- ext4fs_output, exit_code = RunCommand(command)
- self.assertEqual(0, exit_code)
+ proc = common.Run(command)
+ ext4fs_output, _ = proc.communicate()
+ self.assertEqual(0, proc.returncode)
prop_dict = {
'fs_type' : 'ext4',
diff --git a/tools/releasetools/test_common.py b/tools/releasetools/test_common.py
index 5179900..ec86eb2 100644
--- a/tools/releasetools/test_common.py
+++ b/tools/releasetools/test_common.py
@@ -334,8 +334,8 @@
self.assertFalse('Test2' in entries)
self.assertTrue('Test3' in entries)
- self.assertRaises(AssertionError, common.ZipDelete, zip_file.name,
- 'Test2')
+ self.assertRaises(
+ common.ExternalError, common.ZipDelete, zip_file.name, 'Test2')
with zipfile.ZipFile(zip_file.name, 'r') as check_zip:
entries = check_zip.namelist()
self.assertTrue('Test1' in entries)
@@ -782,7 +782,8 @@
'avb_system_rollback_index_location': 2,
}
self.assertRaises(
- AssertionError, common.GetAvbChainedPartitionArg, 'system', info_dict)
+ common.ExternalError, common.GetAvbChainedPartitionArg, 'system',
+ info_dict)
INFO_DICT_DEFAULT = {
'recovery_api_version': 3,
diff --git a/tools/releasetools/test_verity_utils.py b/tools/releasetools/test_verity_utils.py
index 580612f..f318b02 100644
--- a/tools/releasetools/test_verity_utils.py
+++ b/tools/releasetools/test_verity_utils.py
@@ -18,7 +18,6 @@
from __future__ import print_function
-import os
import os.path
import unittest
@@ -26,11 +25,14 @@
import common
import sparse_img
import test_utils
-import verity_utils
from rangelib import RangeSet
+from verity_utils import (
+ CreateHashtreeInfoGenerator, HashtreeInfo,
+ VerifiedBootVersion1HashtreeInfoGenerator)
-class VerityUtilsTest(unittest.TestCase):
+class VerifiedBootVersion1HashtreeInfoGeneratorTest(unittest.TestCase):
+
def setUp(self):
self.testdata_dir = test_utils.get_testdata_dir()
@@ -88,33 +90,33 @@
return output_file
- def test_VerifiedBootVersion1HashtreeInfoGenerator_create(self):
+ def test_CreateHashtreeInfoGenerator(self):
image_file = sparse_img.SparseImage(self._generate_image())
- generator = verity_utils.CreateHashtreeInfoGenerator(
+ generator = CreateHashtreeInfoGenerator(
'system', image_file, self.prop_dict)
self.assertEqual(
- verity_utils.VerifiedBootVersion1HashtreeInfoGenerator, type(generator))
+ VerifiedBootVersion1HashtreeInfoGenerator, type(generator))
self.assertEqual(self.partition_size, generator.partition_size)
self.assertTrue(generator.fec_supported)
- def test_VerifiedBootVersion1HashtreeInfoGenerator_decomposeImage(self):
+ def test_DecomposeSparseImage(self):
image_file = sparse_img.SparseImage(self._generate_image())
- generator = verity_utils.VerifiedBootVersion1HashtreeInfoGenerator(
+ generator = VerifiedBootVersion1HashtreeInfoGenerator(
self.partition_size, 4096, True)
generator.DecomposeSparseImage(image_file)
self.assertEqual(991232, generator.filesystem_size)
self.assertEqual(12288, generator.hashtree_size)
self.assertEqual(32768, generator.metadata_size)
- def test_VerifiedBootVersion1HashtreeInfoGenerator_parseHashtreeMetadata(
- self):
+ def test_ParseHashtreeMetadata(self):
image_file = sparse_img.SparseImage(self._generate_image())
- generator = verity_utils.VerifiedBootVersion1HashtreeInfoGenerator(
+ generator = VerifiedBootVersion1HashtreeInfoGenerator(
self.partition_size, 4096, True)
generator.DecomposeSparseImage(image_file)
+ # pylint: disable=protected-access
generator._ParseHashtreeMetadata()
self.assertEqual(
@@ -122,13 +124,12 @@
self.assertEqual(self.fixed_salt, generator.hashtree_info.salt)
self.assertEqual(self.expected_root_hash, generator.hashtree_info.root_hash)
- def test_VerifiedBootVersion1HashtreeInfoGenerator_validateHashtree_smoke(
- self):
- generator = verity_utils.VerifiedBootVersion1HashtreeInfoGenerator(
+ def test_ValidateHashtree_smoke(self):
+ generator = VerifiedBootVersion1HashtreeInfoGenerator(
self.partition_size, 4096, True)
generator.image = sparse_img.SparseImage(self._generate_image())
- generator.hashtree_info = info = verity_utils.HashtreeInfo()
+ generator.hashtree_info = info = HashtreeInfo()
info.filesystem_range = RangeSet(data=[0, 991232 / 4096])
info.hashtree_range = RangeSet(
data=[991232 / 4096, (991232 + 12288) / 4096])
@@ -138,13 +139,12 @@
self.assertTrue(generator.ValidateHashtree())
- def test_VerifiedBootVersion1HashtreeInfoGenerator_validateHashtree_failure(
- self):
- generator = verity_utils.VerifiedBootVersion1HashtreeInfoGenerator(
+ def test_ValidateHashtree_failure(self):
+ generator = VerifiedBootVersion1HashtreeInfoGenerator(
self.partition_size, 4096, True)
generator.image = sparse_img.SparseImage(self._generate_image())
- generator.hashtree_info = info = verity_utils.HashtreeInfo()
+ generator.hashtree_info = info = HashtreeInfo()
info.filesystem_range = RangeSet(data=[0, 991232 / 4096])
info.hashtree_range = RangeSet(
data=[991232 / 4096, (991232 + 12288) / 4096])
@@ -154,10 +154,9 @@
self.assertFalse(generator.ValidateHashtree())
- def test_VerifiedBootVersion1HashtreeInfoGenerator_generate(self):
+ def test_Generate(self):
image_file = sparse_img.SparseImage(self._generate_image())
- generator = verity_utils.CreateHashtreeInfoGenerator(
- 'system', 4096, self.prop_dict)
+ generator = CreateHashtreeInfoGenerator('system', 4096, self.prop_dict)
info = generator.Generate(image_file)
self.assertEqual(RangeSet(data=[0, 991232 / 4096]), info.filesystem_range)
diff --git a/tools/releasetools/verity_utils.py b/tools/releasetools/verity_utils.py
index 38ebcf5..c512ef3 100644
--- a/tools/releasetools/verity_utils.py
+++ b/tools/releasetools/verity_utils.py
@@ -63,10 +63,6 @@
raise NotImplementedError
-class VerifiedBootVersion2HashtreeInfoGenerator(HashtreeInfoGenerator):
- pass
-
-
class VerifiedBootVersion1HashtreeInfoGenerator(HashtreeInfoGenerator):
"""A class that parses the metadata of hashtree for a given partition."""