Skip to content

Commit

Permalink
Merge "Clean up ACTS from gd cert test artifact"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jizheng Chu authored and Gerrit Code Review committed Nov 19, 2021
2 parents 12e602d + 534cb1d commit 4786b94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 42 deletions.
10 changes: 1 addition & 9 deletions system/gd/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,16 @@ $(bluetooth_cert_src_and_bin_zip): $(SOONG_ZIP) $(LOCAL_cert_test_sources) \
LOCAL_cert_generated_py_zip := \
$(SOONG_OUT_DIR)/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothFacadeAndCertGeneratedStub_py/gen/bluetooth_cert_generated_py.zip

LOCAL_acts_zip := $(HOST_OUT)/acts-dist/acts.zip

bluetooth_cert_tests_py_package_zip := \
$(call intermediates-dir-for,PACKAGING,bluetooth_cert_tests_py_package,HOST)/bluetooth_cert_tests.zip

$(bluetooth_cert_tests_py_package_zip): PRIVATE_cert_src_and_bin_zip := $(bluetooth_cert_src_and_bin_zip)
$(bluetooth_cert_tests_py_package_zip): PRIVATE_acts_zip := $(LOCAL_acts_zip)
$(bluetooth_cert_tests_py_package_zip): PRIVATE_cert_generated_py_zip := $(LOCAL_cert_generated_py_zip)
$(bluetooth_cert_tests_py_package_zip): $(SOONG_ZIP) $(LOCAL_acts_zip) \
$(bluetooth_cert_tests_py_package_zip): $(SOONG_ZIP) \
$(bluetooth_cert_src_and_bin_zip) $(bluetooth_cert_generated_py_zip)
@echo "Packaging Bluetooth Cert Tests into $@"
@rm -rf $(dir $@)bluetooth_cert_tests
@rm -rf $(dir $@)acts
@mkdir -p $(dir $@)bluetooth_cert_tests
@mkdir -p $(dir $@)acts
$(hide) unzip -o -q $(PRIVATE_acts_zip) "tools/test/connectivity/acts/framework/*" -d $(dir $@)acts
$(hide) unzip -o -q $(PRIVATE_cert_src_and_bin_zip) -d $(dir $@)bluetooth_cert_tests
$(hide) unzip -o -q $(PRIVATE_cert_generated_py_zip) -d $(dir $@)bluetooth_cert_tests
# Make all subdirectory of gd Python pacakages except lib64 and target
Expand All @@ -102,8 +96,6 @@ $(bluetooth_cert_tests_py_package_zip): $(SOONG_ZIP) $(LOCAL_acts_zip) \
-not -path "$(dir $@)bluetooth_cert_tests/lib64*"` \
; do (touch -a $$f/__init__.py) ; done
$(hide) $(SOONG_ZIP) -d -o $@ -C $(dir $@)bluetooth_cert_tests -D $(dir $@)bluetooth_cert_tests \
-P acts_framework \
-C $(dir $@)acts/tools/test/connectivity/acts/framework -D $(dir $@)acts/tools/test/connectivity/acts/framework \
-P blueberry -C packages/modules/Bluetooth/system/blueberry -D packages/modules/Bluetooth/system/blueberry \
-P llvm_binutils -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) \
-f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov \
Expand Down
42 changes: 9 additions & 33 deletions system/gd/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
install_requires = [
'grpcio',
'psutil',
'protobuf>=3.14.0',
]

host_executables = [
Expand All @@ -37,20 +38,6 @@
]


# Need to verify acts is importable in a new Python context
def is_acts_importable():
cmd = [sys.executable, '-c', 'import acts']
completed_process = subprocess.run(cmd, cwd=os.getcwd())
return completed_process.returncode == 0


def setup_acts_for_cmd_or_die(cmd_str):
acts_framework_dir = os.path.abspath('acts_framework')
acts_setup_bin = os.path.join(acts_framework_dir, 'setup.py')
cmd = [sys.executable, acts_setup_bin, cmd_str]
subprocess.run(cmd, cwd=acts_framework_dir, check=True)


def set_permissions_for_host_executables(outputs):
for file in outputs:
if os.path.basename(file) in host_executables:
Expand All @@ -62,24 +49,15 @@ def set_permissions_for_host_executables(outputs):

class InstallLocalPackagesForInstallation(install):

user_options = install.user_options + [
('reuse-acts', None, "Skip ACTS installation if already installed"),
]
boolean_options = install.boolean_options + ['reuse-acts']
def run(self):
install_args = [sys.executable, '-m', 'pip', 'install']
subprocess.check_call(install_args + ['--upgrade', 'pip'])

def initialize_options(self):
install.initialize_options(self)
self.reuse_acts = False
for package in install_requires:
self.announce('Installing %s...' % package, log.INFO)
subprocess.check_call(install_args + ['-v', '--no-cache-dir', package])
self.announce('Dependencies installed.')

def run(self):
if self.reuse_acts and is_acts_importable():
self.announce('Reusing existing ACTS installation', log.WARN)
else:
self.announce('Installing ACTS library', log.WARN)
setup_acts_for_cmd_or_die("install")
self.announce('ACTS installed.', log.WARN)
if not is_acts_importable():
raise DistutilsModuleError("Cannot import acts after installation")
install.run(self)
set_permissions_for_host_executables(self.get_outputs())

Expand All @@ -98,12 +76,10 @@ def main():
description="""Bluetooth Cert Tests Package""",
# Include root package so that bluetooth_packets_python3.so can be
# included as well
packages=[''] +
find_packages(exclude=['acts_framework', 'acts_framework.*', 'llvm_binutils', 'llvm_binutils.*']),
packages=[''] + find_packages(exclude=['llvm_binutils', 'llvm_binutils.*']),
install_requires=install_requires,
package_data={
'': host_executables + ['*.so', 'lib64/*.so', 'target/*', 'llvm_binutils/bin/*', 'llvm_binutils/lib64/*'],
'cert': ['all_test_cases'],
},
cmdclass={
'install': InstallLocalPackagesForInstallation,
Expand Down

0 comments on commit 4786b94

Please sign in to comment.