New issue
Advanced search Search tips

Issue 657920 link

Starred by 1 user

Issue metadata

Status: Archived
Owner:
Closed: Feb 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug



Sign in to add a comment

autotest: internal cleanup: non-functional code in cros_host._try_stateful_update

Project Member Reported by lgoo...@google.com, Oct 20 2016

Issue description

I came across this bit of code in autotest cros_host._try_stateful_update:

https://chromium.git.corp.google.com/chromiumos/third_party/autotest/+/90d9561f49650344abc3c799751d2f658e6259c9/server/hosts/cros_host.py#520

 "test -f <file-name>; echo $?"

The return status of the shell command list is the exit status of the echo command, which is always 0, whether or not the file exists. It seems the loop is not actually checking existence of the test files.

 

Comment 1 by dshi@chromium.org, Oct 24 2016

Status: WontFix (was: Unconfirmed)
The echo output is the return code of the last command, e.g.,

$ true
$ echo $?
0
$ false
$ echo $?
1

Comment 2 by lgoo...@google.com, Oct 25 2016

Hmm, agreed, but I don't think cros_hosts parse the stdout to set result.exit_status. For code like this

  result = host.run('test -f no-such-file; echo $?')

where 'host' is a cros_host, result.exit_status is the exit status of the ssh command.

Ssh returns the exit status of the remote command, which is the exit status of the last command in the sequence (echo $?), which is always 0 (the echo always succeeds, no matter what the content of $? is).

Example for a DUT at 192.168.231.105:

  ssh root@192.168.231.105 'test -f no-such-file; echo $?' ; echo $?
  1
  0

The '1' is the stdout from the ssh command. The '0' is the exit status of the ssh command, which is what result.exit_status would return.

Status: Unconfirmed (was: WontFix)
I've run autotests to confirm this behavior, please take another look.


Comment 4 by dshi@chromium.org, Oct 25 2016

Cc: akes...@chromium.org
Owner: xixuan@chromium.org
assign to deputy, need to do some test to confirm the behavior.
Labels: -current-issue
I think you're right, A similar change has been made in new provision code flow: https://chromium-review.googlesource.com/#/c/403191/, but not here.
Status: Started (was: Unconfirmed)

Comment 8 by xixuan@chromium.org, Jan 19 2017

Labels: Hotlist-Fixit
Project Member

Comment 9 by bugdroid1@chromium.org, Feb 4 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/autotest/+/908b0758b40844685a9acf302e09757e5a2de6dd

commit 908b0758b40844685a9acf302e09757e5a2de6dd
Author: xixuan <xixuan@chromium.org>
Date: Sat Feb 04 04:01:51 2017

autotest: Return False when tmp files still exist after stateful update

This CL is just a duplicate of CL:403191, fix the bug that 'echo $?' always
return 0, which prevent |_try_stateful_update| returning False.

BUG= chromium:657920 
TEST=Ran the following commands locally:
host_dut = ssh_host.SSHHost('100.107.151.251')
cmd = 'test -f /var/tmp/provision_failed'
result = host_dut.run(cmd, ignore_status=True)
then Verify the 'result.exit_status'.

Change-Id: I6927f5872eb97ad65b82ffae56fae4a065002791
Reviewed-on: https://chromium-review.googlesource.com/418497
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>

[modify] https://crrev.com/908b0758b40844685a9acf302e09757e5a2de6dd/client/common_lib/hosts/base_classes.py
[modify] https://crrev.com/908b0758b40844685a9acf302e09757e5a2de6dd/server/hosts/cros_host.py

Labels: cros-infra-fixedit-q117
Status: Fixed (was: Started)

Comment 11 by dchan@google.com, Apr 17 2017

Labels: VerifyIn-59

Comment 12 by dchan@google.com, May 30 2017

Labels: VerifyIn-60
Labels: VerifyIn-61

Comment 14 by dchan@chromium.org, Oct 14 2017

Status: Archived (was: Fixed)

Sign in to add a comment