keep wifi-ap from spewing all over std_out during tests
authorCraig Dowell <craigdo@ee.washington.edu>
Thu Oct 01 14:12:56 2009 -0700 (4 months ago)
changeset 53516abced63cd7f
parent 5350 9f457bebbcf4
child 5352 54b51a1105d6
keep wifi-ap from spewing all over std_out during tests
examples/wifi-ap.cc
test.py
     1.1 --- a/examples/wifi-ap.cc	Thu Oct 01 11:53:19 2009 -0700
     1.2 +++ b/examples/wifi-ap.cc	Thu Oct 01 14:12:56 2009 -0700
     1.3 @@ -32,53 +32,73 @@
     1.4  
     1.5  using namespace ns3;
     1.6  
     1.7 +static bool g_verbose = true;
     1.8 +
     1.9  void
    1.10  DevTxTrace (std::string context, Ptr<const Packet> p)
    1.11  {
    1.12 -  std::cout << " TX p: " << *p << std::endl;
    1.13 +  if (g_verbose)
    1.14 +    {
    1.15 +      std::cout << " TX p: " << *p << std::endl;
    1.16 +    }
    1.17  }
    1.18  void
    1.19  DevRxTrace (std::string context, Ptr<const Packet> p)
    1.20  {
    1.21 -  std::cout << " RX p: " << *p << std::endl;
    1.22 +  if (g_verbose)
    1.23 +    {
    1.24 +      std::cout << " RX p: " << *p << std::endl;
    1.25 +    }
    1.26  }
    1.27  void
    1.28  PhyRxOkTrace (std::string context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)
    1.29  {
    1.30 -  std::cout << "PHYRXOK mode=" << mode << " snr=" << snr << " " << *packet << std::endl;
    1.31 +  if (g_verbose)
    1.32 +    {
    1.33 +      std::cout << "PHYRXOK mode=" << mode << " snr=" << snr << " " << *packet << std::endl;
    1.34 +    }
    1.35  }
    1.36  void
    1.37  PhyRxErrorTrace (std::string context, Ptr<const Packet> packet, double snr)
    1.38  {
    1.39 -  std::cout << "PHYRXERROR snr=" << snr << " " << *packet << std::endl;
    1.40 +  if (g_verbose)
    1.41 +    {
    1.42 +      std::cout << "PHYRXERROR snr=" << snr << " " << *packet << std::endl;
    1.43 +    }
    1.44  }
    1.45  void
    1.46  PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
    1.47  {
    1.48 -  std::cout << "PHYTX mode=" << mode << " " << *packet << std::endl;
    1.49 +  if (g_verbose)
    1.50 +    {
    1.51 +      std::cout << "PHYTX mode=" << mode << " " << *packet << std::endl;
    1.52 +    }
    1.53  }
    1.54  void
    1.55  PhyStateTrace (std::string context, Time start, Time duration, enum WifiPhy::State state)
    1.56  {
    1.57 -  std::cout << " state=";
    1.58 -  switch (state) {
    1.59 -  case WifiPhy::SWITCHING: 
    1.60 -    std::cout << "switchng";
    1.61 -    break; 
    1.62 -  case WifiPhy::TX:
    1.63 -    std::cout << "tx      ";
    1.64 -    break;
    1.65 -  case WifiPhy::SYNC:
    1.66 -    std::cout << "sync    ";
    1.67 -    break;
    1.68 -  case WifiPhy::CCA_BUSY:
    1.69 -    std::cout << "cca-busy";
    1.70 -    break;
    1.71 -  case WifiPhy::IDLE:
    1.72 -    std::cout << "idle    ";
    1.73 -    break;
    1.74 -  }
    1.75 -  std::cout << " start="<<start<<" duration="<<duration<<std::endl;
    1.76 +  if (g_verbose)
    1.77 +    {
    1.78 +      std::cout << " state=";
    1.79 +      switch (state) {
    1.80 +      case WifiPhy::SWITCHING: 
    1.81 +        std::cout << "switchng";
    1.82 +        break; 
    1.83 +      case WifiPhy::TX:
    1.84 +        std::cout << "tx      ";
    1.85 +        break;
    1.86 +      case WifiPhy::SYNC:
    1.87 +        std::cout << "sync    ";
    1.88 +        break;
    1.89 +      case WifiPhy::CCA_BUSY:
    1.90 +        std::cout << "cca-busy";
    1.91 +        break;
    1.92 +      case WifiPhy::IDLE:
    1.93 +        std::cout << "idle    ";
    1.94 +        break;
    1.95 +      }
    1.96 +      std::cout << " start="<<start<<" duration="<<duration<<std::endl;
    1.97 +    }
    1.98  }
    1.99  
   1.100  static void
   1.101 @@ -105,17 +125,20 @@
   1.102        return;
   1.103      }
   1.104    SetPosition (node, pos);
   1.105 -  //std::cout << "x="<<pos.x << std::endl;
   1.106 +
   1.107 +  if (g_verbose)
   1.108 +    {
   1.109 +      //std::cout << "x="<<pos.x << std::endl;
   1.110 +    }
   1.111    Simulator::Schedule (Seconds (1.0), &AdvancePosition, node);
   1.112  }
   1.113  
   1.114 -
   1.115 -
   1.116 -
   1.117  int main (int argc, char *argv[])
   1.118  {
   1.119    CommandLine cmd;
   1.120 -   cmd.Parse (argc, argv);
   1.121 +  cmd.AddValue ("verbose", "Print trace information if true", g_verbose);
   1.122 +
   1.123 +  cmd.Parse (argc, argv);
   1.124     
   1.125    Packet::EnablePrinting ();
   1.126  
     2.1 --- a/test.py	Thu Oct 01 11:53:19 2009 -0700
     2.2 +++ b/test.py	Thu Oct 01 14:12:56 2009 -0700
     2.3 @@ -100,7 +100,7 @@
     2.4      ("udp-echo", "True"),
     2.5      ("virtual-net-device", "True"),
     2.6      ("wifi-adhoc", "False"), # takes forever to run
     2.7 -    ("wifi-ap", "True"),
     2.8 +    ("wifi-ap --verbose=0", "True"), # don't let it spew 
     2.9      ("wifi-wired-bridging", "True"),
    2.10  ]
    2.11  
    2.12 @@ -509,8 +509,8 @@
    2.13      if options.verbose:
    2.14          print "Synchronously execute %s" % cmd
    2.15      proc = subprocess.Popen(cmd, shell=True, cwd=directory, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    2.16 -    stdout_results = proc.communicate()[0]
    2.17 -    return (proc.returncode, stdout_results)
    2.18 +    stdout_results, stderr_results = proc.communicate()
    2.19 +    return (proc.returncode, stdout_results, stderr_results)
    2.20  
    2.21  #
    2.22  # This class defines a unit of testing work.  It will typically refer to
    2.23 @@ -641,18 +641,22 @@
    2.24                      # If we have an example, the shell command is all we need to
    2.25                      # know.  It will be something like "examples/udp-echo"
    2.26                      #
    2.27 -                    (job.returncode, standard_out) = run_job_synchronously(job.shell_command, job.cwd)
    2.28 +                    (job.returncode, standard_out, standard_err) = run_job_synchronously(job.shell_command, job.cwd)
    2.29                  else:
    2.30                      #
    2.31                      # If we're a test suite, we need to provide a little more info
    2.32                      # to the test runner, specifically the base directory and temp
    2.33                      # file name
    2.34                      #
    2.35 -                    (job.returncode, standard_out) = run_job_synchronously(job.shell_command + " --basedir=%s --out=%s" %
    2.36 -                        (job.basedir, job.tmp_file_name), job.cwd)
    2.37 +                    (job.returncode, standard_out, standard_err) = run_job_synchronously(job.shell_command + 
    2.38 +                        " --basedir=%s --out=%s" % (job.basedir, job.tmp_file_name), job.cwd)
    2.39  
    2.40                  if options.verbose:
    2.41 +                    print "---------- beign standard out ----------"
    2.42                      print standard_out
    2.43 +                    print "---------- begin standard err ----------"
    2.44 +                    print standard_err
    2.45 +                    print "---------- end standard err ----------"
    2.46  
    2.47                  self.output_queue.put(job)
    2.48  
    2.49 @@ -685,11 +689,11 @@
    2.50      # handle them without doing all of the hard work.
    2.51      #
    2.52      if options.kinds:
    2.53 -        (rc, standard_out) = run_job_synchronously("utils/test-runner --kinds", os.getcwd())
    2.54 +        (rc, standard_out, standard_err) = run_job_synchronously("utils/test-runner --kinds", os.getcwd())
    2.55          print standard_out
    2.56  
    2.57      if options.list:
    2.58 -        (rc, standard_out) = run_job_synchronously("utils/test-runner --list", os.getcwd())
    2.59 +        (rc, standard_out, standard_err) = run_job_synchronously("utils/test-runner --list", os.getcwd())
    2.60          print standard_out
    2.61  
    2.62      if options.kinds or options.list:
    2.63 @@ -755,9 +759,10 @@
    2.64          suites = options.suite + "\n"
    2.65      elif len(options.example) == 0:
    2.66          if len(options.constrain):
    2.67 -            (rc, suites) = run_job_synchronously("utils/test-runner --list --constrain=%s" % options.constrain, os.getcwd())
    2.68 +            (rc, suites, standard_err) = run_job_synchronously("utils/test-runner --list --constrain=%s" % 
    2.69 +                options.constrain, os.getcwd())
    2.70          else:
    2.71 -            (rc, suites) = run_job_synchronously("utils/test-runner --list", os.getcwd())
    2.72 +            (rc, suites, standard_err) = run_job_synchronously("utils/test-runner --list", os.getcwd())
    2.73      else:
    2.74          suites = ""
    2.75  
    2.76 @@ -1055,9 +1060,9 @@
    2.77          shutil.copyfile(xml_results_file, options.xml)
    2.78  
    2.79      if passed_tests == total_tests:
    2.80 -        return 0
    2.81 +        return 0 # success
    2.82      else:
    2.83 -        return -1
    2.84 +        return 1 # catchall for general errors
    2.85  
    2.86  def main(argv):
    2.87      random.seed()