public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Quentin Barnes <qbarnes@urbana.css.mot.com>
To: Martin Hunt <hunt@redhat.com>
Cc: systemtap@sources.redhat.com
Subject: Re: ordering problem with "system_func" test
Date: Thu, 24 May 2007 02:40:00 -0000	[thread overview]
Message-ID: <20070524024044.GA19016@urbana.css.mot.com> (raw)
In-Reply-To: <1179956482.3520.1.camel@dragon>

On Wed, May 23, 2007 at 05:41:22PM -0400, Martin Hunt wrote:
>On Wed, 2007-05-23 at 15:49 -0500, Quentin Barnes wrote:
>> I'm using 20070519 snapshot on a 2.6.21.1 ARM kernel.
>> 
>> The "system_func" test is giving me intermittent results.  I saw #4466
>> go by, but I'm running the test after that change.
>
>Looks like maybe the pattern isn't anchored correctly. I checked in a
>fix. Let me know if that does not help.

Nope, it didn't help.  It doesn't solve the arbitrary ordering
problem.  After each match, what appears in the buffer up to that
match is discarded and can't be rematched.  The exp_continue doesn't
restart from the beginning of the original complete buffer, but from
the point of the last match.

Below is an approach that solves it by creating a regular pattern
for all three possibities for concurrent matching.

In the first version, it 'cheats' by using the default match for
$user.  The second version is a more pedantic method, but it uses
the oft maligned "eval".

I don't know Expect all that well, so there might be another way not
so clumsy to solve this problem.  Maybe there's a way to suck the
whole output string in until eof into a variable and then to pattern
matching on it.

>Martin

Quentin

--- system_func.exp.orig	2007-05-23 21:20:04.000000000 -0500
+++ system_func.exp	2007-05-23 21:25:31.000000000 -0500
@@ -7,9 +7,14 @@ set saw_user 0
 set user [exec whoami]
 expect {
     -timeout 30
-    -re "^$user\[^\r\]*\[\r\n\]*" {incr saw_user; exp_continue}
-    -re {^sys_open[^\r]*[\r\n]*} {incr open; exp_continue }
-    -re {DONE[^\r]*[\r\n]*} {incr done; exp_continue }
+    -re "($user|sys_open|DONE)\r" {
+	switch $expect_out(1,string) {
+	    sys_open {incr open}
+	    DONE     {incr done}
+	    default  {incr saw_user}
+	}
+	exp_continue
+    }
     timeout { fail "$test (timeout)" }
     eof { }
 }



--- system_func.exp.orig	2007-05-23 21:20:04.000000000 -0500
+++ system_func.exp	2007-05-23 21:25:31.000000000 -0500
@@ -7,9 +7,14 @@ set saw_user 0
 set user [exec whoami]
 expect {
     -timeout 30
-    -re "^$user\[^\r\]*\[\r\n\]*" {incr saw_user; exp_continue}
-    -re {^sys_open[^\r]*[\r\n]*} {incr open; exp_continue }
-    -re {DONE[^\r]*[\r\n]*} {incr done; exp_continue }
+    -re "($user|sys_open|DONE)\r" {
+	eval "switch $expect_out(1,string) {
+	    \"$user\" {incr saw_user}
+	    sys_open  {incr open}
+	    DONE      {incr done}
+	}"
+	exp_continue
+    }
     timeout { fail "$test (timeout)" }
     eof { }
 }

      reply	other threads:[~2007-05-24  2:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-23 20:50 Quentin Barnes
2007-05-23 21:41 ` Martin Hunt
2007-05-24  2:40   ` Quentin Barnes [this message]

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=20070524024044.GA19016@urbana.css.mot.com \
    --to=qbarnes@urbana.css.mot.com \
    --cc=hunt@redhat.com \
    --cc=systemtap@sources.redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).