autotest: internal cleanup: non-functional code in cros_host._try_stateful_update |
|||||||||||
Issue descriptionI 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.
,
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.
,
Oct 25 2016
I've run autotests to confirm this behavior, please take another look.
,
Oct 25 2016
assign to deputy, need to do some test to confirm the behavior.
,
Nov 1 2016
,
Dec 9 2016
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.
,
Dec 9 2016
,
Jan 19 2017
,
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
,
Feb 4 2017
,
Apr 17 2017
,
May 30 2017
,
Aug 1 2017
,
Oct 14 2017
|
|||||||||||
►
Sign in to add a comment |
|||||||||||
Comment 1 by dshi@chromium.org
, Oct 24 2016