Check for the 'diff' command, don't allow running regression tests without it.
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Sat, 31 May 2008 16:14:49 +0100
changeset 31897ddf4ad61707
parent 3188 080e43146c47
child 3190 51fe9001a679
child 3204 06ee3b7eb18d
Check for the 'diff' command, don't allow running regression tests without it.
wscript
     1.1 --- a/wscript	Fri May 30 11:11:00 2008 -0700
     1.2 +++ b/wscript	Sat May 31 16:14:49 2008 +0100
     1.3 @@ -217,6 +217,9 @@
     1.4          conf.env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in
     1.5                                             Params.g_options.enable_modules.split(',')]
     1.6  
     1.7 +    ## we cannot run regression tests without diff
     1.8 +    conf.find_program('diff', var='DIFF')
     1.9 +
    1.10  
    1.11  def create_ns3_program(bld, name, dependencies=('simulator',)):
    1.12      program = bld.create_obj('cpp', 'program')
    1.13 @@ -326,11 +329,14 @@
    1.14      #ut.want_to_see_test_error = True
    1.15      #ut.run()
    1.16      #ut.print_results()
    1.17 +    env = Params.g_build.env_of_name('default')
    1.18  
    1.19      if Params.g_commands['check']:
    1.20          _run_waf_check()
    1.21  
    1.22      if Params.g_options.regression or Params.g_options.regression_generate:
    1.23 +        if not env['DIFF']:
    1.24 +            Params.fatal("Cannot run regression tests: the 'diff' program is not installed.")
    1.25          _dir = os.getcwd()
    1.26          os.chdir("regression")
    1.27          try:
    1.28 @@ -657,6 +663,8 @@
    1.29  class Regression(object):
    1.30      def __init__(self, testdir):
    1.31          self.testdir = testdir
    1.32 +        env = Params.g_build.env_of_name('default')
    1.33 +        self.diff = env['DIFF']
    1.34  
    1.35      def run_test(self, verbose, generate, refDirName, testName):
    1.36          refTestDirName = os.path.join(refDirName, (testName + ".ref"))
    1.37 @@ -692,7 +700,7 @@
    1.38  
    1.39              if verbose:
    1.40                  #diffCmd = "diff traces " + refTestDirName + " | head"
    1.41 -                diffCmd = subprocess.Popen(["diff", "traces", refTestDirName],
    1.42 +                diffCmd = subprocess.Popen([self.diff, "traces", refTestDirName],
    1.43                                             stderr=subprocess.PIPE, stdout=subprocess.PIPE)
    1.44                  headCmd = subprocess.Popen("head", stdin=diffCmd.stdout)
    1.45                  rc2 = headCmd.wait()
    1.46 @@ -700,7 +708,7 @@
    1.47                  rc1 = diffCmd.wait()
    1.48                  rc = rc1 or rc2
    1.49              else:
    1.50 -                diffCmd = "diff traces " + refTestDirName + \
    1.51 +                diffCmd = self.diff +" traces " + refTestDirName + \
    1.52                      " > /dev/null 2>&1"
    1.53                  rc = os.system(diffCmd)
    1.54              if rc: