OSDN Git Service

Fix a bug in DumpRenderTree2's run_apache2.py script
authorSteve Block <steveblock@google.com>
Mon, 20 Sep 2010 13:17:34 +0000 (14:17 +0100)
committerSteve Block <steveblock@google.com>
Wed, 22 Sep 2010 14:33:05 +0000 (15:33 +0100)
We use a printf style approach when setting the run command in the
command string to be executed. When doing so, the printf must be
applied to only the relevant part of the string. This avoids problems
in the case that other parts of the string contain special character
sequences, such as '%s' in a custom log directive.

Change-Id: I87df773a2872320386a34cb6a5041a9e0ba6f31e

tests/DumpRenderTree2/assets/run_apache2.py

index c799b5c..5edead1 100755 (executable)
@@ -109,18 +109,17 @@ def main(options, args):
 
   # Try to execute the commands
   logging.info("Will " + run_cmd + " apache2 server.")
-  cmd_template = export_envvars_cmd + " && " + apache2_restart_template + directives + conf_file_cmd
 
   # It is worth noting here that if the configuration file with which we restart the server points
-  # to a different PidFile it will not work and result in second apache2 instance.
+  # to a different PidFile it will not work and will result in a second apache2 instance.
   if (run_cmd == 'restart'):
     logging.info("First will stop...")
-    execute_cmd(cmd_template % ('stop'))
+    execute_cmd(export_envvars_cmd + " && " + (apache2_restart_template % ('stop')) + directives + conf_file_cmd)
     logging.info("Stopped. Will start now...")
     # We need to sleep breifly to avoid errors with apache being stopped and started too quickly
     time.sleep(0.5)
 
-  execute_cmd(cmd_template % (run_cmd))
+  execute_cmd(export_envvars_cmd + " && " + (apache2_restart_template % (run_cmd)) + directives + conf_file_cmd)
 
 def execute_cmd(cmd):
   p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)