On Thu, Jun 10, 2010 at 5:02 PM, Michael Goldish <[email protected]> wrote:
>
> On 06/10/2010 08:10 AM, Chen Cao wrote:
> > (match, s) = session.read_up_to_prompt()
> > if not match:
> > raise error.TestError("Could not get guest time")
> > s = re.findall(time_filter_re, s)[0]
> >
> > Sometimes "match" is not None, but does not contain time string with
> > illegal format.
> > So we need to check the return value of re.findall before get the value
> > by subindexing.
> >
> > And add debug info when error encountered.
> >
> > Signed-off-by: Chen Cao <[email protected]>
> > ---
> > client/tests/kvm/kvm_test_utils.py | 10 ++++++++--
> > 1 files changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/client/tests/kvm/kvm_test_utils.py
> > b/client/tests/kvm/kvm_test_utils.py
> > index 24e2bf5..c0627b3 100644
> > --- a/client/tests/kvm/kvm_test_utils.py
> > +++ b/client/tests/kvm/kvm_test_utils.py
> > @@ -201,9 +201,15 @@ def get_time(session, time_command, time_filter_re,
> > time_format):
> > host_time = time.time()
> > session.sendline(time_command)
> > (match, s) = session.read_up_to_prompt()
> > - if not match:
> > + if not match or s is None:
>
> I don't know if it's possible for s to be None. s is supposed to be a
> string (possibly an empty one). Did you encounter a case where s is None?
In read_until_output_matches(),
The initial value of data is "", it is only changed by "data +=
newdata", it always isn't None.
Unless, some sub function quit abnormally, and return None by default.
> > raise error.TestError("Could not get guest time")
> > - s = re.findall(time_filter_re, s)[0]
> > +
> > + try:
> > + s = re.findall(time_filter_re, s)[0]
> > + except IndexError:
> > + logging.debug("The time string from guest is:\n%s" % s)
> > + raise error.TestError("The time string from guest is unexpected.")
> > +
>
> This part looks good.
>
>
> When you encountered this problem, was it due to an incorrect format
> specified in the config file, or did the guest do something crazy, like
> return an empty string or an unrelated string? I'm asking because this
> might indicate a kvm-autotest bug. Maybe your guest replied to a
> previous command whose output was not properly read.
>
> > guest_time = time.mktime(time.strptime(s, time_format))
> > return (host_time, guest_time)
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest