Browse Source

Allow frameworks to write custom logs

Fixes TechEmpower/FrameworkBenchmarks#956
Hamilton Turner 10 years ago
parent
commit
9ae3383db3
2 changed files with 20 additions and 6 deletions
  1. 9 0
      toolset/benchmark/benchmarker.py
  2. 11 6
      toolset/benchmark/framework_test.py

+ 9 - 0
toolset/benchmark/benchmarker.py

@@ -9,6 +9,7 @@ from utils import gather_frameworks
 from utils import verify_database_connections
 
 import os
+import stat
 import json
 import subprocess
 import traceback
@@ -271,6 +272,14 @@ class Benchmarker:
       os.makedirs(path)
     except OSError:
       pass
+    
+    # Give testrunner permission to write into results directory
+    # so LOGDIR param always works in setup.sh
+    # While 664 is more preferrable, we would have to ensure that 
+    # testrunner is in the group of the current user
+    if not self.os.lower() == 'windows':
+      mode666 = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH
+      os.chmod(path, mode666)
     return path
 
   ############################################################

+ 11 - 6
toolset/benchmark/framework_test.py

@@ -165,17 +165,20 @@ class FrameworkTest:
   ############################################################
   def start(self, out, err):
 
-    # Setup environment variables
+    # Setup environment variables    
+    logDir = os.path.join(self.fwroot, self.benchmarker.latest_results_directory, 'logs', self.name.lower())
     setup_util.replace_environ(config='$FWROOT/config/benchmark_profile', 
               command='''\
               export TROOT=%s       && \
               export IROOT=%s       && \
               export DBHOST=%s      && \
+              export LOGDIR=%s      && \
               export MAX_THREADS=%s    \
               ''' % (
                 self.directory, 
                 self.install_root, 
                 self.database_host, 
+                logDir,
                 self.benchmarker.threads))
 
     # Run the module start inside parent of TROOT
@@ -211,16 +214,18 @@ class FrameworkTest:
     command = 'sudo -u %s -E -H stdbuf -o0 -e0 bash -ex %s.sh' % (self.benchmarker.runner_user, self.setup_file)
     
     debug_command = '''\
-      export FWROOT=%s && \\
-      export TROOT=%s && \\
-      export IROOT=%s && \\
-      export DBHOST=%s && \\
+      export FWROOT=%s      && \\
+      export TROOT=%s       && \\
+      export IROOT=%s       && \\
+      export DBHOST=%s      && \\
+      export LOGDIR=%s      && \\
       export MAX_THREADS=%s && \\
       cd %s && \\
       %s''' % (self.fwroot, 
         self.directory, 
         self.install_root, 
-        self.database_host, 
+        self.database_host,
+        logDir,
         self.benchmarker.threads, 
         self.directory,
         command)