All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bird, Timothy" <Tim.Bird@sony.com>
To: Rafael Gago Castano <RGC@hms.se>
Cc: "fuego@lists.linuxfoundation.org" <fuego@lists.linuxfoundation.org>
Subject: Re: [Fuego] First steps with fuego
Date: Fri, 12 May 2017 18:05:57 +0000	[thread overview]
Message-ID: <ECADFF3FD767C149AD96A924E7EA6EAF1FA88BF0@USCULXMSG01.am.sony.com> (raw)
In-Reply-To: <HE1PR06MB30360BCB9F5F3BEB722E1BA3C2E20@HE1PR06MB3036.eurprd06.prod.outlook.com>



> -----Original Message-----
> From: Rafael Gago Castano on Friday, May 12, 2017 2:39 AM
>
> For some reason I didn't CC the previous mail to the mailing list but just to
> you.
> 
> > OK.  cmd *should* return the error code from the remote command.
> > If it's not, then that's a bug.
> 
> Yes, I was in a rush yesterday and I had no time to do the things properly, but
> I wrote a terse loop with while using "test -f" to poll for file existance on the
> DUT and it failed, so I wronlgy assumed that was a "cmd" error.
> 
> If I write this in the body of a test, the test gets early interrupted and never
> prints "after" (I'm using the ssh transport):
> 
>     echo "before"
>     cmd "test -f /tmp/nonexistant-file"
>     echo "after"
> 
> On the logs I see:
> 
> ++ echo before
> before
> ++ cmd 'test -f /tmp/nonexistant'
> ++ report_devlog 'cmd: test -f /tmp/nonexistant'
> ++ echo 'cmd: test -f /tmp/nonexistant'
> ++ ov_transport_cmd 'test -f /tmp/nonexistant'
> ++ case "$TRANSPORT" in
> ++ sshpass -e ssh -o ServerAliveInterval=30 -o StrictHostKeyChecking=no -o
> UserKnownHostsFile=/dev/null -o ConnectTimeout=30 -p 22
> root@192.168.1.2 'test -f /tmp/nonexistant'
> Warning: Permanently added '192.168.1.2' (ECDSA) to the list of known hosts.
> + signal_handler
> + echo 'in signal_handler'
> in signal_handler

The way Fuego core operates now, the test scripts are run with bash set -e
in effect.  That is, any command error (outside of an if, assignment, or
expression) will issue an error trap and move directly to post_test.
A command failure is interpreted as a hard error.  Possibly this is too aggressive,
but it is the same as the default behavior of Jenkins.

If you have a command that whose failure does not indicate test failure
(something optional, or a test), then you can wrap it like so:

  set +e
  cmd "this might fail, but don't stop the test"
  set -e

We have been contemplating changing this, but that's how it works right now.

> > Just FYI - I experimented a bit, and was able to do some conditional
> > waiting on the target with:
> >  ftc wait-for -t 60 "/bin/bash -c \"source $LOGDIR/prolog.sh ;
> ov_transport_cmd test -f /tmp/sync_file\""
> 
> > This could be improved syntactically, but it did work.  I envision extended
> 'ftc wait-for' to support
> > something like:
> >    ftc wait-for "target: test -f /tmp/sync_file"
> > for this style of board-side conditional test.
> 
> As fuego is writing the test for running in the host, the host is issuing shell
> comands to the DUT (kind of master-slave), so the HOST to DUT
> synchronization is already implicit. There already is a clear "happens before"
> relationship in place.
> 
> It's the other way around, the HOST syncing to the DUT that I couldn't fix. I
> was attempting something similar to this (untested):
> 
> FUEGO_SYNC_PREFIX=/tmp/fuego-sync/
> 
> # Just clear all the sync files from previous runs
> function on_test_start() {
>     cmd rm -rf $FUEGO_SYNC_PREFIX && mkdir $FUEGO_SYNC_PREFIX
>     #error handling
> }
> 
> function wait_for_dut() {
>     local FILE=$FUEGO_SYNC_PREFIX$1
>     local SEC=999999
>     if [[ ! -z $2 ]]; then
>         SEC=$2
>     fi
>     local ELAPSED=0
>     while [[ -n cmd "test -f $FILE" ]]; do
I'm not sure I follow the use of '-n' here.  Is 'test -f' noisy in one case
and silent in the other?  I would think that maybe it should be:
   while cmd "test -f $FILE" ; do

>         if [[ $ELAPSED -lt $SEC ]]; then
>             return 1
>         fi
>         sleep 1
>         ELAPSED=$((ELAPSED + 1))
>     done
>     cmd "rm $FILE"
>     return 0
> }
>

This looks like a good way to provide a generalized sync solution from target
to host, based on files.  I hope you don't mind if I copy parts of this if I implement
a synchronize function for the core. :-)

> > This is probably something that would be good to add to the board file.
> 
> I hand't thought that the board files are just sourced and that I can add
> variables there. That's powerful. In our case we have more than one serial
> port on each device though.
> 
> > That looks great.  I don't know the failure modes for the serial port
> transfers
> > so I can't say how robust this is, but it looks OK to me.  As long as stty
> observes
> > the timeouts, then things shouldn't get stuck.
> >
> > I have a minor preference for using TAP format for the test output for
> these types
> > of simple test  - basically formatting the output line as:
> > ok <testnum> test description
> > But that's not required, and I think this looks like a nice test.
> >
> > I'm trying to think how I can try this here.  I have my test board here with
> the
> > serial port connected to the serial console, but maybe I could wire up a
> second
> > one for testing.
> 
> Don't bother, I should had posted this as an RFC, I just found easier to share
> it as a patch than by copying snippets. As the test is done now it isn't
> guaranteed to work correctly, for doing this test properly the sender (HOST)
> would need to start sending (echo) after making sure that the DUT is
> listening (after the launched "dut_rx.sh" script is past the "cat" command =>
> cat launched as a subprocess). The test is failing for me today.

OK - but it's our first serial port, multi-node test, and I was excited to see it.
:-)
 -- Tim


  reply	other threads:[~2017-05-12 18:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09  9:49 [Fuego] First steps with fuego Rafael Gago Castano
2017-05-09 19:04 ` Bird, Timothy
2017-05-10  6:32   ` Rafael Gago Castano
2017-05-10 13:12   ` Rafael Gago Castano
2017-05-10 19:30     ` Bird, Timothy
     [not found]       ` <HE1PR06MB3036959D51FD5FBFC02208C8C2ED0@HE1PR06MB3036.eurprd06.prod.outlook.com>
     [not found]         ` <ECADFF3FD767C149AD96A924E7EA6EAF1FA88A98@USCULXMSG01.am.sony.com>
2017-05-12  9:38           ` Rafael Gago Castano
2017-05-12 18:05             ` Bird, Timothy [this message]
2017-05-15  8:21               ` Rafael Gago Castano
2017-05-12 14:33         ` Rafael Gago Castano
2017-05-12 18:39           ` Bird, Timothy
2017-05-15 13:57             ` Rafael Gago Castano
2017-05-15 22:37               ` Bird, Timothy
2017-05-16 14:38                 ` Rafael Gago Castano
2017-05-17  5:06                   ` Bird, Timothy
2017-05-17  6:35                     ` Rafael Gago Castano
2017-05-17 15:33                       ` Bird, Timothy
2017-05-22  8:23                         ` Rafael Gago Castano
2017-05-22 20:51                           ` Bird, Timothy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ECADFF3FD767C149AD96A924E7EA6EAF1FA88BF0@USCULXMSG01.am.sony.com \
    --to=tim.bird@sony.com \
    --cc=RGC@hms.se \
    --cc=fuego@lists.linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.