utils/test-runner.cc
author Craig Dowell <craigdo@ee.washington.edu>
Mon, 19 Apr 2010 08:37:27 -0700
changeset 6245 a88bde26913e
parent 6228 4a2c9eaedb7f
child 6248 3ccf4cea2480
permissions -rw-r--r--
repair unused returns in perfio and test-runner
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * Copyright (c) 2009 University of Washington
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
#include "ns3/test.h"
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    20
#include "ns3/assert.h"
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
#include <iostream>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
#include <fstream>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
#include <string>
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    25
#include <stdlib.h>
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    26
#include <stdio.h>
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    27
#include <time.h>
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    28
#include <sys/types.h>
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    29
#include <sys/stat.h>
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    30
#include <dirent.h>
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    31
#include <string.h>
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
6204
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
    33
extern bool gBreakOnFailure;
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
    34
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
using namespace ns3;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
//
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    38
// Create a temporary directory for use by test programs.  This is not a 
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    39
// foolproof thing, but a reasonably good way to get a throwaway directory
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    40
// while running tests in a debugger.
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    41
//  
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    42
std::string
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    43
TempDir (void)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    44
{
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    45
  char *path = NULL;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    46
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    47
  path = getenv ("TMP");
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    48
  if (path == NULL)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    49
    {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    50
      path = getenv ("TEMP");
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    51
      if (path == NULL)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    52
        {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    53
          path = const_cast<char *> ("/tmp");
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    54
        }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    55
    }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    56
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    57
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    58
  // Just in case the user wants to go back and find the output, we give
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    59
  // a hint as to which dir we created by including a time hint.
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    60
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    61
  time_t now = time (NULL);
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    62
  struct tm *tm_now = localtime (&now);
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    63
  
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    64
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    65
  // But we also randomize the name in case there are multiple users doing
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    66
  // this at the same time
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    67
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    68
  srandom (time (0));
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    69
  long int n = random ();
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    70
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    71
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    72
  // The final path to the directory is going to look something like
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    73
  // 
6228
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    74
  //   /tmp/ns3-14.30.29.32767
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    75
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    76
  // The first segment comes from one of the temporary directory env 
6228
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    77
  // variables or /tmp if not found.  The directory name starts with an
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    78
  // identifier telling folks who is making all of the temp directories
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    79
  // and then the local time (in this case 14.30.29 -- which is 2:30 and
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    80
  // 29 seconds PM).
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    81
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    82
  char dirname[1024];
6228
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    83
  snprintf (dirname, sizeof(dirname),  "%s/ns-3.%d.%d.%d.%ld", path, tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec, n);
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    84
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    85
  if (mkdir (dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    86
    {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    87
      return dirname;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    88
    } 
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    89
  else
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    90
    {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    91
      return "";
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    92
    }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    93
}
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
    94
6228
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    95
//
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    96
// Test suites may need to figure out where their source directory is in order
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    97
// to find test vectors.  To do that they will need to know  where the base 
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    98
// directory of the distribution is (the directory in which "src" is found).
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
    99
// It is painful for a user debugging test suites to always provide that dir
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
   100
// so we try and find it in the current directory tree.
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
   101
//
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   102
std::string
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   103
BaseDir (void)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   104
{
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   105
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   106
  // Get an absolute path to the current working directory.  Following code
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   107
  // depends on the leading '/'
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   108
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   109
  char pathbuf[PATH_MAX];
6245
a88bde26913e repair unused returns in perfio and test-runner
Craig Dowell <craigdo@ee.washington.edu>
parents: 6228
diff changeset
   110
  char * __attribute__ ((unused)) p = getcwd (pathbuf, sizeof(pathbuf));
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   111
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   112
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   113
  // Walk up the directory tree looking for a directory that has files that
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   114
  // indicate it is the base of an ns-3 distribution.  We use VERSION and
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   115
  // LICENSE which have been there from the beginning of time.
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   116
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   117
  for (;;)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   118
    {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   119
      bool haveVersion = false;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   120
      bool haveLicense = false;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   121
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   122
      //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   123
      // Open the directory file for the current directory and loop through
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   124
      // the directory entries.
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   125
      //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   126
      DIR *dp = opendir (pathbuf);
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   127
      if (dp != NULL)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   128
        {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   129
          while (struct dirent *de = readdir (dp))
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   130
            {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   131
              if (strcmp (de->d_name, "VERSION") == 0)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   132
                {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   133
                  haveVersion = true;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   134
                }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   135
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   136
              if (strcmp (de->d_name, "LICENSE") == 0)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   137
                {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   138
                  haveLicense = true;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   139
                }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   140
            }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   141
        }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   142
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   143
      //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   144
      // If there's a file named VERSION and a file named LICENSE in this
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   145
      // directory, we assume it's our base directory.
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   146
      //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   147
      if (haveVersion && haveLicense)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   148
        {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   149
          return pathbuf;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   150
        }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   151
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   152
      //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   153
      // Strip off the last segment of the current directory.
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   154
      //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   155
      char *last = strrchr (pathbuf, '/');
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   156
      NS_ASSERT_MSG (last, "No \"/\" found in absolute path ???");
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   157
      *last = '\0';
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   158
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   159
      if (strlen(pathbuf) == 0)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   160
        {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   161
          return "";
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   162
        }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   163
    }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   164
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   165
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   166
  // Quiet the compiler.
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   167
  //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   168
  return "";
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   169
}
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   170
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   171
//
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
// Run one of the test suites.  Returns an integer with the boolean sense of
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
// "an error has occurred."  That is, 0 == false -> no error; 1 == true -> an
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   174
// error occurred.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   175
//
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   176
int 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   177
main (int argc, char *argv[])
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   178
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   179
  bool doVerbose = false;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   180
  bool doList = false;
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5297
diff changeset
   181
  bool doMultiple = false;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   182
  bool doHelp = false;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   183
  bool doSuite = false;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   184
  bool doKinds = false;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   185
6204
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
   186
  gBreakOnFailure = false;
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
   187
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   188
  bool haveBasedir = false;
5481
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   189
  bool haveTempdir = false;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   190
  bool haveOutfile = false;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   191
  bool haveType = false;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   192
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   193
  std::string suiteName;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   194
  std::string basedir;
5481
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   195
  std::string tempdir;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   196
  std::string outfileName;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   197
  std::string typeName;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   198
6204
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
   199
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   200
  for (int i = 1; i < argc; ++i)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   201
    {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   202
      std::string arg(argv[i]);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   203
6204
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
   204
      if (arg.find ("--assert") != std::string::npos)
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
   205
        {
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
   206
          gBreakOnFailure = true;
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
   207
        }
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
   208
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   209
      if (arg.find ("--basedir=") != std::string::npos)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   210
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   211
          basedir = arg.substr (arg.find_first_of ("=") + 1, 9999);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   212
          haveBasedir = true;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   213
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   214
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   215
      if (arg.find ("--constrain=") != std::string::npos)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   216
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   217
          typeName = arg.substr (arg.find_first_of ("=") + 1, 9999);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   218
          haveType = true;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   219
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   220
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   221
      if (arg.compare ("--help") == 0)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   222
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   223
          doHelp = true;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   224
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   225
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   226
      if (arg.compare ("--kinds") == 0)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   227
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   228
          doKinds = true;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   229
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   230
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   231
      if (arg.compare ("--list") == 0)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   232
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   233
          doList = true;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   234
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   235
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5297
diff changeset
   236
      if (arg.compare ("--multiple") == 0)
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5297
diff changeset
   237
        {
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5297
diff changeset
   238
          doMultiple = true;
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5297
diff changeset
   239
        }
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5297
diff changeset
   240
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   241
      if (arg.find ("--out=") != std::string::npos)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   242
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   243
          outfileName = arg.substr (arg.find_first_of ("=") + 1, 9999);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   244
          haveOutfile = true;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   245
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   246
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   247
      if (arg.find ("--suite=") != std::string::npos)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   248
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   249
          suiteName = arg.substr (arg.find_first_of ("=") + 1, 9999);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   250
          doSuite = true;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   251
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   252
5481
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   253
      if (arg.find ("--tempdir=") != std::string::npos)
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   254
        {
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   255
          tempdir = arg.substr (arg.find_first_of ("=") + 1, 9999);
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   256
          haveTempdir = true;
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   257
        }
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   258
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   259
      if (arg.compare ("--verbose") == 0)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   260
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   261
          doVerbose = true;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   262
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   263
    }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   264
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   265
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   266
  // A help request trumps everything else.  If we have one, just print the help
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   267
  // and leave.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   268
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   269
  if (doHelp)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   270
    {
6204
db1a9442b29f enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 6194
diff changeset
   271
      std::cout << "  --assert:               Tell tests to segfault (like assert) if an error is detected" << std::endl;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   272
      std::cout << "  --basedir=dir:          Set the base directory (where to find src) to \"dir\"" << std::endl;
5780
1ae8031ed08f document the new --tempdir option
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5481
diff changeset
   273
      std::cout << "  --tempdir=dir:          Set the temporary directory (where to find data files) to \"dir\"" << std::endl;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   274
      std::cout << "  --constrain=test-type:  Constrain checks to test suites of type \"test-type\"" << std::endl;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   275
      std::cout << "  --help:                 Print this message" << std::endl;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   276
      std::cout << "  --kinds:                List all of the available kinds of tests" << std::endl;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   277
      std::cout << "  --list:                 List all of the test suites (optionally constrained by test-type)" << std::endl;
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5297
diff changeset
   278
      std::cout << "  --multiple:             Allow test suites and cases to produce multiple failures" << std::endl;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   279
      std::cout << "  --out=file-name:        Set the test status output file to \"file-name\"" << std::endl;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   280
      std::cout << "  --suite=suite-name:     Run the test suite named \"suite-name\"" << std::endl;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   281
      std::cout << "  --verbose:              Turn on messages in the run test suites" << std::endl;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   282
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   283
      return false;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   284
    }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   285
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   286
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   287
  // A kinds request trumps everything remaining.  If we are asked, just 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   288
  // print the list of types and leave.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   289
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   290
  if (doKinds)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   291
    {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   292
      //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   293
      // Coming up with a string to represent a test type is completely up to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   294
      // us here.  We just define the types as being a string composed of the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   295
      // enum defined in test.h converted to lower case.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   296
      //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   297
      std::cout << "  bvt:         Build Verification Tests (to see if build completed successfully)" << std::endl;
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5324
diff changeset
   298
      std::cout << "  core:        Run all TestSuite-based tests (exclude examples)" << std::endl;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   299
      std::cout << "  example:     Examples (to see if example programs run successfully)" << std::endl;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   300
      std::cout << "  performance: Performance Tests (check to see if the system is as fast as expected)" << std::endl;
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5324
diff changeset
   301
      std::cout << "  system:      System Tests (spans modules to check integration of modules)" << std::endl;
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5324
diff changeset
   302
      std::cout << "  unit:        Unit Tests (within modules to check basic functionality)" << std::endl;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   303
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   304
      return false;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   305
    }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   306
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   307
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   308
  // A list request is the first functional request.  It trumps running the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   309
  // actual tests.  If we get a list request, we don't run anything, we just
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   310
  // do the requested list which may or may not be qualified by a typename.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   311
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   312
  if (doList)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   313
    {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   314
      for (uint32_t i = 0; i < TestRunner::GetNTestSuites (); ++i)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   315
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   316
          TestSuite *suite = TestRunner::GetTestSuite (i);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   317
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   318
          //
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5324
diff changeset
   319
          // Filter the tests listed by type if requested.  The special typeName 
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5324
diff changeset
   320
          // "core" means any TestSuite.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   321
          //
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5324
diff changeset
   322
          if (haveType && typeName != "core")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   323
            {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   324
              TestSuite::TestType type = suite->GetTestType ();
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   325
              if (typeName == "bvt" && type != TestSuite::BVT)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   326
                {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   327
                  continue;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   328
                }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   329
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   330
              if (typeName == "unit" && type != TestSuite::UNIT)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   331
                {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   332
                  continue;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   333
                }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   334
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   335
              if (typeName == "system" && type != TestSuite::SYSTEM)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   336
                {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   337
                  continue;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   338
                }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   339
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   340
              if (typeName == "example" && type != TestSuite::EXAMPLE)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   341
                {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   342
                  continue;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   343
                }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   344
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   345
              if (typeName == "performance" && type != TestSuite::PERFORMANCE)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   346
                {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   347
                  continue;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   348
                }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   349
            }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   350
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   351
          //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   352
          // This creates a list of test suite names that can be used by the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   353
          // high level test manager to get a list of all tests.  It will then
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   354
          // typically launch individual tests in parallel, calling back here
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   355
          // with a specific "suite=" to run.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   356
          //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   357
          std::cout << suite->GetName () << std::endl;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   358
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   359
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   360
      return false;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   361
    }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   362
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   363
  //
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   364
  // We have a lot of options possible to provide flexibility.  It can become
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   365
  // painful, however, to provide all of the options when debugging, and it 
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   366
  // turns out that not all tests require all options.  It is really helpful
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   367
  // to try and put together some reasonable defaults if we're not provided
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   368
  // them.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   369
  //
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   370
  if (!haveTempdir)
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   371
    {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   372
      //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   373
      // No temporary directory was provided.  We don't know if the selected
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   374
      // test or tests will need one, but we can cook something up.  The 
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   375
      // tmpnam function has its own set of problems, so we'll just do our 
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   376
      // own thing.
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   377
      //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   378
      tempdir = TempDir ();
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   379
      if (tempdir.size ()) 
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   380
        {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   381
          std::cout << "Temporary directory not provided.  Using \"" << tempdir << "\"" << std::endl;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   382
          haveTempdir = true;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   383
        }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   384
      else
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   385
        {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   386
          std::cout << "Temporary directory not provided and unable to create one." << std::endl;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   387
          return true;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   388
        }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   389
    }
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   390
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   391
  if (haveBasedir == false)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   392
    {
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   393
      //
6228
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
   394
      // No basedir was provided.  If we don't have it, we can try and find it 
4a2c9eaedb7f tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents: 6204
diff changeset
   395
      // in the current directory tree.
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   396
      //
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   397
      basedir = BaseDir ();
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   398
      if (basedir.size ()) 
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   399
        {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   400
          std::cout << "Base directory not provided.  Using \"" << basedir << "\"" << std::endl;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   401
          haveBasedir = true;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   402
        }
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   403
      else
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   404
        {
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   405
          std::cout << "Base directory not provided and unable to find one." << std::endl;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   406
          return true;
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   407
        }
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   408
    }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   409
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   410
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   411
  // If given an output file, we just append the output of each test suite 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   412
  // we're asked to run to the end of that file.  We need to append since the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   413
  // higher level test runner may be just running a number of tests back to 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   414
  // back.  We leave it up to that code to decide how to deal with possible
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   415
  // parallel operation -- we just append to a file here.  If no output file
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   416
  // is specified, we don't do any output and just return the sense of error
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   417
  // given by the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   418
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   419
  std::ofstream *pofs = 0;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   420
  std::ofstream ofs;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   421
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   422
  if (!outfileName.empty ())
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   423
    {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   424
      ofs.open (outfileName.c_str (), std::fstream::out | std::fstream::app);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   425
      pofs = &ofs;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   426
    }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   427
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   428
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   429
  // If we have a specified test suite to run, then we only run that suite.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   430
  // The default case is to "run everything.  We don't expect this to be done
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   431
  // much since typically higher level code will be running suites in parallel
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   432
  // but we'll do it if asked.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   433
  //
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   434
  bool result = false;
5297
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   435
  bool suiteRan = false;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   436
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   437
  for (uint32_t i = 0; i < TestRunner::GetNTestSuites (); ++i)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   438
    {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   439
      TestSuite *testSuite = TestRunner::GetTestSuite (i);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   440
      if (doSuite == false || (doSuite == true && suiteName == testSuite->GetName ()))
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   441
        {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   442
          testSuite->SetBaseDir (basedir);
5481
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   443
          testSuite->SetTempDir (tempdir);
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   444
          testSuite->SetStream (pofs);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   445
          testSuite->SetVerbose (doVerbose);
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5297
diff changeset
   446
          testSuite->SetContinueOnFailure (doMultiple);
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   447
          result |= testSuite->Run ();
5297
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   448
          suiteRan = true;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   449
        }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   450
    }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   451
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   452
  ofs.close();
5297
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   453
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   454
  //
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   455
  // If we couldn't figure out how to run at least one test, then return an error
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   456
  //
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   457
  if (suiteRan == false)
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   458
    {
6194
5f8e99c4c456 make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents: 5780
diff changeset
   459
      std::cout << "Unable to find a test to run (constraints too severe or test not found)" << std::endl;
5297
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   460
      return true;
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   461
    }
a7f197a2410b If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
   462
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   463
  return result;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   464
}