Update device boot up detection logic for local instance.
Check the exit code of launch_cvd instead of looking for
VIRTUAL_DEVICE_BOOT_COMPLETED flag.
Bug: 118726580
Test: atest acloud_test &&
Repeatly test below two commands with different targets.
Targets:
aosp_cf_x86_phone-userdebug
aosp_cf_x86_auto-userdebug
Cmd:
acloud create --local-instance
acloud create --local-instance --local-image
Change-Id: I5d5da883e7f44eae9d2a67e3accbb9140f75f726
diff --git a/create/local_image_local_instance.py b/create/local_image_local_instance.py
index fb892ec..395cfe0 100644
--- a/create/local_image_local_instance.py
+++ b/create/local_image_local_instance.py
@@ -203,20 +203,15 @@
print("Exiting out")
sys.exit()
- process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
-
- boot_complete = False
- for line in iter(process.stdout.readline, b''):
- logger.debug(line.strip())
- # cvd is still running and got boot complete.
- if _BOOT_COMPLETE in line:
- boot_complete = True
- break
-
- if not boot_complete:
+ try:
+ # Check the result of launch_cvd command.
+ # An exit code of 0 is equivalent to VIRTUAL_DEVICE_BOOT_COMPLETED
+ logger.debug(subprocess.check_output(cmd, shell=True,
+ stderr=subprocess.STDOUT))
+ except subprocess.CalledProcessError as error:
raise errors.LaunchCVDFail(
- "Can't launch cuttlefish AVD. No %s found" % _BOOT_COMPLETE)
+ "Can't launch cuttlefish AVD.%s. \nFor more detail: "
+ "~/cuttlefish_runtime/launcher.log" % error.message)
@staticmethod
def _IsLaunchCVDInUse():