public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Andrea Arteaga" <andyspiros@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/
Date: Fri,  1 Jul 2011 12:28:34 +0000 (UTC)	[thread overview]
Message-ID: <1599222a06e321570be756d36e03132bd8359d3b.spiros@gentoo> (raw)

commit:     1599222a06e321570be756d36e03132bd8359d3b
Author:     spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Fri Jul  1 12:27:51 2011 +0000
Commit:     Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Fri Jul  1 12:27:51 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=1599222a

Emerge, compilation and run are logged. More readable output.

---
 .../autobench/files/python/PortageUtils.py         |   23 +++++++++++++++---
 app-benchmarks/autobench/files/python/btlbase.py   |   22 ++++++++++++-----
 app-benchmarks/autobench/files/python/btlutils.py  |   14 +++++++++-
 app-benchmarks/autobench/files/python/main.py      |   25 ++++++++++++++++---
 4 files changed, 67 insertions(+), 17 deletions(-)

diff --git a/app-benchmarks/autobench/files/python/PortageUtils.py b/app-benchmarks/autobench/files/python/PortageUtils.py
index 4877cbd..c162e1d 100644
--- a/app-benchmarks/autobench/files/python/PortageUtils.py
+++ b/app-benchmarks/autobench/files/python/PortageUtils.py
@@ -1,4 +1,5 @@
 import commands as cmd
+import subprocess as sp
 import portage
 import os
 
@@ -17,7 +18,8 @@ def available_packages(pattern):
       for l in cmd.getoutput('equery -q list -po ' + pattern).split()]
 
 
-def install_package(package, env={}, root='/', pkgdir='usr/portage/packages'):
+def install_package(package, env={}, root='/', pkgdir='usr/portage/packages',
+                    logfile=None):
     """Emerge a package in the given root.
     
     package is the package to be emerged. It has to be a tuple
@@ -50,9 +52,22 @@ def install_package(package, env={}, root='/', pkgdir='usr/portage/packages'):
         envl += i + '="' + env[i] + '" '
     cl = envl + 'emerge --ignore-default-opts -OB "=' + pkg + '"'
     
-    # Execute emerge command
-    so = cmd.getstatusoutput(cl)
-    if so[0] != 0:
+    # Execute emerge command and log the results
+    if logfile is not None:
+        fout = file(logfile, 'w')
+        fout.write(cl+'\n'+80*'-'+'\n')
+        fout.flush()
+    else:
+        fout = sp.PIPE
+    p = sp.Popen( \
+      ['emerge', '--ignore-default-opts', '-OB', '=' + pkg], \
+      env = env, \
+      stdout = fout, stderr = fout \
+      )
+    p.wait()
+    if logfile is not None:
+        fout.close()
+    if p.returncode != 0:
         # In case of error, print the whole emerge command
         raise InstallException(cl)
     

diff --git a/app-benchmarks/autobench/files/python/btlbase.py b/app-benchmarks/autobench/files/python/btlbase.py
index a8d8c1e..a8dc3f4 100644
--- a/app-benchmarks/autobench/files/python/btlbase.py
+++ b/app-benchmarks/autobench/files/python/btlbase.py
@@ -39,7 +39,7 @@ class BTLBase:
         self._parse_args(passargs)
         
           
-    def run_test(self, root, impl, testdir, env):
+    def run_test(self, root, impl, testdir, env, logdir):
         # Convenient renames and definition of report files 
         Print = self.Print
         libdir = self.libdir
@@ -94,6 +94,7 @@ class BTLBase:
         # Compile
         # TODO: use CXX instead of g++
         btldir = 'btl/'
+        logfile = os.path.join(logdir, name+"_comp.log")
         returncode, compilecl = btl.btlcompile(
           exe = testdir + "/test",
           source = btldir + self._btl_source(),
@@ -102,19 +103,24 @@ class BTLBase:
           defines = self._btl_defines(),
           libs = [],
           libdirs = [root+libdir],
-          other = self._get_flags(root, impl, libdir)
+          other = self._get_flags(root, impl, libdir),
+          logfile = logfile
         )
         if returncode != 0:
-            raise Exception("Compilation failed: " + compilecl)
-        Print("Compilation successful: " + compilecl)
+            Print("Compilation failed")
+            Print("See log: " + logfile)
+            return
+        Print("Compilation successful")
         
         # Run test
-        args = [testdir + "/test"] + self.tests
+        logfile = file(os.path.join(logdir, name+"_run.log"), 'w')
+        args = [os.path.join(testdir,"test")] + self.tests
         proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE, 
           cwd = testdir)
         results = {}
         while True:
             errline = proc.stderr.readline()
+            logfile.write(errline)
             if not errline:
                 break
             resfile = errline.split()[-1]
@@ -123,11 +129,13 @@ class BTLBase:
             Print(resfile)
             Print.down()
             for i in xrange(100):
-                outline = proc.stdout.readline().rstrip()
-                Print(outline)
+                outline = proc.stdout.readline()
+                logfile.write(outline)
+                Print(outline.rstrip())
             Print.up()
         Print.up()
         proc.wait()
+        logfile.close()
         if proc.returncode != 0:
             Print('Test failed')
         else:

diff --git a/app-benchmarks/autobench/files/python/btlutils.py b/app-benchmarks/autobench/files/python/btlutils.py
index 752096e..d2207cd 100644
--- a/app-benchmarks/autobench/files/python/btlutils.py
+++ b/app-benchmarks/autobench/files/python/btlutils.py
@@ -3,7 +3,8 @@ import shlex
 
 run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
 
-def btlcompile(exe, source, btldir, includes, defines, libs, libdirs, other):
+def btlcompile(exe, source, btldir, includes, defines, libs, libdirs, other, \
+  logfile=None):
     incs = (
       "%s/actions" % btldir,
       "%s/generic_bench" % btldir,
@@ -25,7 +26,16 @@ def btlcompile(exe, source, btldir, includes, defines, libs, libdirs, other):
     # TODO: use CXX instead of g++
     cl = "g++ -o %s %s %s %s %s %s %s %s" \
         % (exe, source, incs, defs, libs, libdirs, cxxflags, otherflags)
+        
+    if logfile is None:
+        fout = sp.PIPE
+    else:
+        fout = file(logfile, 'w')
+        fout.write(cl + "\n" + 80*'-' + "\n")
+        fout.flush()
     cl = shlex.split(cl)
-    cp = sp.Popen(cl, stdout=sp.PIPE, stderr=sp.PIPE)
+    cp = sp.Popen(cl, stdout=fout, stderr=sp.STDOUT)
     cp.communicate()
+    if logfile is not None:
+        fout.close()
     return (cp.returncode, ' '.join(cl))

diff --git a/app-benchmarks/autobench/files/python/main.py b/app-benchmarks/autobench/files/python/main.py
index 474f9bd..21e3c34 100644
--- a/app-benchmarks/autobench/files/python/main.py
+++ b/app-benchmarks/autobench/files/python/main.py
@@ -20,6 +20,17 @@ testsdir = "/var/tmp/benchmarks/tests/"
 libdir = sp.Popen \
   ('ABI=$(portageq envvar ABI); echo /usr/`portageq envvar LIBDIR_$ABI`/', \
   stdout=sp.PIPE, shell=True).communicate()[0].strip()
+logdir = "/var/log/benchmarks/" + time.strftime('%Y-%m-%d')
+if os.path.exists(logdir):
+    n = 1
+    while True:
+        logdir = "/var/log/benchmarks/" + time.strftime('%Y-%m-%d') + "_%i"%n
+        if not os.path.exists(logdir):
+            os.makedirs(logdir)
+            break
+        n += 1
+else:
+    os.makedirs(logdir)
 
 def print_usage():
     print "Usage: benchmarks [blas|cblas|lapack] file args"   
@@ -150,6 +161,8 @@ for tn,(name,test) in enumerate(tests.items(),1):
     
     pkgdir = "%s/%s/" % (pkgsdir, name)
     root = "%s/%s/" % (rootsdir, name)
+    tlogdir = os.path.join(logdir, name)
+    os.path.exists(tlogdir) or os.makedirs(tlogdir)
     
     # Emerge package
     Print.down()
@@ -160,8 +173,11 @@ for tn,(name,test) in enumerate(tests.items(),1):
         Print("Package already emerged - skipping")
     else:
         try:
+            logfile = os.path.join(tlogdir, 'emerge.log')
             install_package( \
-              test['package'], env=test['env'], root=root, pkgdir=pkgdir)
+              test['package'], env=test['env'], root=root, pkgdir=pkgdir, \
+              logfile=logfile
+              )
             # Unpack the archive onto the given root directory
             archive = pkgdir + package + '.tbz2'
             os.path.exists(root) or os.makedirs(root)
@@ -172,7 +188,8 @@ for tn,(name,test) in enumerate(tests.items(),1):
                 raise InstallException(tarcmd)
                 
         except InstallException as e:
-            Print("Package %s failed to emerge: %s" % (package, e.command))
+            Print("Package %s failed to emerge" % package)
+            Print("See emerge log: " + logfile)
             Print.up()
             print
             continue
@@ -181,7 +198,7 @@ for tn,(name,test) in enumerate(tests.items(),1):
     # Find implementations
     impls = mod.get_impls(root)
     test['implementations'] = impls
-      
+    
     # Test every implementation
     test['results'] = {}
     for impl in impls:
@@ -191,7 +208,7 @@ for tn,(name,test) in enumerate(tests.items(),1):
         # Run the test suite
         testdir = "%s/%s/%s" % (testsdir, name, impl)
         test['results'][impl] = \
-          mod.run_test(root=root, impl=impl, testdir=testdir, env=test['env'])
+          mod.run_test(root, impl, testdir, env=test['env'], logdir=tlogdir)
         Print.up()
             
     Print.up()



             reply	other threads:[~2011-07-01 12:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-01 12:28 Andrea Arteaga [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-07-01 16:06 [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/ Andrea Arteaga
2011-07-04 21:38 Andrea Arteaga
2011-07-04 21:38 Andrea Arteaga
2011-07-12 15:08 Andrea Arteaga
2011-07-13  0:01 Andrea Arteaga
2011-07-13 10:01 Andrea Arteaga
2011-07-13 16:05 [gentoo-commits] proj/auto-numerical-bench:mid-term " Andrea Arteaga
2011-07-13 16:00 ` [gentoo-commits] proj/auto-numerical-bench:master " Andrea Arteaga

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=1599222a06e321570be756d36e03132bd8359d3b.spiros@gentoo \
    --to=andyspiros@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /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