summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspiros <andyspiros@gmail.com>2011-07-01 14:27:51 +0200
committerspiros <andyspiros@gmail.com>2011-07-01 14:27:51 +0200
commit1599222a06e321570be756d36e03132bd8359d3b (patch)
treea1a975ff6af5617ac122f0e34bde5ff055439c01
parentFixed Manifest. (diff)
downloadauto-numerical-bench-1599222a06e321570be756d36e03132bd8359d3b.tar.gz
auto-numerical-bench-1599222a06e321570be756d36e03132bd8359d3b.tar.bz2
auto-numerical-bench-1599222a06e321570be756d36e03132bd8359d3b.zip
Emerge, compilation and run are logged. More readable output.
-rw-r--r--app-benchmarks/autobench/files/python/PortageUtils.py23
-rw-r--r--app-benchmarks/autobench/files/python/btlbase.py22
-rw-r--r--app-benchmarks/autobench/files/python/btlutils.py14
-rw-r--r--app-benchmarks/autobench/files/python/main.py25
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()