test.py
author Tom Henderson <tomh@tomh.org>
Mon, 28 Sep 2015 20:27:25 -0700
changeset 11676 05ea1489e509
parent 11634 99173c0ad09b
permissions -rwxr-xr-x
bug 2184: Integer overflow in MacLow
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
#! /usr/bin/env python
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
# Copyright (c) 2009 University of Washington
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
# 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
     7
# 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
     8
# published by the Free Software Foundation;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
# 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
    11
# 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
    12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
# GNU General Public License for more details.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
# 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
    16
# 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
    17
# 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
    18
#
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
    19
from __future__ import print_function
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
import os
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
import sys
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
    22
import time
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
import optparse
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
import subprocess
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
import threading
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
import signal
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
import xml.dom.minidom
5239
2e753de86174 Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
    28
import shutil
5912
679c04aa43e7 Update test.py to detect still reachable memory blocks as errors, it will fail if there is some reachable memory blocks reported by valgrind
fmoatamr
parents: 5909
diff changeset
    29
import re
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
    31
from utils import get_list_from_file
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
    32
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
    33
try:
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
    34
    import queue
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
    35
except ImportError:
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
    36
    import Queue as queue
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
# XXX This should really be part of a waf command to list the configuration
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
# items relative to optional ns-3 pieces.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
# A list of interesting configuration items in the waf configuration 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
# cache which we may be interested in when deciding on which examples
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
# to run and how to run them.  These are set by waf during the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
# configuration phase and the corresponding assignments are usually
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
# found in the associated subdirectory wscript files.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
interesting_config_items = [
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
    48
    "NS3_ENABLED_MODULES",
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
    "NS3_MODULE_PATH",
6619
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
    50
    "NSC_ENABLED",
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
    "ENABLE_REAL_TIME",
7028
3963d3678649 Make examples that were in samples directory run
Mitch Watrous <watrous@u.washington.edu>
parents: 6890
diff changeset
    52
    "ENABLE_THREADING",
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
    53
    "ENABLE_EXAMPLES",
7245
4b245d55faa2 Bug 1146 - help string for test.py with disabled tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7199
diff changeset
    54
    "ENABLE_TESTS",
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
    55
    "EXAMPLE_DIRECTORIES",
6243
a597d6d2da85 Bug 882 - ./test.py reports 6 FAILs with --disable-python
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6227
diff changeset
    56
    "ENABLE_PYTHON_BINDINGS",
6825
f9a45d9a10d0 NS-3 Click Integration merge
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6801
diff changeset
    57
    "ENABLE_CLICK",
9164
347452534b2e Brite Integration
Brian Swenson <bswenson3@gatech.edu>
parents: 9076
diff changeset
    58
    "ENABLE_BRITE",
6890
e5da7045526e Merge OpenFlow
Josh Pelkey <jpelkey@gatech.edu>
parents: 6886
diff changeset
    59
    "ENABLE_OPENFLOW",
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    60
    "APPNAME",
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    61
    "BUILD_PROFILE",
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    62
    "VERSION",
7687
9918e57b9f8d bug 1317: allow test.py to learn which python version was used to build ns-3
Tom Henderson <tomh@tomh.org>
parents: 7682
diff changeset
    63
    "PYTHON",
9832
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
    64
    "VALGRIND_FOUND",
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
]
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
6619
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
    67
NSC_ENABLED = False
5295
c1bd4ffb5e47 fix test.py -v
Craig Dowell <craigdo@ee.washington.edu>
parents: 5279
diff changeset
    68
ENABLE_REAL_TIME = False
7028
3963d3678649 Make examples that were in samples directory run
Mitch Watrous <watrous@u.washington.edu>
parents: 6890
diff changeset
    69
ENABLE_THREADING = False
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
    70
ENABLE_EXAMPLES = True
7245
4b245d55faa2 Bug 1146 - help string for test.py with disabled tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7199
diff changeset
    71
ENABLE_TESTS = True
6825
f9a45d9a10d0 NS-3 Click Integration merge
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6801
diff changeset
    72
ENABLE_CLICK = False
9164
347452534b2e Brite Integration
Brian Swenson <bswenson3@gatech.edu>
parents: 9076
diff changeset
    73
ENABLE_BRITE = False
6890
e5da7045526e Merge OpenFlow
Josh Pelkey <jpelkey@gatech.edu>
parents: 6886
diff changeset
    74
ENABLE_OPENFLOW = False
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
    75
EXAMPLE_DIRECTORIES = []
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    76
APPNAME = ""
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    77
BUILD_PROFILE = ""
9850
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
    78
BUILD_PROFILE_SUFFIX = ""
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    79
VERSION = ""
7689
8d3e8dbc5305 postfix bug 1317: support -v option in test.py when python not enabled
Tom Henderson <tomh@tomh.org>
parents: 7687
diff changeset
    80
PYTHON = ""
9832
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
    81
VALGRIND_FOUND = True
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    82
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    83
#
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    84
# This will be given a prefix and a suffix when the waf config file is
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    85
# read.
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    86
#
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
    87
test_runner_name = "test-runner"
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
    88
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
    89
#
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
    90
# If the user has constrained us to run certain kinds of tests, we can tell waf
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
    91
# to only build
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
    92
#
9072
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
    93
core_kinds = ["bvt", "core", "performance", "system", "unit"]
5295
c1bd4ffb5e47 fix test.py -v
Craig Dowell <craigdo@ee.washington.edu>
parents: 5279
diff changeset
    94
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
#
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
    96
# There are some special cases for test suites that kill valgrind.  This is
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
    97
# because NSC causes illegal instruction crashes when run under valgrind.
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
    98
#
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
    99
core_valgrind_skip_tests = [
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   100
    "ns3-tcp-cwnd",
6198
cd1b101cae62 suppress valgrind testing of new nsc test suite
Tom Henderson <tomh@tomh.org>
parents: 6127
diff changeset
   101
    "nsc-tcp-loss",
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   102
    "ns3-tcp-interoperability",
7259
5c63124c3955 remove click from valgrind tests
Josh Pelkey <jpelkey@gatech.edu>
parents: 7245
diff changeset
   103
    "routing-click",
9219
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   104
    "lte-rr-ff-mac-scheduler",
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   105
    "lte-tdmt-ff-mac-scheduler",
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   106
    "lte-fdmt-ff-mac-scheduler",
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   107
    "lte-pf-ff-mac-scheduler",
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   108
    "lte-tta-ff-mac-scheduler",
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   109
    "lte-fdbet-ff-mac-scheduler",
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   110
    "lte-ttbet-ff-mac-scheduler",
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   111
    "lte-fdtbfq-ff-mac-scheduler",
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   112
    "lte-tdtbfq-ff-mac-scheduler",
f09a0822157e bug 1563: reduce valgrind test scope
Tom Henderson <tomh@tomh.org>
parents: 9164
diff changeset
   113
    "lte-pss-ff-mac-scheduler",
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   114
]
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   115
6619
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   116
# 
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   117
# There are some special cases for test suites that fail when NSC is
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   118
# missing.
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   119
#
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   120
core_nsc_missing_skip_tests = [
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   121
    "ns3-tcp-cwnd",
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   122
    "nsc-tcp-loss",
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   123
    "ns3-tcp-interoperability",
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   124
]
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
   125
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   126
#
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   127
# Parse the examples-to-run file if it exists.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
#
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   129
# This function adds any C++ examples or Python examples that are to be run
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   130
# to the lists in example_tests and python_tests, respectively.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   131
#
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   132
def parse_examples_to_run_file(
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   133
    examples_to_run_path,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   134
    cpp_executable_dir,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   135
    python_script_dir,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   136
    example_tests,
9220
fd38b9505eb9 Add shell script that runs all examples with full logging turned on
Mitch Watrous <watrous@u.washington.edu>
parents: 9219
diff changeset
   137
    example_names_original,
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   138
    python_tests):
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
   139
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   140
    # Look for the examples-to-run file exists.
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   141
    if os.path.exists(examples_to_run_path):
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
   142
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   143
        # Each tuple in the C++ list of examples to run contains
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   144
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   145
        #     (example_name, do_run, do_valgrind_run)
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   146
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   147
        # where example_name is the executable to be run, do_run is a
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   148
        # condition under which to run the example, and do_valgrind_run is
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   149
        # a condition under which to run the example under valgrind.  This
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   150
        # is needed because NSC causes illegal instruction crashes with
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   151
        # some tests when they are run under valgrind.
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   152
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   153
        # Note that the two conditions are Python statements that
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   154
        # can depend on waf configuration variables.  For example,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   155
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   156
        #     ("tcp-nsc-lfn", "NSC_ENABLED == True", "NSC_ENABLED == False"),
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   157
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   158
        cpp_examples = get_list_from_file(examples_to_run_path, "cpp_examples")
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   159
        for example_name, do_run, do_valgrind_run in cpp_examples:
9220
fd38b9505eb9 Add shell script that runs all examples with full logging turned on
Mitch Watrous <watrous@u.washington.edu>
parents: 9219
diff changeset
   160
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   161
            # Seperate the example name from its arguments.
9220
fd38b9505eb9 Add shell script that runs all examples with full logging turned on
Mitch Watrous <watrous@u.washington.edu>
parents: 9219
diff changeset
   162
            example_name_original = example_name
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   163
            example_name_parts = example_name.split(' ', 1)
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   164
            if len(example_name_parts) == 1:
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   165
                example_name      = example_name_parts[0]
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   166
                example_arguments = ""
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   167
            else:
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   168
                example_name      = example_name_parts[0]
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   169
                example_arguments = example_name_parts[1]
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   170
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
   171
            # Add the proper prefix and suffix to the example name to
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
   172
            # match what is done in the wscript file.
10554
ee9c5221e7bd Strip NS3_BUILDDIR from Example path.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9852
diff changeset
   173
            example_path = "%s%s-%s%s" % (APPNAME, VERSION, example_name, BUILD_PROFILE_SUFFIX)
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   174
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   175
            # Set the full path for the example.
10554
ee9c5221e7bd Strip NS3_BUILDDIR from Example path.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9852
diff changeset
   176
            example_path = os.path.join(cpp_executable_dir, example_path)
ee9c5221e7bd Strip NS3_BUILDDIR from Example path.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9852
diff changeset
   177
            example_name = os.path.join(
ee9c5221e7bd Strip NS3_BUILDDIR from Example path.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9852
diff changeset
   178
                os.path.relpath(cpp_executable_dir, NS3_BUILDDIR),
ee9c5221e7bd Strip NS3_BUILDDIR from Example path.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9852
diff changeset
   179
                example_name)
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   180
            # Add all of the C++ examples that were built, i.e. found
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   181
            # in the directory, to the list of C++ examples to run.
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   182
            if os.path.exists(example_path):
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   183
                # Add any arguments to the path.
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   184
                if len(example_name_parts) != 1:
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   185
                    example_path = "%s %s" % (example_path, example_arguments)
10554
ee9c5221e7bd Strip NS3_BUILDDIR from Example path.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9852
diff changeset
   186
                    example_name = "%s %s" % (example_name, example_arguments)
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   187
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   188
                # Add this example.
10554
ee9c5221e7bd Strip NS3_BUILDDIR from Example path.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9852
diff changeset
   189
                example_tests.append((example_name, example_path, do_run, do_valgrind_run))
9220
fd38b9505eb9 Add shell script that runs all examples with full logging turned on
Mitch Watrous <watrous@u.washington.edu>
parents: 9219
diff changeset
   190
                example_names_original.append(example_name_original)
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   191
    
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   192
        # Each tuple in the Python list of examples to run contains
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   193
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   194
        #     (example_name, do_run)
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   195
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   196
        # where example_name is the Python script to be run and
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   197
        # do_run is a condition under which to run the example.
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   198
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   199
        # Note that the condition is a Python statement that can
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   200
        # depend on waf configuration variables.  For example,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   201
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   202
        #     ("realtime-udp-echo.py", "ENABLE_REAL_TIME == True"),
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   203
        #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   204
        python_examples = get_list_from_file(examples_to_run_path, "python_examples")
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   205
        for example_name, do_run in python_examples:
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   206
            # Seperate the example name from its arguments.
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   207
            example_name_parts = example_name.split(' ', 1)
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   208
            if len(example_name_parts) == 1:
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   209
                example_name      = example_name_parts[0]
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   210
                example_arguments = ""
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   211
            else:
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   212
                example_name      = example_name_parts[0]
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   213
                example_arguments = example_name_parts[1]
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   214
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   215
            # Set the full path for the example.
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   216
            example_path = os.path.join(python_script_dir, example_name)
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   217
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   218
            # Add all of the Python examples that were found to the
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   219
            # list of Python examples to run.
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   220
            if os.path.exists(example_path):
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   221
                # Add any arguments to the path.
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   222
                if len(example_name_parts) != 1:
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   223
                    example_path = "%s %s" % (example_path, example_arguments)
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   224
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
   225
                # Add this example.
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
   226
                python_tests.append((example_path, do_run))
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   227
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   228
#
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   229
# The test suites are going to want to output status.  They are running
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   230
# concurrently.  This means that unless we are careful, the output of
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   231
# the test suites will be interleaved.  Rather than introducing a lock
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   232
# file that could unintentionally start serializing execution, we ask
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   233
# the tests to write their output to a temporary directory and then 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   234
# put together the final output file when we "join" the test tasks back
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
   235
# to the main thread.  In addition to this issue, the example programs
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
   236
# often write lots and lots of trace files which we will just ignore.
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
   237
# We put all of them into the temp directory as well, so they can be
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
   238
# easily deleted.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   239
#
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
   240
TMP_OUTPUT_DIR = "testpy-output"
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   241
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   242
def read_test(test):
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   243
    result = test.find('Result').text
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   244
    name = test.find('Name').text
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   245
    if not test.find('Time') is None:
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   246
        time_real = test.find('Time').get('real')
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   247
    else:
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   248
        time_real = ''
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   249
    return (result, name, time_real)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   250
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   251
#
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   252
# A simple example of writing a text file with a test result summary.  It is 
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   253
# expected that this output will be fine for developers looking for problems.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   254
#
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   255
def node_to_text (test, f):
7406
5249884a7e52 test.py:node_to_text time to time_real
John Abraham <john.abraham@gatech.edu>
parents: 7379
diff changeset
   256
    (result, name, time_real) = read_test(test)
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   257
    output = "%s: Test Suite \"%s\" (%s)\n" % (result, name, time_real)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   258
    f.write(output)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   259
    for details in test.findall('FailureDetails'):
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   260
        f.write("    Details:\n")
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   261
        f.write("      Message:   %s\n" % details.find('Message').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   262
        f.write("      Condition: %s\n" % details.find('Condition').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   263
        f.write("      Actual:    %s\n" % details.find('Actual').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   264
        f.write("      Limit:     %s\n" % details.find('Limit').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   265
        f.write("      File:      %s\n" % details.find('File').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   266
        f.write("      Line:      %s\n" % details.find('Line').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   267
    for child in test.findall('Test'):
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   268
        node_to_text(child, f)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   269
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   270
def translate_to_text(results_file, text_file):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   271
    f = open(text_file, 'w')
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   272
    import xml.etree.ElementTree as ET
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   273
    et = ET.parse (results_file)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   274
    for test in et.findall('Test'):
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   275
        node_to_text (test, f)
7199
eae56a101979 Bug 957 - Issue with test.py
Mitch Watrous <watrous@u.washington.edu>
parents: 7096
diff changeset
   276
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   277
    for example in et.findall('Example'):
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   278
        result = example.find('Result').text
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   279
        name = example.find('Name').text
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   280
        if not example.find('Time') is None:
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   281
            time_real = example.find('Time').get('real')
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   282
        else:
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   283
            time_real = ''
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   284
        output = "%s: Example \"%s\" (%s)\n" % (result, name, time_real)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   285
        f.write(output)
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
    f.close()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   288
    
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   289
#
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   290
# A simple example of writing an HTML file with a test result summary.  It is 
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   291
# expected that this will eventually be made prettier as time progresses and
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   292
# we have time to tweak it.  This may end up being moved to a separate module
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   293
# since it will probably grow over time.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   294
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   295
def translate_to_html(results_file, html_file):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   296
    f = open(html_file, 'w')
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   297
    f.write("<html>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   298
    f.write("<body>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   299
    f.write("<center><h1>ns-3 Test Results</h1></center>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   300
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   301
    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   302
    # Read and parse the whole results file.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   303
    #
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   304
    import xml.etree.ElementTree as ET
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   305
    et = ET.parse(results_file)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   306
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   307
    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   308
    # Iterate through the test suites
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   309
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   310
    f.write("<h2>Test Suites</h2>\n")
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   311
    for suite in et.findall('Test'):     
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   312
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   313
        # For each test suite, get its name, result and execution time info
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   314
        #
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   315
        (result, name, time) = read_test (suite)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   316
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   317
        # 
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   318
        # Print a level three header with the result, name and time.  If the 
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   319
        # test suite passed, the header is printed in green. If the suite was
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   320
        # skipped, print it in orange, otherwise assume something bad happened
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   321
        # and print in red.
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   322
        #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   323
        if result == "PASS":
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   324
            f.write("<h3 style=\"color:green\">%s: %s (%s)</h3>\n" % (result, name, time))
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   325
        elif result == "SKIP":
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   326
            f.write("<h3 style=\"color:#ff6600\">%s: %s (%s)</h3>\n" % (result, name, time))
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   327
        else:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   328
            f.write("<h3 style=\"color:red\">%s: %s (%s)</h3>\n" % (result, name, time))
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   329
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   330
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   331
        # The test case information goes in a table.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   332
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   333
        f.write("<table border=\"1\">\n")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   334
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   335
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   336
        # The first column of the table has the heading Result
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   337
        #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   338
        f.write("<th> Result </th>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   339
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   340
        #
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   341
        # If the suite crashed or is skipped, there is no further information, so just
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   342
        # delare a new table row with the result (CRASH or SKIP) in it.  Looks like:
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   343
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   344
        #   +--------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   345
        #   | Result |
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   346
        #   +--------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   347
        #   | CRASH  |
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   348
        #   +--------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   349
        #
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   350
        # Then go on to the next test suite.  Valgrind and skipped errors look the same.
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   351
        #
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   352
        if result in ["CRASH", "SKIP", "VALGR"]:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   353
            f.write("<tr>\n")
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   354
            if result == "SKIP":
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   355
                f.write("<td style=\"color:#ff6600\">%s</td>\n" % result)
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   356
            else:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   357
                f.write("<td style=\"color:red\">%s</td>\n" % result)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   358
            f.write("</tr>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   359
            f.write("</table>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   360
            continue
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   361
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   362
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   363
        # If the suite didn't crash, we expect more information, so fill out
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   364
        # the table heading row.  Like,
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   365
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   366
        #   +--------+----------------+------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   367
        #   | Result | Test Case Name | Time |
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   368
        #   +--------+----------------+------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   369
        #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   370
        f.write("<th>Test Case Name</th>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   371
        f.write("<th> Time </th>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   372
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   373
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   374
        # If the test case failed, we need to print out some failure details
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   375
        # so extend the heading row again.  Like,
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   376
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   377
        #   +--------+----------------+------+-----------------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   378
        #   | Result | Test Case Name | Time | Failure Details |
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   379
        #   +--------+----------------+------+-----------------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   380
        #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   381
        if result == "FAIL":
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   382
            f.write("<th>Failure Details</th>\n")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   383
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   384
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   385
        # Now iterate through all of the test cases.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   386
        #
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   387
        for case in suite.findall('Test'):
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   388
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   389
            #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   390
            # Get the name, result and timing information from xml to use in
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   391
            # printing table below.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   392
            #
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   393
            (result, name, time) = read_test(case)
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   394
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   395
            #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   396
            # If the test case failed, we iterate through possibly multiple
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   397
            # failure details
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   398
            #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   399
            if result == "FAIL":
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   400
                #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   401
                # There can be multiple failures for each test case.  The first
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   402
                # row always gets the result, name and timing information along
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   403
                # with the failure details.  Remaining failures don't duplicate
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   404
                # this information but just get blanks for readability.  Like,
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   405
                #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   406
                #   +--------+----------------+------+-----------------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   407
                #   | Result | Test Case Name | Time | Failure Details |
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   408
                #   +--------+----------------+------+-----------------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   409
                #   |  FAIL  | The name       | time | It's busted     |   
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   410
                #   +--------+----------------+------+-----------------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   411
                #   |        |                |      | Really broken   |   
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   412
                #   +--------+----------------+------+-----------------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   413
                #   |        |                |      | Busted bad      |   
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   414
                #   +--------+----------------+------+-----------------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   415
                #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   416
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   417
                first_row = True
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   418
                for details in case.findall('FailureDetails'):
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   419
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   420
                    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   421
                    # Start a new row in the table for each possible Failure Detail
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   422
                    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   423
                    f.write("<tr>\n")
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   424
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   425
                    if first_row:
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   426
                        first_row = False
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   427
                        f.write("<td style=\"color:red\">%s</td>\n" % result)
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   428
                        f.write("<td>%s</td>\n" % name)
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   429
                        f.write("<td>%s</td>\n" % time)
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   430
                    else:
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   431
                        f.write("<td></td>\n")
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   432
                        f.write("<td></td>\n")
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   433
                        f.write("<td></td>\n")
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   434
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   435
                    f.write("<td>")
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   436
                    f.write("<b>Message: </b>%s, " % details.find('Message').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   437
                    f.write("<b>Condition: </b>%s, " % details.find('Condition').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   438
                    f.write("<b>Actual: </b>%s, " % details.find('Actual').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   439
                    f.write("<b>Limit: </b>%s, " % details.find('Limit').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   440
                    f.write("<b>File: </b>%s, " % details.find('File').text)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   441
                    f.write("<b>Line: </b>%s" % details.find('Line').text)
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   442
                    f.write("</td>\n")
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   443
                    
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   444
                    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   445
                    # End the table row
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   446
                    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   447
                    f.write("</td>\n")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   448
            else:
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   449
                #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   450
                # If this particular test case passed, then we just print the PASS
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   451
                # result in green, followed by the test case name and its execution
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   452
                # time information.  These go off in <td> ... </td> table data.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   453
                # The details table entry is left blank.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   454
                #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   455
                #   +--------+----------------+------+---------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   456
                #   | Result | Test Case Name | Time | Details |
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   457
                #   +--------+----------------+------+---------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   458
                #   |  PASS  | The name       | time |         |   
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   459
                #   +--------+----------------+------+---------+
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   460
                #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   461
                f.write("<tr>\n")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   462
                f.write("<td style=\"color:green\">%s</td>\n" % result)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   463
                f.write("<td>%s</td>\n" % name)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   464
                f.write("<td>%s</td>\n" % time)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   465
                f.write("<td></td>\n")
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   466
                f.write("</tr>\n")
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   467
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   468
        # All of the rows are written, so we need to end the table.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   469
        #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   470
        f.write("</table>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   471
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   472
    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   473
    # That's it for all of the test suites.  Now we have to do something about 
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   474
    # our examples.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   475
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   476
    f.write("<h2>Examples</h2>\n")
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   477
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   478
    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   479
    # Example status is rendered in a table just like the suites.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   480
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   481
    f.write("<table border=\"1\">\n")
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   482
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   483
    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   484
    # The table headings look like,
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   485
    #
5460
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   486
    #   +--------+--------------+--------------+
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   487
    #   | Result | Example Name | Elapsed Time |
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   488
    #   +--------+--------------+--------------+
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   489
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   490
    f.write("<th> Result </th>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   491
    f.write("<th>Example Name</th>\n")
5460
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   492
    f.write("<th>Elapsed Time</th>\n")
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   493
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   494
    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   495
    # Now iterate through all of the examples
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   496
    #
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   497
    for example in et.findall("Example"):
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   498
        
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   499
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   500
        # Start a new row for each example
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   501
        #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   502
        f.write("<tr>\n")
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   503
        
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   504
        #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   505
        # Get the result and name of the example in question
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   506
        #
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   507
        (result, name, time) = read_test(example)
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   508
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   509
        #
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   510
        # If the example either failed or crashed, print its result status
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   511
        # in red; otherwise green.  This goes in a <td> ... </td> table data
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   512
        #
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   513
        if result == "PASS":
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   514
            f.write("<td style=\"color:green\">%s</td>\n" % result)
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   515
        elif result == "SKIP":
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   516
            f.write("<td style=\"color:#ff6600\">%s</fd>\n" % result)
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   517
        else:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   518
            f.write("<td style=\"color:red\">%s</td>\n" % result)
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   519
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   520
        #
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   521
        # Write the example name as a new tag data.
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   522
        #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   523
        f.write("<td>%s</td>\n" % name)
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   524
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   525
        #
5460
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   526
        # Write the elapsed time as a new tag data.
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   527
        #
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   528
        f.write("<td>%s</td>\n" % time)
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   529
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   530
        #
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   531
        # That's it for the current example, so terminate the row.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   532
        #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   533
        f.write("</tr>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   534
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   535
    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   536
    # That's it for the table of examples, so terminate the table.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   537
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   538
    f.write("</table>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   539
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   540
    #
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   541
    # And that's it for the report, so finish up.
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
   542
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   543
    f.write("</body>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   544
    f.write("</html>\n")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   545
    f.close()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   546
    
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   547
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   548
# Python Control-C handling is broken in the presence of multiple threads.  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   549
# Signals get delivered to the runnable/running thread by default and if 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   550
# it is blocked, the signal is simply ignored.  So we hook sigint and set 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   551
# a global variable telling the system to shut down gracefully.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   552
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   553
thread_exit = False
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   554
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   555
def sigint_hook(signal, frame):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   556
    global thread_exit
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   557
    thread_exit = True
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   558
    return 0
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   559
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   560
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   561
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   562
# In general, the build process itself naturally takes care of figuring out
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   563
# which tests are built into the test runner.  For example, if waf configure
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   564
# determines that ENABLE_EMU is false due to some missing dependency,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   565
# the tests for the emu net device simply will not be built and will 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   566
# therefore not be included in the built test runner.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   567
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   568
# Examples, however, are a different story.  In that case, we are just given
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   569
# a list of examples that could be run.  Instead of just failing, for example,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   570
# nsc-tcp-zoo if NSC is not present, we look into the waf saved configuration
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   571
# for relevant configuration items.  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   572
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   573
# XXX This function pokes around in the waf internal state file.  To be a
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   574
# little less hacky, we should add a commmand to waf to return this info
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   575
# and use that result.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   576
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   577
def read_waf_config():
7669
ab2af491785a align test.py with waf-1.6.10 changes
Tom Henderson <tomh@tomh.org>
parents: 7488
diff changeset
   578
    for line in open(".lock-waf_" + sys.platform + "_build", "rt"):
7713
6b3d1a5495f7 Bug 1325
Mitch Watrous <watrous@u.washington.edu>
parents: 7689
diff changeset
   579
        if line.startswith("top_dir ="):
6b3d1a5495f7 Bug 1325
Mitch Watrous <watrous@u.washington.edu>
parents: 7689
diff changeset
   580
            key, val = line.split('=')
6b3d1a5495f7 Bug 1325
Mitch Watrous <watrous@u.washington.edu>
parents: 7689
diff changeset
   581
            top_dir = eval(val.strip())
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
   582
        if line.startswith("out_dir ="):
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
   583
            key, val = line.split('=')
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
   584
            out_dir = eval(val.strip())
7713
6b3d1a5495f7 Bug 1325
Mitch Watrous <watrous@u.washington.edu>
parents: 7689
diff changeset
   585
    global NS3_BASEDIR
6b3d1a5495f7 Bug 1325
Mitch Watrous <watrous@u.washington.edu>
parents: 7689
diff changeset
   586
    NS3_BASEDIR = top_dir
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
   587
    global NS3_BUILDDIR
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
   588
    NS3_BUILDDIR = out_dir
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
   589
    for line in open("%s/c4che/_cache.py" % out_dir).readlines():
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   590
        for item in interesting_config_items:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   591
            if line.startswith(item):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   592
                exec(line, globals())
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   593
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   594
    if options.verbose:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   595
        for item in interesting_config_items:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   596
            print("%s ==" % item, eval(item))
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   597
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   598
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   599
# It seems pointless to fork a process to run waf to fork a process to run
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   600
# the test runner, so we just run the test runner directly.  The main thing 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   601
# that waf would do for us would be to sort out the shared library path but
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   602
# we can deal with that easily and do here.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   603
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   604
# There can be many different ns-3 repositories on a system, and each has 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   605
# its own shared libraries, so ns-3 doesn't hardcode a shared library search
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   606
# path -- it is cooked up dynamically, so we do that too.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   607
#
6227
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   608
def make_paths():
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   609
    have_DYLD_LIBRARY_PATH = False
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   610
    have_LD_LIBRARY_PATH = False
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   611
    have_PATH = False
6227
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   612
    have_PYTHONPATH = False
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   613
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   614
    keys = list(os.environ.keys())
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   615
    for key in keys:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   616
        if key == "DYLD_LIBRARY_PATH":
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   617
            have_DYLD_LIBRARY_PATH = True
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   618
        if key == "LD_LIBRARY_PATH":
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   619
            have_LD_LIBRARY_PATH = True
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   620
        if key == "PATH":
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   621
            have_PATH = True
6227
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   622
        if key == "PYTHONPATH":
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   623
            have_PYTHONPATH = True
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   624
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
   625
    pypath = os.environ["PYTHONPATH"] = os.path.join (NS3_BUILDDIR, "bindings", "python")
6227
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   626
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   627
    if not have_PYTHONPATH:
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   628
        os.environ["PYTHONPATH"] = pypath
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   629
    else:
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   630
        os.environ["PYTHONPATH"] += ":" + pypath
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   631
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
   632
    if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   633
        print("os.environ[\"PYTHONPATH\"] == %s" % os.environ["PYTHONPATH"])
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   634
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   635
    if sys.platform == "darwin":
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   636
        if not have_DYLD_LIBRARY_PATH:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   637
            os.environ["DYLD_LIBRARY_PATH"] = ""
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   638
        for path in NS3_MODULE_PATH:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   639
            os.environ["DYLD_LIBRARY_PATH"] += ":" + path
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   640
        if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   641
            print("os.environ[\"DYLD_LIBRARY_PATH\"] == %s" % os.environ["DYLD_LIBRARY_PATH"])
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   642
    elif sys.platform == "win32":
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   643
        if not have_PATH:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   644
            os.environ["PATH"] = ""
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   645
        for path in NS3_MODULE_PATH:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   646
            os.environ["PATH"] += ';' + path
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   647
        if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   648
            print("os.environ[\"PATH\"] == %s" % os.environ["PATH"])
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   649
    elif sys.platform == "cygwin":
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   650
        if not have_PATH:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   651
            os.environ["PATH"] = ""
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   652
        for path in NS3_MODULE_PATH:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   653
            os.environ["PATH"] += ":" + path
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   654
        if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   655
            print("os.environ[\"PATH\"] == %s" % os.environ["PATH"])
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   656
    else:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   657
        if not have_LD_LIBRARY_PATH:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   658
            os.environ["LD_LIBRARY_PATH"] = ""
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   659
        for path in NS3_MODULE_PATH:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   660
            os.environ["LD_LIBRARY_PATH"] += ":" + str(path)
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   661
        if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   662
            print("os.environ[\"LD_LIBRARY_PATH\"] == %s" % os.environ["LD_LIBRARY_PATH"])
5275
d4008f2981ba Windows needs entire path
Craig Dowell <craigdo@ee.washington.edu>
parents: 5274
diff changeset
   663
5909
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   664
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   665
# Short note on generating suppressions:
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   666
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   667
# See the valgrind documentation for a description of suppressions.  The easiest
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   668
# way to generate a suppression expression is by using the valgrind 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   669
# --gen-suppressions option.  To do that you have to figure out how to run the 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   670
# test in question.
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   671
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   672
# If you do "test.py -v -g -s <suitename> then test.py will output most of what
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   673
# you need.  For example, if you are getting a valgrind error in the
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   674
# devices-mesh-dot11s-regression test suite, you can run:
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   675
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   676
#   ./test.py -v -g -s devices-mesh-dot11s-regression 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   677
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   678
# You should see in the verbose output something that looks like:
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   679
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   680
#   Synchronously execute valgrind --suppressions=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/testpy.supp
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
   681
#   --leak-check=full --error-exitcode=2 /home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/build/debug/utils/ns3-dev-test-runner-debug 
5909
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   682
#   --suite=devices-mesh-dot11s-regression --basedir=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   683
#   --tempdir=testpy-output/2010-01-12-22-47-50-CUT 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   684
#   --out=testpy-output/2010-01-12-22-47-50-CUT/devices-mesh-dot11s-regression.xml
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   685
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   686
# You need to pull out the useful pieces, and so could run the following to 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   687
# reproduce your error:
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   688
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   689
#   valgrind --suppressions=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/testpy.supp
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
   690
#   --leak-check=full --error-exitcode=2 /home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/build/debug/utils/ns3-dev-test-runner-debug 
5909
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   691
#   --suite=devices-mesh-dot11s-regression --basedir=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   692
#   --tempdir=testpy-output 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   693
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   694
# Hint: Use the first part of the command as is, and point the "tempdir" to 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   695
# somewhere real.  You don't need to specify an "out" file.
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   696
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   697
# When you run the above command you should see your valgrind error.  The 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   698
# suppression expression(s) can be generated by adding the --gen-suppressions=yes
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   699
# option to valgrind.  Use something like:
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   700
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   701
#   valgrind --gen-suppressions=yes --suppressions=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/testpy.supp
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
   702
#   --leak-check=full --error-exitcode=2 /home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/build/debug/utils/ns3-dev-test-runner-debug 
5909
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   703
#   --suite=devices-mesh-dot11s-regression --basedir=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   704
#   --tempdir=testpy-output 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   705
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   706
# Now when valgrind detects an error it will ask:
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   707
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   708
#   ==27235== ---- Print suppression ? --- [Return/N/n/Y/y/C/c] ----
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   709
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   710
# to which you just enter 'y'<ret>.
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   711
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   712
# You will be provided with a suppression expression that looks something like
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   713
# the following:
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   714
#   {
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   715
#     <insert_a_suppression_name_here>
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   716
#     Memcheck:Addr8
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   717
#     fun:_ZN3ns36dot11s15HwmpProtocolMac8SendPreqESt6vectorINS0_6IePreqESaIS3_EE
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   718
#     fun:_ZN3ns36dot11s15HwmpProtocolMac10SendMyPreqEv
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   719
#     fun:_ZN3ns36dot11s15HwmpProtocolMac18RequestDestinationENS_12Mac48AddressEjj
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   720
#     ...
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   721
#     the rest of the stack frame
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   722
#     ...
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   723
#   }
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   724
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   725
# You need to add a supression name which will only be printed out by valgrind in 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   726
# verbose mode (but it needs to be there in any case).  The entire stack frame is
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   727
# shown to completely characterize the error, but in most cases you won't need 
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   728
# all of that info.  For example, if you want to turn off all errors that happen
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   729
# when the function (fun:) is called, you can just delete the rest of the stack
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   730
# frame.  You can also use wildcards to make the mangled signatures more readable.
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   731
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   732
# I added the following to the testpy.supp file for this particular error:
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   733
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   734
#   {
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   735
#     Supress invalid read size errors in SendPreq() when using HwmpProtocolMac
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   736
#     Memcheck:Addr8
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   737
#     fun:*HwmpProtocolMac*SendPreq*
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   738
#   }
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   739
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   740
# Now, when you run valgrind the error will be suppressed.
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   741
#
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   742
VALGRIND_SUPPRESSIONS_FILE = "testpy.supp"
766442c7f240 Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents: 5741
diff changeset
   743
7087
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   744
def run_job_synchronously(shell_command, directory, valgrind, is_python, build_path=""):
7713
6b3d1a5495f7 Bug 1325
Mitch Watrous <watrous@u.washington.edu>
parents: 7689
diff changeset
   745
    suppressions_path = os.path.join (NS3_BASEDIR, VALGRIND_SUPPRESSIONS_FILE)
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   746
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   747
    if is_python:
7713
6b3d1a5495f7 Bug 1325
Mitch Watrous <watrous@u.washington.edu>
parents: 7689
diff changeset
   748
        path_cmd = PYTHON[0] + " " + os.path.join (NS3_BASEDIR, shell_command)
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   749
    else:
7087
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   750
        if len(build_path):
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   751
            path_cmd = os.path.join (build_path, shell_command)
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   752
        else:
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
   753
            path_cmd = os.path.join (NS3_BUILDDIR, shell_command)
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   754
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   755
    if valgrind:
5917
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   756
        cmd = "valgrind --suppressions=%s --leak-check=full --show-reachable=yes --error-exitcode=2 %s" % (suppressions_path, 
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   757
            path_cmd)
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   758
    else:
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   759
        cmd = path_cmd
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   760
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   761
    if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   762
        print("Synchronously execute %s" % cmd)
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   763
5460
7c6f8ebf4a34 test.py prints example elapsed times
craigdo@ee.washington.edu
parents: 5459
diff changeset
   764
    start_time = time.time()
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   765
    proc = subprocess.Popen(cmd, shell = True, cwd = directory, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
5917
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   766
    stdout_results, stderr_results = proc.communicate()
5912
679c04aa43e7 Update test.py to detect still reachable memory blocks as errors, it will fail if there is some reachable memory blocks reported by valgrind
fmoatamr
parents: 5909
diff changeset
   767
    elapsed_time = time.time() - start_time
5917
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   768
5912
679c04aa43e7 Update test.py to detect still reachable memory blocks as errors, it will fail if there is some reachable memory blocks reported by valgrind
fmoatamr
parents: 5909
diff changeset
   769
    retval = proc.returncode
5917
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   770
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   771
    #
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   772
    # valgrind sometimes has its own idea about what kind of memory management
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   773
    # errors are important.  We want to detect *any* leaks, so the way to do 
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   774
    # that is to look for the presence of a valgrind leak summary section.
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   775
    #
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   776
    # If another error has occurred (like a test suite has failed), we don't 
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   777
    # want to trump that error, so only do the valgrind output scan if the 
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   778
    # test has otherwise passed (return code was zero).
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   779
    #
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   780
    if valgrind and retval == 0 and "== LEAK SUMMARY:" in stderr_results:
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   781
        retval = 2
aa8364846523 Bug 792: Neither test.py nor waf --valgrind catch all kinds of memory leaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5912
diff changeset
   782
    
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   783
    if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   784
        print("Return code = ", retval)
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   785
        print("stderr = ", stderr_results)
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   786
5912
679c04aa43e7 Update test.py to detect still reachable memory blocks as errors, it will fail if there is some reachable memory blocks reported by valgrind
fmoatamr
parents: 5909
diff changeset
   787
    return (retval, stdout_results, stderr_results, elapsed_time)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   788
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   789
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   790
# This class defines a unit of testing work.  It will typically refer to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   791
# a test suite to run using the test-runner, or an example to run directly.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   792
#
5415
5c2f96b507a9 Stray () in test.py (bug 718)
Craig Dowell <craigdo@ee.washington.edu>
parents: 5414
diff changeset
   793
class Job:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   794
    def __init__(self):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   795
        self.is_break = False
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   796
        self.is_skip = False
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   797
        self.is_example = False
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   798
        self.is_pyexample = False
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   799
        self.shell_command = ""
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   800
        self.display_name = ""
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   801
        self.basedir = ""
5481
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5470
diff changeset
   802
        self.tempdir = ""
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   803
        self.cwd = ""
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   804
        self.tmp_file_name = ""
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   805
        self.returncode = False
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   806
        self.elapsed_time = 0
7087
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   807
        self.build_path = ""
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   808
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   809
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   810
    # A job is either a standard job or a special job indicating that a worker
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   811
    # thread should exist.  This special job is indicated by setting is_break 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   812
    # to true.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   813
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   814
    def set_is_break(self, is_break):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   815
        self.is_break = is_break
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   816
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   817
    #
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   818
    # If a job is to be skipped, we actually run it through the worker threads
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   819
    # to keep the PASS, FAIL, CRASH and SKIP processing all in one place.
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   820
    #
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   821
    def set_is_skip(self, is_skip):
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   822
        self.is_skip = is_skip
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   823
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   824
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   825
    # Examples are treated differently than standard test suites.  This is
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   826
    # mostly because they are completely unaware that they are being run as 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   827
    # tests.  So we have to do some special case processing to make them look
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   828
    # like tests.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   829
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   830
    def set_is_example(self, is_example):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   831
        self.is_example = is_example
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   832
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   833
    #
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   834
    # Examples are treated differently than standard test suites.  This is
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   835
    # mostly because they are completely unaware that they are being run as 
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   836
    # tests.  So we have to do some special case processing to make them look
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   837
    # like tests.
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   838
    #
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   839
    def set_is_pyexample(self, is_pyexample):
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   840
        self.is_pyexample = is_pyexample
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   841
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   842
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   843
    # This is the shell command that will be executed in the job.  For example,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   844
    #
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
   845
    #  "utils/ns3-dev-test-runner-debug --test-name=some-test-suite"
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   846
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   847
    def set_shell_command(self, shell_command):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   848
        self.shell_command = shell_command
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   849
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   850
    #
7087
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   851
    # This is the build path where ns-3 was built.  For example,
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   852
    #
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   853
    #  "/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build/debug"
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   854
    #
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   855
    def set_build_path(self, build_path):
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   856
        self.build_path = build_path
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   857
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   858
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   859
    # This is the dispaly name of the job, typically the test suite or example 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   860
    # name.  For example,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   861
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   862
    #  "some-test-suite" or "udp-echo"
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   863
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   864
    def set_display_name(self, display_name):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   865
        self.display_name = display_name
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   866
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   867
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   868
    # This is the base directory of the repository out of which the tests are
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   869
    # being run.  It will be used deep down in the testing framework to determine
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   870
    # where the source directory of the test was, and therefore where to find 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   871
    # provided test vectors.  For example,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   872
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   873
    #  "/home/user/repos/ns-3-dev"
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   874
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   875
    def set_basedir(self, basedir):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   876
        self.basedir = basedir
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   877
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   878
    #
5481
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5470
diff changeset
   879
    # This is the directory to which a running test suite should write any 
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5470
diff changeset
   880
    # temporary files.
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5470
diff changeset
   881
    #
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5470
diff changeset
   882
    def set_tempdir(self, tempdir):
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5470
diff changeset
   883
        self.tempdir = tempdir
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5470
diff changeset
   884
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5470
diff changeset
   885
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   886
    # This is the current working directory that will be given to an executing
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   887
    # test as it is being run.  It will be used for examples to tell them where
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   888
    # to write all of the pcap files that we will be carefully ignoring.  For
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   889
    # example,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   890
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   891
    #  "/tmp/unchecked-traces"
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   892
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   893
    def set_cwd(self, cwd):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   894
        self.cwd = cwd
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   895
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   896
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   897
    # This is the temporary results file name that will be given to an executing 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   898
    # test as it is being run.  We will be running all of our tests in parallel
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   899
    # so there must be multiple temporary output files.  These will be collected
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
   900
    # into a single XML file at the end and then be deleted.  
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   901
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   902
    def set_tmp_file_name(self, tmp_file_name):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   903
        self.tmp_file_name = tmp_file_name
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   904
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   905
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   906
    # The return code received when the job process is executed.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   907
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   908
    def set_returncode(self, returncode):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   909
        self.returncode = returncode
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   910
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   911
    #
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   912
    # The elapsed real time for the job execution.
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   913
    #
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   914
    def set_elapsed_time(self, elapsed_time):
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   915
        self.elapsed_time = elapsed_time
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   916
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   917
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   918
# The worker thread class that handles the actual running of a given test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   919
# Once spawned, it receives requests for work through its input_queue and
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   920
# ships the results back through the output_queue.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   921
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   922
class worker_thread(threading.Thread):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   923
    def __init__(self, input_queue, output_queue):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   924
        threading.Thread.__init__(self)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   925
        self.input_queue = input_queue
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   926
        self.output_queue = output_queue
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   927
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   928
    def run(self):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   929
        while True:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   930
            job = self.input_queue.get()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   931
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   932
            # Worker threads continue running until explicitly told to stop with
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   933
            # a special job.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   934
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   935
            if job.is_break:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   936
                return
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   937
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   938
            # If the global interrupt handler sets the thread_exit variable,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   939
            # we stop doing real work and just report back a "break" in the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   940
            # normal command processing has happened.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   941
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   942
            if thread_exit == True:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   943
                job.set_is_break(True)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   944
                self.output_queue.put(job)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   945
                continue
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   946
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   947
            #
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   948
            # If we are actually supposed to skip this job, do so.  Note that
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   949
            # if is_skip is true, returncode is undefined.
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   950
            #
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   951
            if job.is_skip:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   952
                if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   953
                    print("Skip %s" % job.shell_command)
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   954
                self.output_queue.put(job)
6253
3aa30fa758f5 bug 886
Craig Dowell <craigdo@ee.washington.edu>
parents: 6247
diff changeset
   955
                continue
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
   956
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   957
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   958
            # Otherwise go about the business of running tests as normal.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   959
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   960
            else:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   961
                if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   962
                    print("Launch %s" % job.shell_command)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   963
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   964
                if job.is_example or job.is_pyexample:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   965
                    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   966
                    # If we have an example, the shell command is all we need to
7819
30638cb5fd62 fix test.py comments
Tom Henderson <tomh@tomh.org>
parents: 7713
diff changeset
   967
                    # know.  It will be something like "examples/udp/udp-echo" or 
30638cb5fd62 fix test.py comments
Tom Henderson <tomh@tomh.org>
parents: 7713
diff changeset
   968
                    # "examples/wireless/mixed-wireless.py"
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   969
                    #
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   970
                    (job.returncode, standard_out, standard_err, et) = run_job_synchronously(job.shell_command, 
7087
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
   971
                        job.cwd, options.valgrind, job.is_pyexample, job.build_path)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   972
                else:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   973
                    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   974
                    # If we're a test suite, we need to provide a little more info
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   975
                    # to the test runner, specifically the base directory and temp
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   976
                    # file name
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   977
                    #
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   978
                    if options.update_data:
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   979
                        update_data = '--update-data'
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   980
                    else:
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   981
                        update_data = ''
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   982
                    (job.returncode, standard_out, standard_err, et) = run_job_synchronously(job.shell_command + 
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
   983
                        " --xml --tempdir=%s --out=%s %s" % (job.tempdir, job.tmp_file_name, update_data), 
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
   984
                        job.cwd, options.valgrind, False)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   985
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   986
                job.set_elapsed_time(et)
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
   987
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   988
                if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   989
                    print("returncode = %d" % job.returncode)
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   990
                    print("---------- begin standard out ----------")
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   991
                    print(standard_out)
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   992
                    print("---------- begin standard err ----------")
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   993
                    print(standard_err)
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
   994
                    print("---------- end standard err ----------")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   995
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   996
                self.output_queue.put(job)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   997
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   998
#
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
   999
# This is the main function that does the work of interacting with the
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1000
# test-runner itself.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1001
#
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1002
def run_tests():
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1003
    #
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1004
    # Pull some interesting configuration information out of waf, primarily
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1005
    # so we can know where executables can be found, but also to tell us what
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1006
    # pieces of the system have been built.  This will tell us what examples 
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1007
    # are runnable.
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1008
    #
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1009
    read_waf_config()
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1010
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1011
    #
9850
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1012
    # Set the proper suffix.
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1013
    #
9851
33cfe647ba55 Make examples again work for nonrelease builds
Mitch Watrous <watrous@u.washington.edu>
parents: 9850
diff changeset
  1014
    global BUILD_PROFILE_SUFFIX
9850
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1015
    if BUILD_PROFILE == 'release': 
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1016
        BUILD_PROFILE_SUFFIX = ""
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1017
    else:
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1018
        BUILD_PROFILE_SUFFIX = "-" + BUILD_PROFILE
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1019
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1020
    #
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1021
    # Add the proper prefix and suffix to the test-runner name to
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1022
    # match what is done in the wscript file.
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1023
    #
9850
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1024
    test_runner_name = "%s%s-%s%s" % (APPNAME, VERSION, "test-runner", BUILD_PROFILE_SUFFIX)
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1025
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1026
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1027
    # Run waf to make sure that everything is built, configured and ready to go
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1028
    # unless we are explicitly told not to.  We want to be careful about causing
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1029
    # our users pain while waiting for extraneous stuff to compile and link, so
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1030
    # we allow users that know what they''re doing to not invoke waf at all.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1031
    #
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1032
    if not options.nowaf:
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1033
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1034
        #
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1035
        # If the user is running the "kinds" or "list" options, there is an 
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1036
        # implied dependency on the test-runner since we call that program
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1037
        # if those options are selected.  We will exit after processing those
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1038
        # options, so if we see them, we can safely only build the test-runner.
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1039
        #
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1040
        # If the user has constrained us to running only a particular type of
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1041
        # file, we can only ask waf to build what we know will be necessary.
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1042
        # For example, if the user only wants to run BVT tests, we only have
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1043
        # to build the test-runner and can ignore all of the examples.
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1044
        #
5470
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1045
        # If the user only wants to run a single example, then we can just build
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1046
        # that example.
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1047
        #
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1048
        # If there is no constraint, then we have to build everything since the
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1049
        # user wants to run everything.
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1050
        #
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1051
        if options.kinds or options.list or (len(options.constrain) and options.constrain in core_kinds):
5470
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1052
            if sys.platform == "win32":
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1053
                waf_cmd = sys.executable + " waf --target=test-runner"
5470
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1054
            else:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1055
                waf_cmd = sys.executable + " waf --target=test-runner"
5470
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1056
        elif len(options.example):
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1057
            if sys.platform == "win32": #Modify for windows
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1058
                waf_cmd = sys.executable + " waf --target=%s" % os.path.basename(options.example)
5470
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1059
            else:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1060
                waf_cmd = sys.executable + " waf --target=%s" % os.path.basename(options.example)
5470
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1061
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1062
        else:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1063
            if sys.platform == "win32": #Modify for windows
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1064
                waf_cmd = sys.executable + " waf"
5470
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1065
            else:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1066
                waf_cmd = sys.executable + " waf"
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1067
5470
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1068
        if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1069
            print("Building: %s" % waf_cmd)
5470
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1070
d3aabb63dd12 remind test.py how to build on unix and limit build scope when posible
Craig Dowell <craigdo@ee.washington.edu>
parents: 5466
diff changeset
  1071
        proc = subprocess.Popen(waf_cmd, shell = True)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1072
        proc.communicate()
6315
1f53e122254b fix bug 908
Andrey Mazo <mazo@iitp.ru>
parents: 6312
diff changeset
  1073
        if proc.returncode:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1074
            print("Waf died. Not running tests", file=sys.stderr)
6315
1f53e122254b fix bug 908
Andrey Mazo <mazo@iitp.ru>
parents: 6312
diff changeset
  1075
            return proc.returncode
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1076
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1077
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1078
    #
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1079
    # Dynamically set up paths.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1080
    #
6227
38a3d54b5742 python path helps when running python programs
Craig Dowell <craigdo@ee.washington.edu>
parents: 6203
diff changeset
  1081
    make_paths()
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1082
9076
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1083
    #
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1084
    # Get the information from the build status file.
9076
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1085
    #
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
  1086
    build_status_file = os.path.join (NS3_BUILDDIR, 'build-status.py')
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1087
    if os.path.exists(build_status_file):
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1088
        ns3_runnable_programs = get_list_from_file(build_status_file, "ns3_runnable_programs")
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1089
        ns3_runnable_scripts = get_list_from_file(build_status_file, "ns3_runnable_scripts")
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1090
    else:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1091
        print('The build status file was not found.  You must do waf build before running test.py.', file=sys.stderr)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1092
        sys.exit(2)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1093
9076
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1094
    #
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1095
    # Make a dictionary that maps the name of a program to its path.
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1096
    #
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1097
    ns3_runnable_programs_dictionary = {}
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1098
    for program in ns3_runnable_programs:
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1099
        # Remove any directory names from path.
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1100
        program_name = os.path.basename(program)
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1101
        ns3_runnable_programs_dictionary[program_name] = program
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1102
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1103
    # Generate the lists of examples to run as smoke tests in order to
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1104
    # ensure that they remain buildable and runnable over time.
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1105
    #
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1106
    example_tests = []
9220
fd38b9505eb9 Add shell script that runs all examples with full logging turned on
Mitch Watrous <watrous@u.washington.edu>
parents: 9219
diff changeset
  1107
    example_names_original = []
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1108
    python_tests = []
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1109
    for directory in EXAMPLE_DIRECTORIES:
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1110
        # Set the directories and paths for this example. 
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1111
        example_directory   = os.path.join("examples", directory)
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1112
        examples_to_run_path = os.path.join(example_directory, "examples-to-run.py")
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
  1113
        cpp_executable_dir   = os.path.join(NS3_BUILDDIR, example_directory)
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1114
        python_script_dir    = os.path.join(example_directory)
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1115
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1116
        # Parse this example directory's file.
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1117
        parse_examples_to_run_file(
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1118
            examples_to_run_path,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1119
            cpp_executable_dir,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1120
            python_script_dir,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1121
            example_tests,
9220
fd38b9505eb9 Add shell script that runs all examples with full logging turned on
Mitch Watrous <watrous@u.washington.edu>
parents: 9219
diff changeset
  1122
            example_names_original,
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1123
            python_tests)
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1124
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1125
    for module in NS3_ENABLED_MODULES:
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1126
        # Remove the "ns3-" from the module name.
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1127
        module = module[len("ns3-"):]
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1128
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1129
        # Set the directories and paths for this example. 
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1130
        module_directory     = os.path.join("src", module)
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1131
        example_directory    = os.path.join(module_directory, "examples")
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1132
        examples_to_run_path = os.path.join(module_directory, "test", "examples-to-run.py")
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7411
diff changeset
  1133
        cpp_executable_dir   = os.path.join(NS3_BUILDDIR, example_directory)
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1134
        python_script_dir    = os.path.join(example_directory)
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1135
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1136
        # Parse this module's file.
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1137
        parse_examples_to_run_file(
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1138
            examples_to_run_path,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1139
            cpp_executable_dir,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1140
            python_script_dir,
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1141
            example_tests,
9220
fd38b9505eb9 Add shell script that runs all examples with full logging turned on
Mitch Watrous <watrous@u.washington.edu>
parents: 9219
diff changeset
  1142
            example_names_original,
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1143
            python_tests)
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6863
diff changeset
  1144
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1145
    #
6083
a4a7ded174dc test.py turns off NS_LOG locally
Craig Dowell <craigdo@ee.washington.edu>
parents: 6046
diff changeset
  1146
    # If lots of logging is enabled, we can crash Python when it tries to 
a4a7ded174dc test.py turns off NS_LOG locally
Craig Dowell <craigdo@ee.washington.edu>
parents: 6046
diff changeset
  1147
    # save all of the text.  We just don't allow logging to be turned on when
a4a7ded174dc test.py turns off NS_LOG locally
Craig Dowell <craigdo@ee.washington.edu>
parents: 6046
diff changeset
  1148
    # test.py runs.  If you want to see logging output from your tests, you
a4a7ded174dc test.py turns off NS_LOG locally
Craig Dowell <craigdo@ee.washington.edu>
parents: 6046
diff changeset
  1149
    # have to run them using the test-runner directly.
a4a7ded174dc test.py turns off NS_LOG locally
Craig Dowell <craigdo@ee.washington.edu>
parents: 6046
diff changeset
  1150
    #
a4a7ded174dc test.py turns off NS_LOG locally
Craig Dowell <craigdo@ee.washington.edu>
parents: 6046
diff changeset
  1151
    os.environ["NS_LOG"] = ""
a4a7ded174dc test.py turns off NS_LOG locally
Craig Dowell <craigdo@ee.washington.edu>
parents: 6046
diff changeset
  1152
a4a7ded174dc test.py turns off NS_LOG locally
Craig Dowell <craigdo@ee.washington.edu>
parents: 6046
diff changeset
  1153
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1154
    # There are a couple of options that imply we can to exit before starting
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1155
    # up a bunch of threads and running tests.  Let's detect these cases and 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1156
    # handle them without doing all of the hard work.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1157
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1158
    if options.kinds:
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1159
        path_cmd = os.path.join("utils", test_runner_name + " --print-test-type-list")
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1160
        (rc, standard_out, standard_err, et) = run_job_synchronously(path_cmd, os.getcwd(), False, False)
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1161
        print(standard_out.decode())
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1162
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1163
    if options.list:
9074
52d752ab185d Bug 1494 - test.py --constrain doesn't work
Mitch Watrous <watrous@u.washington.edu>
parents: 9073
diff changeset
  1164
        if len(options.constrain):
9075
f8fe606acbda Bug 1493 - test.py --list should show the test type
Mitch Watrous <watrous@u.washington.edu>
parents: 9074
diff changeset
  1165
            path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list --print-test-types --test-type=%s" % options.constrain)
9074
52d752ab185d Bug 1494 - test.py --constrain doesn't work
Mitch Watrous <watrous@u.washington.edu>
parents: 9073
diff changeset
  1166
        else:
9075
f8fe606acbda Bug 1493 - test.py --list should show the test type
Mitch Watrous <watrous@u.washington.edu>
parents: 9074
diff changeset
  1167
            path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list --print-test-types")
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1168
        (rc, standard_out, standard_err, et) = run_job_synchronously(path_cmd, os.getcwd(), False, False)
10828
eca3cb80bc79 print error message when test.py list printing fails
Tom Henderson <tomh@tomh.org>
parents: 10766
diff changeset
  1169
        if rc != 0:
eca3cb80bc79 print error message when test.py list printing fails
Tom Henderson <tomh@tomh.org>
parents: 10766
diff changeset
  1170
            # This is usually a sign that ns-3 crashed or exited uncleanly
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1171
            print(('test.py error:  test-runner return code returned {}'.format(rc)))
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1172
            print(('To debug, try running {}\n'.format('\'./waf --run \"test-runner --print-test-name-list\"\'')))
10828
eca3cb80bc79 print error message when test.py list printing fails
Tom Henderson <tomh@tomh.org>
parents: 10766
diff changeset
  1173
            return
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1174
        if isinstance(standard_out, bytes):
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1175
            standard_out = standard_out.decode()
8919
d5c54a93c3f7 Bug 1475: test.py --list should sort the output
Mitch Watrous <watrous@u.washington.edu>
parents: 7864
diff changeset
  1176
        list_items = standard_out.split('\n')
9075
f8fe606acbda Bug 1493 - test.py --list should show the test type
Mitch Watrous <watrous@u.washington.edu>
parents: 9074
diff changeset
  1177
        list_items.sort()
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1178
        print("Test Type    Test Name")
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1179
        print("---------    ---------")
9075
f8fe606acbda Bug 1493 - test.py --list should show the test type
Mitch Watrous <watrous@u.washington.edu>
parents: 9074
diff changeset
  1180
        for item in list_items:
f8fe606acbda Bug 1493 - test.py --list should show the test type
Mitch Watrous <watrous@u.washington.edu>
parents: 9074
diff changeset
  1181
            if len(item.strip()):
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1182
                print(item)
9220
fd38b9505eb9 Add shell script that runs all examples with full logging turned on
Mitch Watrous <watrous@u.washington.edu>
parents: 9219
diff changeset
  1183
        example_names_original.sort()
fd38b9505eb9 Add shell script that runs all examples with full logging turned on
Mitch Watrous <watrous@u.washington.edu>
parents: 9219
diff changeset
  1184
        for item in example_names_original:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1185
                print("example     ", item)
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1186
        print()
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1187
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1188
    if options.kinds or options.list:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1189
        return
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1190
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1191
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1192
    # We communicate results in two ways.  First, a simple message relating 
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1193
    # PASS, FAIL, CRASH or SKIP is always written to the standard output.  It 
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1194
    # is expected that this will be one of the main use cases.  A developer can
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1195
    # just run test.py with no options and see that all of the tests still 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1196
    # pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1197
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1198
    # The second main use case is when detailed status is requested (with the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1199
    # --text or --html options).  Typicall this will be text if a developer
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1200
    # finds a problem, or HTML for nightly builds.  In these cases, an
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1201
    # XML file is written containing the status messages from the test suites.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1202
    # This file is then read and translated into text or HTML.  It is expected
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1203
    # that nobody will really be interested in the XML, so we write it somewhere
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1204
    # with a unique name (time) to avoid collisions.  In case an error happens, we
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1205
    # provide a runtime option to retain the temporary files.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1206
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1207
    # When we run examples as smoke tests, they are going to want to create
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1208
    # lots and lots of trace files.  We aren't really interested in the contents
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1209
    # of the trace files, so we also just stash them off in the temporary dir.
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1210
    # The retain option also causes these unchecked trace files to be kept.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1211
    #
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1212
    date_and_time = time.strftime("%Y-%m-%d-%H-%M-%S-CUT", time.gmtime())
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1213
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1214
    if not os.path.exists(TMP_OUTPUT_DIR):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1215
        os.makedirs(TMP_OUTPUT_DIR)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1216
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1217
    testpy_output_dir = os.path.join(TMP_OUTPUT_DIR, date_and_time);
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1218
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1219
    if not os.path.exists(testpy_output_dir):
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1220
        os.makedirs(testpy_output_dir)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1221
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1222
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1223
    # Create the main output file and start filling it with XML.  We need to 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1224
    # do this since the tests will just append individual results to this file.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1225
    #
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1226
    xml_results_file = os.path.join(testpy_output_dir, "results.xml")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1227
    f = open(xml_results_file, 'w')
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1228
    f.write('<?xml version="1.0"?>\n')
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1229
    f.write('<Results>\n')
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1230
    f.close()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1231
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1232
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1233
    # We need to figure out what test suites to execute.  We are either given one 
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1234
    # suite or example explicitly via the --suite or --example/--pyexample option,
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1235
    # or we need to call into the test runner and ask it to list all of the available
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1236
    # test suites.  Further, we need to provide the constraint information if it
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1237
    # has been given to us.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1238
    # 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1239
    # This translates into allowing the following options with respect to the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1240
    # suites
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1241
    #
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1242
    #  ./test,py:                                           run all of the suites and examples
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1243
    #  ./test.py --constrain=core:                          run all of the suites of all kinds
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1244
    #  ./test.py --constrain=unit:                          run all unit suites
7819
30638cb5fd62 fix test.py comments
Tom Henderson <tomh@tomh.org>
parents: 7713
diff changeset
  1245
    #  ./test.py --suite=some-test-suite:                   run a single suite
30638cb5fd62 fix test.py comments
Tom Henderson <tomh@tomh.org>
parents: 7713
diff changeset
  1246
    #  ./test.py --example=examples/udp/udp-echo:           run single example
30638cb5fd62 fix test.py comments
Tom Henderson <tomh@tomh.org>
parents: 7713
diff changeset
  1247
    #  ./test.py --pyexample=examples/wireless/mixed-wireless.py:  run python example
30638cb5fd62 fix test.py comments
Tom Henderson <tomh@tomh.org>
parents: 7713
diff changeset
  1248
    #  ./test.py --suite=some-suite --example=some-example: run the single suite
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1249
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1250
    # We can also use the --constrain option to provide an ordering of test 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1251
    # execution quite easily.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1252
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1253
    if len(options.suite):
7411
9b4d53a854bb Bug 1235 - test.py reports success on invalid tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7406
diff changeset
  1254
        # See if this is a valid test suite.
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1255
        path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list")
7411
9b4d53a854bb Bug 1235 - test.py reports success on invalid tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7406
diff changeset
  1256
        (rc, suites, standard_err, et) = run_job_synchronously(path_cmd, os.getcwd(), False, False)
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1257
        if isinstance(suites, bytes):
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1258
            suites = suites.decode()
9073
24a5b2e6f691 Bug 1495 - test.py claims test passed when no test was run
Mitch Watrous <watrous@u.washington.edu>
parents: 9072
diff changeset
  1259
        if options.suite in suites.split('\n'):
7411
9b4d53a854bb Bug 1235 - test.py reports success on invalid tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7406
diff changeset
  1260
            suites = options.suite + "\n"
9b4d53a854bb Bug 1235 - test.py reports success on invalid tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7406
diff changeset
  1261
        else:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1262
            print('The test suite was not run because an unknown test suite name was requested.', file=sys.stderr)
7411
9b4d53a854bb Bug 1235 - test.py reports success on invalid tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7406
diff changeset
  1263
            sys.exit(2)
9b4d53a854bb Bug 1235 - test.py reports success on invalid tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7406
diff changeset
  1264
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1265
    elif len(options.example) == 0 and len(options.pyexample) == 0:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1266
        if len(options.constrain):
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1267
            path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list --test-type=%s" % options.constrain)
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1268
            (rc, suites, standard_err, et) = run_job_synchronously(path_cmd, os.getcwd(), False, False)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1269
        else:
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1270
            path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list")
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1271
            (rc, suites, standard_err, et) = run_job_synchronously(path_cmd, os.getcwd(), False, False)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1272
    else:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1273
        suites = ""
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1274
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1275
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1276
    # suite_list will either a single test suite name that the user has 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1277
    # indicated she wants to run or a list of test suites provided by
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1278
    # the test-runner possibly according to user provided constraints.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1279
    # We go through the trouble of setting up the parallel execution 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1280
    # even in the case of a single suite to avoid having two process the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1281
    # results in two different places.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1282
    #
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1283
    if isinstance(suites, bytes):
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1284
        suites = suites.decode()
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1285
    suite_list = suites.split('\n')
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1286
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1287
    #
9072
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1288
    # Performance tests should only be run when they are requested,
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1289
    # i.e. they are not run by default in test.py.
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1290
    #
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1291
    if options.constrain != 'performance':
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1292
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1293
        # Get a list of all of the performance tests.
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1294
        path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list --test-type=%s" % "performance")
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1295
        (rc, performance_tests, standard_err, et) = run_job_synchronously(path_cmd, os.getcwd(), False, False)
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1296
        if isinstance(performance_tests, bytes):
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1297
            performance_tests = performance_tests.decode()
9072
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1298
        performance_test_list = performance_tests.split('\n')
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1299
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1300
        # Remove any performance tests from the suites list.
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1301
        for performance_test in performance_test_list:
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1302
            if performance_test in suite_list:
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1303
                suite_list.remove(performance_test)
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1304
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1305
    # We now have a possibly large number of test suites to run, so we want to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1306
    # run them in parallel.  We're going to spin up a number of worker threads
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1307
    # that will run our test jobs for us.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1308
    #
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1309
    input_queue = queue.Queue(0)
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1310
    output_queue = queue.Queue(0)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1311
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1312
    jobs = 0
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1313
    threads=[]
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1314
5273
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1315
    #
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1316
    # In Python 2.6 you can just use multiprocessing module, but we don't want
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1317
    # to introduce that dependency yet; so we jump through a few hoops.
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1318
    #
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1319
    processors = 1
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1320
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1321
    if sys.platform != "win32":
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1322
        if 'SC_NPROCESSORS_ONLN'in os.sysconf_names:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1323
            processors = os.sysconf('SC_NPROCESSORS_ONLN')
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1324
        else:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1325
            proc = subprocess.Popen("sysctl -n hw.ncpu", shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1326
            stdout_results, stderr_results = proc.communicate()
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1327
            if len(stderr_results) == 0:
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1328
                processors = int(stdout_results)
5273
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1329
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1330
    #
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1331
    # Now, spin up one thread per processor which will eventually mean one test
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1332
    # per processor running concurrently.
c95bd39cc980 Remove multiprocessing dependency in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5257
diff changeset
  1333
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1334
    for i in range(processors):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1335
        thread = worker_thread(input_queue, output_queue)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1336
        threads.append(thread)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1337
        thread.start()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1338
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1339
    #
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1340
    # Keep track of some summary statistics
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1341
    #
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1342
    total_tests = 0
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1343
    skipped_tests = 0
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1344
    skipped_testnames = []
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1345
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1346
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1347
    # We now have worker threads spun up, and a list of work to do.  So, run 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1348
    # through the list of test suites and dispatch a job to run each one.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1349
    # 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1350
    # Dispatching will run with unlimited speed and the worker threads will 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1351
    # execute as fast as possible from the queue.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1352
    #
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1353
    # Note that we actually dispatch tests to be skipped, so all of the 
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1354
    # PASS, FAIL, CRASH and SKIP processing is done in the same place.
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1355
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1356
    for test in suite_list:
5461
ac47584eca3e Make test.py work on MinGW
Craig Dowell <craigdo@ee.washington.edu>
parents: 5460
diff changeset
  1357
        test = test.strip()
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1358
        if len(test):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1359
            job = Job()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1360
            job.set_is_example(False)
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1361
            job.set_is_pyexample(False)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1362
            job.set_display_name(test)
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1363
            job.set_tmp_file_name(os.path.join(testpy_output_dir, "%s.xml" % test))
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1364
            job.set_cwd(os.getcwd())
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1365
            job.set_basedir(os.getcwd())
5481
de01c67af975 pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents: 5470
diff changeset
  1366
            job.set_tempdir(testpy_output_dir)
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
  1367
            if (options.multiple):
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1368
                multiple = ""
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
  1369
            else:
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1370
                multiple = " --stop-on-failure"
9265
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9256
diff changeset
  1371
            if (len(options.fullness)):
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9256
diff changeset
  1372
                fullness = options.fullness.upper()
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9256
diff changeset
  1373
                fullness = " --fullness=%s" % fullness
9256
68d3f772c696 Allow very slow test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9220
diff changeset
  1374
            else:
9265
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9256
diff changeset
  1375
                fullness = " --fullness=QUICK"
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
  1376
9265
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9256
diff changeset
  1377
            path_cmd = os.path.join("utils", test_runner_name + " --test-name=%s%s%s" % (test, multiple, fullness))
9256
68d3f772c696 Allow very slow test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9220
diff changeset
  1378
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1379
            job.set_shell_command(path_cmd)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1380
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1381
            if options.valgrind and test in core_valgrind_skip_tests:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1382
                job.set_is_skip(True)
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1383
6619
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
  1384
            # Skip tests that will fail if NSC is missing.
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
  1385
            if not NSC_ENABLED and test in core_nsc_missing_skip_tests:
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
  1386
                job.set_is_skip(True)
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
  1387
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1388
            if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1389
                print("Queue %s" % test)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1390
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1391
            input_queue.put(job)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1392
            jobs = jobs + 1
5279
1aec8ea805d2 update tcp interop response vectors
Craig Dowell <craigdo@ee.washington.edu>
parents: 5275
diff changeset
  1393
            total_tests = total_tests + 1
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1394
    
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1395
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1396
    # We've taken care of the discovered or specified test suites.  Now we
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1397
    # have to deal with examples run as smoke tests.  We have a list of all of
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1398
    # the example programs it makes sense to try and run.  Each example will
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1399
    # have a condition associated with it that must evaluate to true for us
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1400
    # to try and execute it.  This is used to determine if the example has
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1401
    # a dependency that is not satisfied.  For example, if an example depends
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1402
    # on NSC being configured by waf, that example should have a condition
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1403
    # that evaluates to true if NSC is enabled.  For example,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1404
    #
6619
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
  1405
    #      ("tcp-nsc-zoo", "NSC_ENABLED == True"),
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1406
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1407
    # In this case, the example "tcp-nsc-zoo" will only be run if we find the
6619
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
  1408
    # waf configuration variable "NSC_ENABLED" to be True.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1409
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1410
    # We don't care at all how the trace files come out, so we just write them 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1411
    # to a single temporary directory.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1412
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1413
    # XXX As it stands, all of the trace files have unique names, and so file
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1414
    # collisions can only happen if two instances of an example are running in
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1415
    # two versions of the test.py process concurrently.  We may want to create
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1416
    # uniquely named temporary traces directories to avoid this problem.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1417
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1418
    # We need to figure out what examples to execute.  We are either given one 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1419
    # suite or example explicitly via the --suite or --example option, or we
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1420
    # need to walk the list of examples looking for available example 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1421
    # conditions.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1422
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1423
    # This translates into allowing the following options with respect to the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1424
    # suites
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1425
    #
9072
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1426
    #  ./test.py:                                           run all of the examples
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1427
    #  ./test.py --constrain=unit                           run no examples
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1428
    #  ./test.py --constrain=example                        run all of the examples
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1429
    #  ./test.py --suite=some-test-suite:                   run no examples
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1430
    #  ./test.py --example=some-example:                    run the single example
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1431
    #  ./test.py --suite=some-suite --example=some-example: run the single example
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1432
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1433
    #
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1434
    if len(options.suite) == 0 and len(options.example) == 0 and len(options.pyexample) == 0:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1435
        if len(options.constrain) == 0 or options.constrain == "example":
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5351
diff changeset
  1436
            if ENABLE_EXAMPLES:
10554
ee9c5221e7bd Strip NS3_BUILDDIR from Example path.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9852
diff changeset
  1437
                for name, test, do_run, do_valgrind_run in example_tests:
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
  1438
                    # Remove any arguments and directory names from test.
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
  1439
                    test_name = test.split(' ', 1)[0] 
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
  1440
                    test_name = os.path.basename(test_name)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1441
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1442
                    # Don't try to run this example if it isn't runnable.
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1443
                    if test_name in ns3_runnable_programs_dictionary:
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1444
                        if eval(do_run):
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1445
                            job = Job()
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1446
                            job.set_is_example(True)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1447
                            job.set_is_pyexample(False)
10554
ee9c5221e7bd Strip NS3_BUILDDIR from Example path.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9852
diff changeset
  1448
                            job.set_display_name(name)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1449
                            job.set_tmp_file_name("")
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1450
                            job.set_cwd(testpy_output_dir)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1451
                            job.set_basedir(os.getcwd())
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1452
                            job.set_tempdir(testpy_output_dir)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1453
                            job.set_shell_command(test)
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1454
                            job.set_build_path(options.buildpath)
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1455
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1456
                            if options.valgrind and not eval(do_valgrind_run):
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1457
                                job.set_is_skip (True)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1458
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1459
                            if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1460
                                print("Queue %s" % test)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1461
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1462
                            input_queue.put(job)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1463
                            jobs = jobs + 1
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1464
                            total_tests = total_tests + 1
5279
1aec8ea805d2 update tcp interop response vectors
Craig Dowell <craigdo@ee.washington.edu>
parents: 5275
diff changeset
  1465
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1466
    elif len(options.example):
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1467
        # Add the proper prefix and suffix to the example name to
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1468
        # match what is done in the wscript file.
9850
aff1dc7687f1 Bug 1707 - test.py doesn't work with the release profile
Mitch Watrous <watrous@u.washington.edu>
parents: 9832
diff changeset
  1469
        example_name = "%s%s-%s%s" % (APPNAME, VERSION, options.example, BUILD_PROFILE_SUFFIX)
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1470
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1471
        # Don't try to run this example if it isn't runnable.
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1472
        if example_name not in ns3_runnable_programs_dictionary:
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1473
            print("Example %s is not runnable." % example_name)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1474
        else:
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1475
            #
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1476
            # If you tell me to run an example, I will try and run the example
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1477
            # irrespective of any condition.
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1478
            #
9076
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1479
            example_path = ns3_runnable_programs_dictionary[example_name]
9852
78f437d03c3c Bug 1710 - Examples crash when run like this: ./test.py -e example-name
Mitch Watrous <watrous@u.washington.edu>
parents: 9851
diff changeset
  1480
            example_path = os.path.abspath(example_path)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1481
            job = Job()
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1482
            job.set_is_example(True)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1483
            job.set_is_pyexample(False)
9076
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1484
            job.set_display_name(example_path)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1485
            job.set_tmp_file_name("")
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1486
            job.set_cwd(testpy_output_dir)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1487
            job.set_basedir(os.getcwd())
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1488
            job.set_tempdir(testpy_output_dir)
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7669
diff changeset
  1489
            job.set_shell_command(example_path)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1490
            job.set_build_path(options.buildpath)
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1491
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1492
            if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1493
                print("Queue %s" % example_name)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1494
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1495
            input_queue.put(job)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1496
            jobs = jobs + 1
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1497
            total_tests = total_tests + 1
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1498
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1499
    #
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1500
    # Run some Python examples as smoke tests.  We have a list of all of
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1501
    # the example programs it makes sense to try and run.  Each example will
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1502
    # have a condition associated with it that must evaluate to true for us
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1503
    # to try and execute it.  This is used to determine if the example has
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1504
    # a dependency that is not satisfied.
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1505
    #
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1506
    # We don't care at all how the trace files come out, so we just write them 
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1507
    # to a single temporary directory.
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1508
    #
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1509
    # We need to figure out what python examples to execute.  We are either 
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1510
    # given one pyexample explicitly via the --pyexample option, or we
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1511
    # need to walk the list of python examples
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1512
    #
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1513
    # This translates into allowing the following options with respect to the 
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1514
    # suites
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1515
    #
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1516
    #  ./test.py --constrain=pyexample           run all of the python examples
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1517
    #  ./test.py --pyexample=some-example.py:    run the single python example
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1518
    #
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1519
    if len(options.suite) == 0 and len(options.example) == 0 and len(options.pyexample) == 0:
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1520
        if len(options.constrain) == 0 or options.constrain == "pyexample":
6247
ab7f2498373a report skipping python tests, don't valgrind them
Craig Dowell <craigdo@ee.washington.edu>
parents: 6243
diff changeset
  1521
            if ENABLE_EXAMPLES:
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1522
                for test, do_run in python_tests:
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
  1523
                    # Remove any arguments and directory names from test.
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
  1524
                    test_name = test.split(' ', 1)[0] 
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
  1525
                    test_name = os.path.basename(test_name)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1526
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1527
                    # Don't try to run this example if it isn't runnable.
7864
d0df2d56ae9c Bug 1415 - examples-to-run.py doesn't work with command line arguments
Mitch Watrous <watrous@u.washington.edu>
parents: 7819
diff changeset
  1528
                    if test_name in ns3_runnable_scripts:
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1529
                        if eval(do_run):
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1530
                            job = Job()
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1531
                            job.set_is_example(False)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1532
                            job.set_is_pyexample(True)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1533
                            job.set_display_name(test)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1534
                            job.set_tmp_file_name("")
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1535
                            job.set_cwd(testpy_output_dir)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1536
                            job.set_basedir(os.getcwd())
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1537
                            job.set_tempdir(testpy_output_dir)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1538
                            job.set_shell_command(test)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1539
                            job.set_build_path("")
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1540
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1541
                            #
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1542
                            # Python programs and valgrind do not work and play
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1543
                            # well together, so we skip them under valgrind.
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1544
                            # We go through the trouble of doing all of this
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1545
                            # work to report the skipped tests in a consistent
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1546
                            # way throught the output formatter.
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1547
                            #
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1548
                            if options.valgrind:
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1549
                                job.set_is_skip (True)
6247
ab7f2498373a report skipping python tests, don't valgrind them
Craig Dowell <craigdo@ee.washington.edu>
parents: 6243
diff changeset
  1550
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1551
                            #
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1552
                            # The user can disable python bindings, so we need
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1553
                            # to pay attention to that and give some feedback
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1554
                            # that we're not testing them
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1555
                            #
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1556
                            if not ENABLE_PYTHON_BINDINGS:
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1557
                                job.set_is_skip (True)
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1558
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1559
                            if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1560
                                print("Queue %s" % test)
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1561
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1562
                            input_queue.put(job)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1563
                            jobs = jobs + 1
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1564
                            total_tests = total_tests + 1
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1565
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1566
    elif len(options.pyexample):
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1567
        # Don't try to run this example if it isn't runnable.
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1568
        example_name = os.path.basename(options.pyexample)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1569
        if example_name not in ns3_runnable_scripts:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1570
            print("Example %s is not runnable." % example_name)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1571
        else:
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1572
            #
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1573
            # If you tell me to run a python example, I will try and run the example
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1574
            # irrespective of any condition.
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1575
            #
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1576
            job = Job()
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1577
            job.set_is_pyexample(True)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1578
            job.set_display_name(options.pyexample)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1579
            job.set_tmp_file_name("")
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1580
            job.set_cwd(testpy_output_dir)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1581
            job.set_basedir(os.getcwd())
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1582
            job.set_tempdir(testpy_output_dir)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1583
            job.set_shell_command(options.pyexample)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1584
            job.set_build_path("")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1585
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1586
            if options.verbose:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1587
                print("Queue %s" % options.pyexample)
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1588
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1589
            input_queue.put(job)
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1590
            jobs = jobs + 1
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7087
diff changeset
  1591
            total_tests = total_tests + 1
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1592
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1593
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1594
    # Tell the worker threads to pack up and go home for the day.  Each one
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1595
    # will exit when they see their is_break task.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1596
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1597
    for i in range(processors):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1598
        job = Job()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1599
        job.set_is_break(True)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1600
        input_queue.put(job)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1601
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1602
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1603
    # Now all of the tests have been dispatched, so all we have to do here
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1604
    # in the main thread is to wait for them to complete.  Keyboard interrupt
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1605
    # handling is broken as mentioned above.  We use a signal handler to catch
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1606
    # sigint and set a global variable.  When the worker threads sense this
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1607
    # they stop doing real work and will just start throwing jobs back at us
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1608
    # with is_break set to True.  In this case, there are no real results so we 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1609
    # ignore them.  If there are real results, we always print PASS or FAIL to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1610
    # standard out as a quick indication of what happened.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1611
    #
5279
1aec8ea805d2 update tcp interop response vectors
Craig Dowell <craigdo@ee.washington.edu>
parents: 5275
diff changeset
  1612
    passed_tests = 0
1aec8ea805d2 update tcp interop response vectors
Craig Dowell <craigdo@ee.washington.edu>
parents: 5275
diff changeset
  1613
    failed_tests = 0
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1614
    failed_testnames = []
5279
1aec8ea805d2 update tcp interop response vectors
Craig Dowell <craigdo@ee.washington.edu>
parents: 5275
diff changeset
  1615
    crashed_tests = 0
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1616
    crashed_testnames = []
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1617
    valgrind_errors = 0
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1618
    valgrind_testnames = []
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1619
    for i in range(jobs):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1620
        job = output_queue.get()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1621
        if job.is_break:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1622
            continue
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1623
6203
1204777b0bcf bug 856, initialize vbl
Craig Dowell <craigdo@ee.washington.edu>
parents: 6202
diff changeset
  1624
        if job.is_example or job.is_pyexample:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1625
            kind = "Example"
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1626
        else:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1627
            kind = "TestSuite"
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1628
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1629
        if job.is_skip:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1630
            status = "SKIP"
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1631
            skipped_tests = skipped_tests + 1
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1632
            skipped_testnames.append(job.display_name)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1633
        else:
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1634
            if job.returncode == 0:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1635
                status = "PASS"
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1636
                passed_tests = passed_tests + 1
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1637
            elif job.returncode == 1:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1638
                failed_tests = failed_tests + 1
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1639
                failed_testnames.append(job.display_name)
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1640
                status = "FAIL"
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1641
            elif job.returncode == 2:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1642
                valgrind_errors = valgrind_errors + 1
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1643
                valgrind_testnames.append(job.display_name)
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1644
                status = "VALGR"
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1645
            else:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1646
                crashed_tests = crashed_tests + 1
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1647
                crashed_testnames.append(job.display_name)
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1648
                status = "CRASH"
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1649
9072
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1650
        if options.duration or options.constrain == "performance":
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1651
            print("%s (%.3f): %s %s" % (status, job.elapsed_time, kind, job.display_name))
9072
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1652
        else:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1653
            print("%s: %s %s" % (status, kind, job.display_name))
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1654
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1655
        if job.is_example or job.is_pyexample:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1656
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1657
            # Examples are the odd man out here.  They are written without any
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1658
            # knowledge that they are going to be run as a test, so we need to 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1659
            # cook up some kind of output for them.  We're writing an xml file,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1660
            # so we do some simple XML that says we ran the example.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1661
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1662
            # XXX We could add some timing information to the examples, i.e. run
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1663
            # them through time and print the results here.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1664
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1665
            f = open(xml_results_file, 'a')
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1666
            f.write('<Example>\n')
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1667
            example_name = "  <Name>%s</Name>\n" % job.display_name
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1668
            f.write(example_name)
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1669
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1670
            if status == "PASS":
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1671
                f.write('  <Result>PASS</Result>\n')
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1672
            elif status == "FAIL":
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1673
                f.write('  <Result>FAIL</Result>\n')
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1674
            elif status == "VALGR":
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1675
                f.write('  <Result>VALGR</Result>\n')
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1676
            elif status == "SKIP":
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1677
                f.write('  <Result>SKIP</Result>\n')
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1678
            else:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1679
                f.write('  <Result>CRASH</Result>\n')
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1680
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1681
            f.write('  <Time real="%.3f"/>\n' % job.elapsed_time)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1682
            f.write('</Example>\n')
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1683
            f.close()
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1684
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1685
        else:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1686
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1687
            # If we're not running an example, we're running a test suite.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1688
            # These puppies are running concurrently and generating output
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1689
            # that was written to a temporary file to avoid collisions.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1690
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1691
            # Now that we are executing sequentially in the main thread, we can
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1692
            # concatenate the contents of the associated temp file to the main 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1693
            # results file and remove that temp file.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1694
            #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1695
            # One thing to consider is that a test suite can crash just as
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1696
            # well as any other program, so we need to deal with that 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1697
            # possibility as well.  If it ran correctly it will return 0
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1698
            # if it passed, or 1 if it failed.  In this case, we can count
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1699
            # on the results file it saved being complete.  If it crashed, it 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1700
            # will return some other code, and the file should be considered 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1701
            # corrupt and useless.  If the suite didn't create any XML, then
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1702
            # we're going to have to do it ourselves.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1703
            #
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1704
            # Another issue is how to deal with a valgrind error.  If we run
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1705
            # a test suite under valgrind and it passes, we will get a return
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1706
            # code of 0 and there will be a valid xml results file since the code
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1707
            # ran to completion.  If we get a return code of 1 under valgrind,
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1708
            # the test case failed, but valgrind did not find any problems so the
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1709
            # test case return code was passed through.  We will have a valid xml
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1710
            # results file here as well since the test suite ran.  If we see a 
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1711
            # return code of 2, this means that valgrind found an error (we asked
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1712
            # it to return 2 if it found a problem in run_job_synchronously) but
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1713
            # the suite ran to completion so there is a valid xml results file.
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1714
            # If the suite crashes under valgrind we will see some other error 
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1715
            # return code (like 139).  If valgrind finds an illegal instruction or
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1716
            # some other strange problem, it will die with its own strange return
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1717
            # code (like 132).  However, if the test crashes by itself, not under
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1718
            # valgrind we will also see some other return code.
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1719
            #
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1720
            # If the return code is 0, 1, or 2, we have a valid xml file.  If we 
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1721
            # get another return code, we have no xml and we can't really say what
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1722
            # happened -- maybe the TestSuite crashed, maybe valgrind crashed due
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1723
            # to an illegal instruction.  If we get something beside 0-2, we assume
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1724
            # a crash and fake up an xml entry.  After this is all done, we still
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1725
            # need to indicate a valgrind error somehow, so we fake up an xml entry
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1726
            # with a VALGR result.  Thus, in the case of a working TestSuite that
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1727
            # fails valgrind, we'll see the PASS entry for the working TestSuite
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1728
            # followed by a VALGR failing test suite of the same name.
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1729
            #
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1730
            if job.is_skip:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1731
                f = open(xml_results_file, 'a')
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1732
                f.write("<Test>\n")
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1733
                f.write("  <Name>%s</Name>\n" % job.display_name)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1734
                f.write('  <Result>SKIP</Result>\n')
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1735
                f.write("</Test>\n")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1736
                f.close()
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1737
            else:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1738
                if job.returncode == 0 or job.returncode == 1 or job.returncode == 2:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1739
                    f_to = open(xml_results_file, 'a')
5459
3c240ed38d99 try and make test.py a bit more portable
Craig Dowell <craigdo@ee.washington.edu>
parents: 5415
diff changeset
  1740
                    f_from = open(job.tmp_file_name)
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1741
                    f_to.write(f_from.read())
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1742
                    f_to.close()
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1743
                    f_from.close()
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1744
                else:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1745
                    f = open(xml_results_file, 'a')
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1746
                    f.write("<Test>\n")
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1747
                    f.write("  <Name>%s</Name>\n" % job.display_name)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1748
                    f.write('  <Result>CRASH</Suite>\n')
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1749
                    f.write("</Test>\n")
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1750
                    f.close()
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1751
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1752
                    if job.returncode == 2:
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1753
                        f = open(xml_results_file, 'a')
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1754
                        f.write("<Test>\n")
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1755
                        f.write("  <Name>%s</Name>\n" % job.display_name)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1756
                        f.write('  <Result>VALGR</Result>\n')
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1757
                        f.write("</Test>\n")
5402
b73b6da8ead6 teach test.py to skip selected tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5390
diff changeset
  1758
                        f.close()
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1759
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1760
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1761
    # We have all of the tests run and the results written out.  One final 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1762
    # bit of housekeeping is to wait for all of the threads to close down
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1763
    # so we can exit gracefully.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1764
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1765
    for thread in threads:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1766
        thread.join()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1767
    
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1768
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1769
    # Back at the beginning of time, we started the body of an XML document
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1770
    # since the test suites and examples were going to just write their 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1771
    # individual pieces.  So, we need to finish off and close out the XML 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1772
    # document
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1773
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1774
    f = open(xml_results_file, 'a')
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1775
    f.write('</Results>\n')
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1776
    f.close()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1777
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1778
    #
5279
1aec8ea805d2 update tcp interop response vectors
Craig Dowell <craigdo@ee.washington.edu>
parents: 5275
diff changeset
  1779
    # Print a quick summary of events
1aec8ea805d2 update tcp interop response vectors
Craig Dowell <craigdo@ee.washington.edu>
parents: 5275
diff changeset
  1780
    #
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1781
    print("%d of %d tests passed (%d passed, %d skipped, %d failed, %d crashed, %d valgrind errors)" % (passed_tests, 
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1782
        total_tests, passed_tests, skipped_tests, failed_tests, crashed_tests, valgrind_errors))
5279
1aec8ea805d2 update tcp interop response vectors
Craig Dowell <craigdo@ee.washington.edu>
parents: 5275
diff changeset
  1783
    #
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1784
    # Repeat summary of skipped, failed, crashed, valgrind events 
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1785
    #
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1786
    if skipped_testnames:
11031
88aba7d03b9a Sort and pretty-print result lists of SKIPped, FAILed, CRASHed and VALGR tests from ./test.py
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10828
diff changeset
  1787
        skipped_testnames.sort()
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1788
        print('List of SKIPped tests:\n    %s' % '\n    '.join(map(str, skipped_testnames)))
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1789
    if failed_testnames:
11031
88aba7d03b9a Sort and pretty-print result lists of SKIPped, FAILed, CRASHed and VALGR tests from ./test.py
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10828
diff changeset
  1790
        failed_testnames.sort()
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1791
        print('List of FAILed tests:\n    %s' % '\n    '.join(map(str, failed_testnames)))
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1792
    if crashed_testnames:
11031
88aba7d03b9a Sort and pretty-print result lists of SKIPped, FAILed, CRASHed and VALGR tests from ./test.py
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10828
diff changeset
  1793
        crashed_testnames.sort()
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1794
        print('List of CRASHed tests:\n    %s' % '\n    '.join(map(str, crashed_testnames)))
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1795
    if valgrind_testnames:
11031
88aba7d03b9a Sort and pretty-print result lists of SKIPped, FAILed, CRASHed and VALGR tests from ./test.py
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10828
diff changeset
  1796
        valgrind_testnames.sort()
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1797
        print('List of VALGR failures:\n    %s' % '\n    '.join(map(str, valgrind_testnames)))
10766
04ea88ac6d8d append list of skipped/failed/crashed/valgrined tests to end of test.py output
Tom Henderson <tomh@tomh.org>
parents: 10554
diff changeset
  1798
    #
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1799
    # The last things to do are to translate the XML results file to "human
5239
2e753de86174 Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
  1800
    # readable form" if the user asked for it (or make an XML file somewhere)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1801
    #
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1802
    if len(options.html):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1803
        translate_to_html(xml_results_file, options.html)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1804
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1805
    if len(options.text):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1806
        translate_to_text(xml_results_file, options.text)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1807
5239
2e753de86174 Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
  1808
    if len(options.xml):
2e753de86174 Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
  1809
        shutil.copyfile(xml_results_file, options.xml)
2e753de86174 Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
  1810
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1811
    #
7245
4b245d55faa2 Bug 1146 - help string for test.py with disabled tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7199
diff changeset
  1812
    # Let the user know if they need to turn on tests or examples.
4b245d55faa2 Bug 1146 - help string for test.py with disabled tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7199
diff changeset
  1813
    #
4b245d55faa2 Bug 1146 - help string for test.py with disabled tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7199
diff changeset
  1814
    if not ENABLE_TESTS or not ENABLE_EXAMPLES:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1815
        print()
7245
4b245d55faa2 Bug 1146 - help string for test.py with disabled tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7199
diff changeset
  1816
        if not ENABLE_TESTS:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1817
            print('***  Note: ns-3 tests are currently disabled. Enable them by adding')
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1818
            print('***  "--enable-tests" to ./waf configure or modifying your .ns3rc file.')
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1819
            print()
7245
4b245d55faa2 Bug 1146 - help string for test.py with disabled tests
Mitch Watrous <watrous@u.washington.edu>
parents: 7199
diff changeset
  1820
        if not ENABLE_EXAMPLES:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1821
            print('***  Note: ns-3 examples are currently disabled. Enable them by adding')
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1822
            print('***  "--enable-examples" to ./waf configure or modifying your .ns3rc file.')
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1823
            print()
9826
8a9f775a4cba Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9265
diff changeset
  1824
8a9f775a4cba Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9265
diff changeset
  1825
    #
9832
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
  1826
    # Let the user know if they tried to use valgrind but it was not
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
  1827
    # present on their machine.
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
  1828
    #
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
  1829
    if options.valgrind and not VALGRIND_FOUND:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1830
        print()
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1831
        print('***  Note: you are trying to use valgrind, but valgrind could not be found')
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1832
        print('***  on your machine.  All tests and examples will crash or be skipped.')
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11412
diff changeset
  1833
        print()
9832
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
  1834
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
  1835
    #
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1836
    # If we have been asked to retain all of the little temporary files, we
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1837
    # don't delete tm.  If we do delete the temporary files, delete only the
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1838
    # directory we just created.  We don't want to happily delete any retained
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1839
    # directories, which will probably surprise the user.
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1840
    #
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1841
    if not options.retain:
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1842
        shutil.rmtree(testpy_output_dir)
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5403
diff changeset
  1843
5403
530155ecdbcb fix ns3-tcp-cwnd unit test
Craig Dowell <craigdo@ee.washington.edu>
parents: 5402
diff changeset
  1844
    if passed_tests + skipped_tests == total_tests:
5351
6abced63cd7f keep wifi-ap from spewing all over std_out during tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5350
diff changeset
  1845
        return 0 # success
5350
9f457bebbcf4 have test.py return status
Craig Dowell <craigdo@ee.washington.edu>
parents: 5324
diff changeset
  1846
    else:
5351
6abced63cd7f keep wifi-ap from spewing all over std_out during tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 5350
diff changeset
  1847
        return 1 # catchall for general errors
5350
9f457bebbcf4 have test.py return status
Craig Dowell <craigdo@ee.washington.edu>
parents: 5324
diff changeset
  1848
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1849
def main(argv):
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1850
    parser = optparse.OptionParser()
7087
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
  1851
    parser.add_option("-b", "--buildpath", action="store", type="string", dest="buildpath", default="",
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
  1852
                      metavar="BUILDPATH",
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
  1853
                      help="specify the path where ns-3 was built (defaults to the build directory for the current variant)")
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
  1854
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1855
    parser.add_option("-c", "--constrain", action="store", type="string", dest="constrain", default="",
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1856
                      metavar="KIND",
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1857
                      help="constrain the test-runner by kind of test")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1858
9072
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1859
    parser.add_option("-d", "--duration", action="store_true", dest="duration", default=False,
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1860
                      help="print the duration of each test suite and example")
7bfaded450be Bug 1284 - ./test.py performance tests do not exist
Mitch Watrous <watrous@u.washington.edu>
parents: 8919
diff changeset
  1861
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1862
    parser.add_option("-e", "--example", action="store", type="string", dest="example", default="",
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1863
                      metavar="EXAMPLE",
9076
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 9075
diff changeset
  1864
                      help="specify a single example to run (no relative path is needed)")
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1865
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1866
    parser.add_option("-u", "--update-data", action="store_true", dest="update_data", default=False,
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1867
                      help="If examples use reference data files, get them to re-generate them")
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7259
diff changeset
  1868
9265
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9256
diff changeset
  1869
    parser.add_option("-f", "--fullness", action="store", type="string", dest="fullness", default="QUICK",
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9256
diff changeset
  1870
                      metavar="FULLNESS",
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9256
diff changeset
  1871
                      help="choose the duration of tests to run: QUICK, EXTENSIVE, or TAKES_FOREVER, where EXTENSIVE includes QUICK and TAKES_FOREVER includes QUICK and EXTENSIVE (only QUICK tests are run by default)")
9256
68d3f772c696 Allow very slow test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9220
diff changeset
  1872
5370
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1873
    parser.add_option("-g", "--grind", action="store_true", dest="valgrind", default=False,
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1874
                      help="run the test suites and examples using valgrind")
a27163124701 add valgrind powers back to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
  1875
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1876
    parser.add_option("-k", "--kinds", action="store_true", dest="kinds", default=False,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1877
                      help="print the kinds of tests available")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1878
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1879
    parser.add_option("-l", "--list", action="store_true", dest="list", default=False,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1880
                      help="print the list of known tests")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1881
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
  1882
    parser.add_option("-m", "--multiple", action="store_true", dest="multiple", default=False,
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
  1883
                      help="report multiple failures from test suites and test cases")
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5295
diff changeset
  1884
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1885
    parser.add_option("-n", "--nowaf", action="store_true", dest="nowaf", default=False,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1886
                      help="do not run waf before starting testing")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1887
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1888
    parser.add_option("-p", "--pyexample", action="store", type="string", dest="pyexample", default="",
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1889
                      metavar="PYEXAMPLE",
7087
18ae03e01c6f Bug 1108 - test.py -e option needs repair
Mitch Watrous <watrous@u.washington.edu>
parents: 7028
diff changeset
  1890
                      help="specify a single python example to run (with relative path)")
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1891
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1892
    parser.add_option("-r", "--retain", action="store_true", dest="retain", default=False,
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1893
                      help="retain all temporary files (which are normally deleted)")
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1894
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1895
    parser.add_option("-s", "--suite", action="store", type="string", dest="suite", default="",
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1896
                      metavar="TEST-SUITE",
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1897
                      help="specify a single test suite to run")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1898
6200
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1899
    parser.add_option("-t", "--text", action="store", type="string", dest="text", default="",
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1900
                      metavar="TEXT-FILE",
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1901
                      help="write detailed test results into TEXT-FILE.txt")
2bf2700b6e67 Add some python examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 6127
diff changeset
  1902
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1903
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1904
                      help="print progress and informational messages")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1905
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1906
    parser.add_option("-w", "--web", "--html", action="store", type="string", dest="html", default="",
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1907
                      metavar="HTML-FILE",
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1908
                      help="write detailed test results into HTML-FILE.html")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1909
5239
2e753de86174 Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
  1910
    parser.add_option("-x", "--xml", action="store", type="string", dest="xml", default="",
2e753de86174 Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
  1911
                      metavar="XML-FILE",
2e753de86174 Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
  1912
                      help="write detailed test results into XML-FILE.xml")
2e753de86174 Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
  1913
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1914
    global options
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1915
    options = parser.parse_args()[0]
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1916
    signal.signal(signal.SIGINT, sigint_hook)
6619
c6e03f378655 Fixed problems due to missing NSC.
Mitch Watrous <watrous@u.washington.edu>
parents: 6374
diff changeset
  1917
5350
9f457bebbcf4 have test.py return status
Craig Dowell <craigdo@ee.washington.edu>
parents: 5324
diff changeset
  1918
    return run_tests()
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1919
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1920
if __name__ == '__main__':
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1921
    sys.exit(main(sys.argv))