Browse Source

Create FWROOT and ensure consistent ENV

Hamilton Turner 11 years ago
parent
commit
d9af0b8850
2 changed files with 56 additions and 17 deletions
  1. 27 17
      config/benchmark_profile
  2. 29 0
      toolset/run-tests.py

+ 27 - 17
config/benchmark_profile

@@ -1,23 +1,33 @@
-# Start Benchmark profile
+# This is auto-loaded from toolset/run-tests.py
+
+# Always reference ROOT for other vars
+if [ -z "${FWROOT}" ]; then
+  # Default value
+  FWROOT=~/FrameworkBenchmarks
+else
+  # Re-declare so it can be used in this script
+  FWROOT=$(echo $FWROOT)
+fi
+IROOT=${FWROOT}/installs
 
 
 export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
 export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
-export RESIN_HOME=~/FrameworkBenchmarks/installs/resin-4.0.36
-export GRAILS_HOME=~/FrameworkBenchmarks/installs/grails-2.4.2
-export VERTX_HOME=~/FrameworkBenchmarks/installs/vert.x-2.1.1
-export GOROOT=~/FrameworkBenchmarks/installs/go
-export GOPATH=~/FrameworkBenchmarks/go:~/FrameworkBenchmarks/webgo:~/FrameworkBenchmarks/revel
-export TOMCAT_HOME=~/FrameworkBenchmarks/installs/apache-tomcat-7.0.35
-export NODE_HOME=~/FrameworkBenchmarks/installs/node-v0.10.8-linux-x64
-export PLAY_HOME=~/FrameworkBenchmarks/installs/play-2.2.0
-export PLAY1_HOME=~/FrameworkBenchmarks/installs/play-1.2.5
-export MAVEN_HOME=~/FrameworkBenchmarks/installs/apache-maven-3.0.5
-export PERL_HOME=~/FrameworkBenchmarks/installs/perl-5.18
-export DART_HOME=~/FrameworkBenchmarks/installs/dart-sdk
-export PYTHON_HOME=~/FrameworkBenchmarks/installs/python-2.7.5
-export RACKET_HOME=~/FrameworkBenchmarks/installs/racket-5.3.6
-export NIMROD_HOME=~/FrameworkBenchmarks/installs/nimrod
+export RESIN_HOME=${IROOT}/resin-4.0.36
+export GRAILS_HOME=${IROOT}/grails-2.4.2
+export VERTX_HOME=${IROOT}/vert.x-2.1.1
+export GOROOT=${IROOT}/go
+export GOPATH=${FWROOT}/go:${FWROOT}/webgo:${FWROOT}/revel
+export TOMCAT_HOME=${IROOT}/apache-tomcat-7.0.35
+export NODE_HOME=${IROOT}/node-v0.10.8-linux-x64
+export PLAY_HOME=${IROOT}/play-2.2.0
+export PLAY1_HOME=${IROOT}/play-1.2.5
+export MAVEN_HOME=${IROOT}/apache-maven-3.0.5
+export PERL_HOME=${IROOT}/perl-5.18
+export DART_HOME=${IROOT}/dart-sdk
+export PYTHON_HOME=${IROOT}/python-2.7.5
+export RACKET_HOME=${IROOT}/racket-5.3.6
+export NIMROD_HOME=${IROOT}/nimrod
 export NGINX_HOME=/usr/local/nginx
 export NGINX_HOME=/usr/local/nginx
-export ELIXIR_HOME=~/FrameworkBenchmarks/installs/elixir-0.13.3
+export ELIXIR_HOME=${IROOT}/elixir-0.13.3
 
 
 export PATH="$PYTHON_HOME/bin:$JAVA_HOME/bin:$GRAILS_HOME/bin:$PLAY_HOME:$PLAY1_HOME:$VERTX_HOME/bin:$GOROOT/bin:$NODE_HOME/bin:$HOME/FrameworkBenchmarks/installs/bin:$MAVEN_HOME/bin:$PERL_HOME/bin:$DART_HOME/bin:$RACKET_HOME/bin:$NIMROD_HOME/bin:$NGINX_HOME/sbin:$ELIXIR_HOME/bin:$PATH"
 export PATH="$PYTHON_HOME/bin:$JAVA_HOME/bin:$GRAILS_HOME/bin:$PLAY_HOME:$PLAY1_HOME:$VERTX_HOME/bin:$GOROOT/bin:$NODE_HOME/bin:$HOME/FrameworkBenchmarks/installs/bin:$MAVEN_HOME/bin:$PERL_HOME/bin:$DART_HOME/bin:$RACKET_HOME/bin:$NIMROD_HOME/bin:$NGINX_HOME/sbin:$ELIXIR_HOME/bin:$PATH"
 
 

+ 29 - 0
toolset/run-tests.py

@@ -4,6 +4,7 @@ import ConfigParser
 import sys
 import sys
 import os
 import os
 import multiprocessing
 import multiprocessing
+import subprocess
 from pprint import pprint 
 from pprint import pprint 
 from benchmark.benchmarker import Benchmarker
 from benchmark.benchmarker import Benchmarker
 from setup.linux.unbuffered import Unbuffered
 from setup.linux.unbuffered import Unbuffered
@@ -130,6 +131,34 @@ def main(argv=None):
         pprint(args)
         pprint(args)
     benchmarker = Benchmarker(vars(args))
     benchmarker = Benchmarker(vars(args))
 
 
+    # Ensure a consistent environment for any subprocesses run during
+    # the lifetime of this program
+    # Note: This will not work if your command starts with 'sudo', you
+    # will need sudo sh -c ". config/benchmark_profile && your_command"
+    setup_env = '. config/benchmark_profile && env'
+    mini_environ = os.environ.copy()
+    mini_environ.clear()
+    mini_environ['HOME']=os.environ['HOME']
+    mini_environ['PATH']=os.environ['PATH']
+    mini_environ['USER']=os.environ['USER']
+    fwroot=subprocess.check_output("pwd", shell=True)
+    mini_environ['FWROOT']=fwroot
+    os.environ.clear()
+    env = subprocess.check_output(setup_env, shell=True, env=mini_environ)
+    for line in env.split('\n'):
+        try:
+            split=line.index('=')
+            key=line[:split]
+            value=line[split+1:]
+            os.environ[key]=value
+        except:
+            print "WARN: Cannot parse %s from config/benchmark_profile" % line
+            continue
+
+    out = subprocess.check_output('env', shell=True)
+    print 'Checking environment'
+    print out
+
     # Run the benchmarker in the specified mode
     # Run the benchmarker in the specified mode
     if benchmarker.list_tests:
     if benchmarker.list_tests:
       benchmarker.run_list_tests()
       benchmarker.run_list_tests()