Browse Source

Merge pull request #2476 from nbrady-techempower/fwroot

Simplify FWROOT and remove benchmark_profiler
Mike Smith 8 years ago
parent
commit
3a659ed7f1

+ 7 - 15
toolset/benchmark/framework_test.py

@@ -171,21 +171,13 @@ class FrameworkTest:
     # Setup environment variables
     logDir = os.path.join(self.fwroot, self.benchmarker.full_results_directory(), 'logs', self.name.lower())
     bash_functions_path= os.path.join(self.fwroot, 'toolset/setup/linux/bash_functions.sh')
-    setup_util.replace_environ(config='$FWROOT/toolset/setup/linux/config/benchmark_profile',
-              command='''\
-              export TROOT=%s       &&  \
-              export IROOT=%s       &&  \
-              export DBHOST=%s      &&  \
-              export LOGDIR=%s      &&  \
-              export MAX_THREADS=%s &&  \
-              export MAX_CONCURRENCY=%s \
-              ''' % (
-                self.directory,
-                self.install_root,
-                self.database_host,
-                logDir,
-                self.benchmarker.threads,
-                max(self.benchmarker.concurrency_levels)))
+
+    os.environ['TROOT'] = self.directory
+    os.environ['IROOT'] = self.install_root
+    os.environ['DBHOST'] = self.database_host
+    os.environ['LOGDIR'] = logDir
+    os.environ['MAX_THREADS'] = str(self.benchmarker.threads)
+    os.environ['MAX_CONCURRENCY'] = str(max(self.benchmarker.concurrency_levels))
 
     # Always ensure that IROOT exists
     if not os.path.exists(self.install_root):

+ 7 - 5
toolset/run-tests.py

@@ -3,6 +3,7 @@ import argparse
 import ConfigParser
 import sys
 import os
+import platform
 import multiprocessing
 import itertools
 import copy
@@ -63,11 +64,12 @@ def main(argv=None):
     sys.path.append('toolset/setup/linux')
 
     # Update environment for shell scripts
-    fwroot = setup_util.get_fwroot()
-    if not fwroot: 
-        fwroot = os.getcwd()
-    setup_util.replace_environ(config='toolset/setup/linux/config/benchmark_profile', root=fwroot)
-    print "FWROOT is %s"%setup_util.get_fwroot()
+    os.environ['FWROOT'] = setup_util.get_fwroot()
+    os.environ['IROOT'] = os.environ['FWROOT'] + '/installs'
+    # 'Ubuntu', '14.04', 'trusty' respectively
+    os.environ['TFB_DISTRIB_ID'], os.environ['TFB_DISTRIB_RELEASE'], os.environ['TFB_DISTRIB_CODENAME'] = platform.linux_distribution()
+
+    print "FWROOT is %s"%os.environ['FWROOT']
 
     conf_parser = argparse.ArgumentParser(
         description=__doc__,

+ 0 - 50
toolset/setup/linux/config/benchmark_profile

@@ -1,50 +0,0 @@
-# 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
-
-# Determine which OS we are using and set the appropriate variables
-source /etc/lsb-release
-export TFB_DISTRIB_ID=$DISTRIB_ID
-export TFB_DISTRIB_RELEASE=$DISTRIB_RELEASE
-export TFB_DISTRIB_CODENAME=$DISTRIB_CODENAME
-export TFB_DISTRIB_DESCRIPTION=$DISTRIB_DESCRIPTION
-
-#
-#export RESIN_HOME=${IROOT}/resin-4.0.41
-#export GRAILS_HOME=${IROOT}/grails-2.4.4
-#export VERTX_HOME=${IROOT}/vert.x-2.1.1
-#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 SBT_HOME=${IROOT}/sbt
-#export PERL_HOME=${IROOT}/perl-5.18
-#export DART_HOME=${IROOT}/dart-sdk
-#export RACKET_HOME=${IROOT}/racket-5.3.6
-#export NIMROD_HOME=${IROOT}/nimrod
-#export NGINX_HOME=/usr/local/nginx
-#export ELIXIR_HOME=${IROOT}/elixir-0.13.3
-#
-#export PATH="$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:$SBT_HOME/bin:$PERL_HOME/bin:$DART_HOME/bin:$RACKET_HOME/bin:$NIMROD_HOME/bin:$NGINX_HOME/sbin:$ELIXIR_HOME/bin:$PATH"
-#
-#export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/apr/lib'
-#
-#export TFB_SERVER_HOST='127.0.0.1'
-#export TFB_CLIENT_HOST='127.0.0.1'
-#export TFB_CLIENT_USER='tfb'
-#export TFB_CLIENT_IDENTITY_FILE='/home/tfb/.ssh/id_rsa'
-#export TFB_DATABASE_HOST='127.0.0.1'
-#
-#[ -e ~/.rvm ] && . ~/.rvm/scripts/'rvm'
-#export LC_ALL='en_US.UTF-8'
-#export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
-#export MAKEFLAGS="-j $NUMCPUS -l $NUMCPUS"

+ 3 - 75
toolset/setup/linux/setup_util.py

@@ -65,85 +65,13 @@ def replace_text(file, to_replace, replacement):
     with open(file, "w") as f:
         f.write(replaced_text)
 
-# Replaces the current process environment with the one found in 
-# config file. Retains a few original vars (HOME,PATH, etc) by default. 
-# Optionally allows specification of a command to be run before loading
-# the environment, to allow the framework to set environment variables
-# Note: This command *cannot* print to stdout!
-#
-# Note: This will not replace the sudo environment (e.g. subprocess.check_call("sudo <command>")). 
-# If you must use sudo, consider sudo sh -c ". <config> && your_command"
-def replace_environ(config=None, root=None, print_result=False, command='true'):
-
-    if platform.system().lower() == 'windows':
-
-        pass
-
-    else:
-    
-        # Clean up our current environment, preserving some important items
-        mini_environ = {}
-        for envname in ['HOME', 'PATH', 'LANG', 'USER', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'FWROOT', 'TRAVIS']:
-          if envname in os.environ:
-            mini_environ[envname] = os.environ[envname]
-        for key in os.environ:
-          if key.startswith(('TFB_', 'TRAVIS_')):    # Any TFB_* and TRAVIS_* variables are preserved
-            mini_environ[key] = os.environ[key]
-        os.environ.clear()
-
-        # Use FWROOT if explicitely provided
-        if root is not None: 
-          mini_environ['FWROOT']=root
-        
-
-        # Run command, source config file, and store resulting environment
-        setup_env = "%s && . %s && env" % (command, config)
-        env = ""
-        try:
-            env = subprocess.check_output(setup_env, shell=True, env=mini_environ,
-           executable='/bin/bash')
-        except subprocess.CalledProcessError:
-            # Ensure that an error here does not crash the toolset
-            print "CRITICAL: Loading %s returned non-zero exit" % config
-            for key,value in mini_environ.iteritems():
-                os.environ[key]=value
-            return
-        for line in env.split('\n'):
-            try:
-                key, value = line.split('=', 1)
-                # If we already have this TFB_ variable, do not overwrite
-                if key.startswith('TFB_') and key in mini_environ:
-                    os.environ[key]=mini_environ[key]
-                else:
-                    os.environ[key]=value    
-            except Exception:
-                if not line: # Don't warn for empty line
-                    continue 
-                print "WARN: Line '%s' from '%s' is not an environment variable" % (line, config)
-                continue
-        if print_result:
-            out = subprocess.check_output('env', shell=True, executable='/bin/bash')
-            print "Environment after loading %s" %config
-            print out
-
 # Queries the shell for the value of FWROOT
 def get_fwroot():
 
-    if platform.system().lower() == 'windows':
-
-        fwroot = "C:\FrameworkBenchmarks"
-        return fwroot
-
+    if os.getenv('FWROOT'):
+        return os.environ['FWROOT']
     else:
-    
-        try:
-            # Use printf to avoid getting a newline
-            # Redirect to avoid stderr printing
-            fwroot = subprocess.check_output('printf $FWROOT 2> /dev/null', shell=True, executable='/bin/bash')
-            return fwroot
-        except subprocess.CalledProcessError:
-            # Make a last-guess effort ;-)
-            return os.getcwd();
+        return os.getcwd()
 
 # Turns absolute path into path relative to FWROOT
 # Assumes path is underneath FWROOT, not above