This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ordering problem with "system_func" test


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 { }
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]