[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [XTF PATCH v2] xtf-runner: support two modes for getting output



On Thu, Aug 11, 2016 at 05:27:56PM +0100, Ian Jackson wrote:
> Wei Liu writes ("[XTF PATCH v2] xtf-runner: support two modes for getting 
> output"):
> > We need two modes for getting output:
> ...
> > +        logfile = open(fn, "rb")
> > +    except IOError as e:
> > +        # Create file if it doesn't exist
> > +        if e.errno == 2:
> > +            logfile = open(fn, "ab")
> > +            logfile.close()
> > +            logfile = open(fn, "rb")
> > +        else:
> > +            raise e
> 
> This is perverse.  Why not just open it O_CREAT|O_RDONLY ?  If Python
> can't do that then unconditionally opening it O_CREAT|O_RDWR would do.
> 

The open call doesn't accept O_CREAT|O_RDONLY.

Andy my experiment showed that "rb" doesn't create the file.

> > +    logfile.seek(0, 2) # Go to end of file
> 
> Does Python not have SEEK_END somewhere ?

There is one, but that's in os module.

Python official document is using numeric values directly.

> 
> > +    lines = logfile.readlines()
> > +    logfile.close()
> > +
> > +    if len(lines) == 0:
> > +        raise RunnerError("Test output empty")
> 
> I think you are racing with xenconsoled here.  How do you know that
> all the output has arrived ?
> 

Unfortunately there doesn't seem to be a direct way to synchronise
between the two.

Maybe the best bet is to watch the tty node for it to go away?

Wei.

> Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.