Fix bug in service_stopper.
https://gerrit.chromium.org/gerrit/51254 introduced bug into the
service stopper logic where is_stopped was always true.
For example the most likely upstart status strings will create the
following values for is_stopped:
out_arr = ['tcsd start/running, process 507',
'tcsd stop/waiting',
'status: Unknown job: tcsd_bogus'
]
for out in out_arr:
is_stopped = 'start/running' not in out
print is_stopped
>>> False
>>> True
>>> True
Previous change incorrectly assummed find would return 0 for a match
and 1 for not but it should have instead key'd off -1 for no match.
BUG=chrome-os-partner:19561
TEST=hardware_TPMCheck passes
Reviewed-on: https://gerrit.chromium.org/gerrit/56025
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
(cherry picked from commit 7d6386a862470be63bc607fcc0c0eb2b288923df)
Change-Id: Ib554b4d44602ca4456d21b782237b4cff386cff2
Reviewed-on: https://gerrit.chromium.org/gerrit/56086
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Tested-by: Scott Zawalski <scottz@chromium.org>
diff --git a/client/cros/service_stopper.py b/client/cros/service_stopper.py
index 570ef47..0593bc9 100644
--- a/client/cros/service_stopper.py
+++ b/client/cros/service_stopper.py
@@ -43,7 +43,7 @@
for service in self.services_to_stop:
cmd = 'status %s' % service
out = utils.system_output(cmd, ignore_status=True)
- is_stopped = out.find('start/running') != 0
+ is_stopped = 'start/running' not in out
if is_stopped:
continue
try: