From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14163 invoked by alias); 24 May 2007 02:40:52 -0000 Received: (qmail 14081 invoked by uid 22791); 24 May 2007 02:40:51 -0000 X-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME X-Spam-Check-By: sourceware.org Received: from mail153.messagelabs.com (HELO mail153.messagelabs.com) (216.82.253.51) by sourceware.org (qpsmtpd/0.31) with SMTP; Thu, 24 May 2007 02:40:49 +0000 X-VirusChecked: Checked X-Env-Sender: qbarnes@urbana.css.mot.com X-Msg-Ref: server-8.tower-153.messagelabs.com!1179974446!3135494!1 X-StarScan-Version: 5.5.10.7.1; banners=-,-,- X-Originating-IP: [129.188.136.8] Received: (qmail 22809 invoked from network); 24 May 2007 02:40:47 -0000 Received: from motgate8.mot.com (HELO motgate8.mot.com) (129.188.136.8) by server-8.tower-153.messagelabs.com with SMTP; 24 May 2007 02:40:47 -0000 Received: from il06exr03.mot.com (il06exr03.mot.com [129.188.137.133]) by motgate8.mot.com (8.12.11/Motorola) with ESMTP id l4O2ekNm028195 for ; Wed, 23 May 2007 19:40:46 -0700 (MST) Received: from il06vts02.mot.com (il06vts02.mot.com [129.188.137.142]) by il06exr03.mot.com (8.13.1/Vontu) with SMTP id l4O2ek8f013423 for ; Wed, 23 May 2007 21:40:46 -0500 (CDT) Received: from udc.urbana.css.mot.com (udc.urbana.css.mot.com [10.12.0.51]) by il06exr03.mot.com (8.13.1/8.13.0) with ESMTP id l4O2ejke013409 for ; Wed, 23 May 2007 21:40:45 -0500 (CDT) Received: from nova.urbana.css.mot.com (nova.urbana.css.mot.com [192.88.153.60]) by udc.urbana.css.mot.com (8.13.8+Sun/8.13.8) with ESMTP id l4O2ejl7002218; Wed, 23 May 2007 21:40:45 -0500 (CDT) Received: (from qbarnes@localhost) by nova.urbana.css.mot.com (8.13.8+Sun/8.13.7/Submit) id l4O2eifU019067; Wed, 23 May 2007 21:40:44 -0500 (CDT) Date: Thu, 24 May 2007 02:40:00 -0000 From: Quentin Barnes To: Martin Hunt Cc: systemtap@sources.redhat.com Subject: Re: ordering problem with "system_func" test Message-ID: <20070524024044.GA19016@urbana.css.mot.com> References: <20070523204944.GA18405@urbana.css.mot.com> <1179956482.3520.1.camel@dragon> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1179956482.3520.1.camel@dragon> User-Agent: Mutt/1.4.2.1i X-POPI: This message is Motorola General Business Information (MGBI). X-Organization: Motorola Cellular Subscriber Group, Urbana Design Center X-Phone: (217) 384-8726 X-Vontu: Pass X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2007-q2/txt/msg00387.txt.bz2 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 { } }