From owner-svn-src-head@FreeBSD.ORG Tue Feb 14 18:51:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5AEA71065680; Tue, 14 Feb 2012 18:51:22 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F4F98FC08; Tue, 14 Feb 2012 18:51:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1EIpM6T012836; Tue, 14 Feb 2012 18:51:22 GMT (envelope-from gnn@svn.freebsd.org) Received: (from gnn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1EIpLPX012834; Tue, 14 Feb 2012 18:51:21 GMT (envelope-from gnn@svn.freebsd.org) Message-Id: <201202141851.q1EIpLPX012834@svn.freebsd.org> From: "George V. Neville-Neil" Date: Tue, 14 Feb 2012 18:51:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r231698 - head/tools/test/hwpmc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Feb 2012 18:51:22 -0000 Author: gnn Date: Tue Feb 14 18:51:21 2012 New Revision: 231698 URL: http://svn.freebsd.org/changeset/base/231698 Log: Add options for program (-p) and to turn off waiting (-w) which is now on by default. The default is to wait after each counter is tested. Since the prompt would go to stdout you won't see it if you're redirecting the output of the executed sub-program to /dev/null, so just press return to continue or Ctrl-D to stop. Modified: head/tools/test/hwpmc/pmctest.py Modified: head/tools/test/hwpmc/pmctest.py ============================================================================== --- head/tools/test/hwpmc/pmctest.py Tue Feb 14 18:00:37 2012 (r231697) +++ head/tools/test/hwpmc/pmctest.py Tue Feb 14 18:51:21 2012 (r231698) @@ -38,10 +38,14 @@ # # To use: # -# pmctest.py ls > /dev/null +# pmctest.py -p ls > /dev/null # # This should result in ls being run with every available counter # and the system should neither lock up nor panic. +# +# The default is to wait after each counter is tested. Since the +# prompt would go to stdout you won't see it, just press return +# to continue or Ctrl-D to stop. import sys import subprocess @@ -53,10 +57,15 @@ notcounter = ["IAF", "IAP", "TSC", "UNC" def main(): - if (len(sys.argv) != 2): - print ("usage: pmctest.py program") + from optparse import OptionParser + + parser = OptionParser() + parser.add_option("-p", "--program", dest="program", + help="program to execute") + parser.add_option("-w", "--wait", action="store_true", dest="wait", + default=True, help="wait after each execution") - program = sys.argv[1] + (options, args) = parser.parse_args() p = subprocess.Popen(["pmccontrol", "-L"], stdout=PIPE) counters = p.communicate()[0] @@ -68,9 +77,15 @@ def main(): for counter in counters.split(): if counter in notcounter: continue - p = subprocess.Popen(["pmcstat", "-p", counter, program], stdout=PIPE) + p = subprocess.Popen(["pmcstat", "-p", counter, options.program], + stdout=PIPE) result = p.communicate()[0] print result + if (options.wait == True): + try: + value = raw_input("next?") + except EOFError: + sys.exit() # The canonical way to make a python module into a script. # Remove if unnecessary.